本文整理汇总了C#中Subject.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# Subject.ToString方法的具体用法?C# Subject.ToString怎么用?C# Subject.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Subject
的用法示例。
在下文中一共展示了Subject.ToString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SubjectTitle
public static string SubjectTitle( Subject subject )
{
string str = subject.ToString();
int index = 1;
int i = FindIndex(str, index);
while( i >= 0 )
{
str = str.Insert(i, " ");
index = i + 2;
i = FindIndex(str, index);
}
return str;
}
示例2: InsertButton_Click
private void InsertButton_Click(object sender, EventArgs e)
{
try
{
DialogResult res;
if (ProfessorBox2.Text.Length == 0)
{
MessageBox.Show("Professor name is empty");
return;
}
if (ClassroomBox2.Text.Length == 0)
{
MessageBox.Show("Classroom name is empty");
return;
}
if (DayChecklist.CheckedItems.Count == 0)
{
MessageBox.Show("Please choose day/s");
return;
}
if (SubjectBox2.Text.Length == 0)
{
res = MessageBox.Show("Continue with empty subject?", "Insert Schedule", MessageBoxButtons.YesNo);
if (res == DialogResult.No) return;
SaveButton.Enabled = true;
}
// parse professor
Professor p = Program.db.GetProfessor(ProfessorBox2.Text);
if (p == null)
{
res = MessageBox.Show("Professor with name \"" + ProfessorBox2.Text + "\" does not exist.\nAdd new Professor to the database?", "Insert Schedule", MessageBoxButtons.YesNo);
if (res == DialogResult.No) return;
int size = Program.db.AllProfessors.Count;
AddProfessorForm f = new AddProfessorForm();
p = new Professor(ProfessorBox2.Text, "", "", "");
f.LastNameBox.Text = p.LastName;
f.FirstNameBox.Text = p.FirstName;
f.ShowDialog();
if (size == Program.db.AllProfessors.Count) return;
p = (Professor)ProfessorList.SelectedItem;
SaveButton.Enabled = true;
}
Room r = Program.db.GetRoom(ClassroomBox2.Text);
if (r == null)
{
res = MessageBox.Show("Classroom with name \"" + ClassroomBox2.Text + "\" does not exist.\nAdd new Classroom to the database?", "Insert Schedule", MessageBoxButtons.YesNo);
if (res == DialogResult.No) return;
r = Program.db.AddRoom(new Room(ClassroomBox2.Text));
RoomList.DataSource = Program.db.AllRooms.Clone();
RenewRoomList();
RoomList.SelectedItem = r;
SaveButton.Enabled = true;
}
Subject s = new Subject(SubjectBox2.Text, p, r);
// check if subjects exists
if (SubjectBox2.Text.Length != 0)
{
string str = SubjectBox2.Text;
if (!SubjectBox2.AutoCompleteCustomSource.Contains(str))
{
SubjectBox2.AutoCompleteCustomSource.Add(str);
string[] newSubjectList = new string[SubjectBox2.AutoCompleteCustomSource.Count];
SubjectBox2.AutoCompleteCustomSource.CopyTo(newSubjectList, 0);
Array.Sort(newSubjectList);
//MessageBox.Show(String.Join(", ", newSubjectList));
SubjectList.DataSource = newSubjectList;
SubjectList.SelectedItem = str;
RenewSubjectList();
SubjectList.SelectedItem = str;
//MessageBox.Show(str);
SaveButton.Enabled = true;
}
}
// make schedule/s
res = MessageBox.Show("You are about to insert Schedule:\n" + s.ToString() + "\n" + TimeStartBox.Text + " to " + TimeEndBox.Text + "\n" + DayBox.Text, "Insert Schedule", MessageBoxButtons.OKCancel);
if (res == DialogResult.Cancel) return;
ArrayList Schedules = new ArrayList();
ArrayList ConflictList = new ArrayList();
Boolean HasConflict = false;
foreach (int i in DayChecklist.CheckedIndices)
{
Schedule sched = new Schedule(s, new Time(i, TimeStartBox.Text), new Time(i, TimeEndBox.Text));
Schedule conflict = Program.db.GetConflict(sched);
Schedules.Add(sched);
ConflictList.Add(conflict);
if (conflict != null)
{
HasConflict = true;
}
}
if (HasConflict)
{
new ShowConflictsForm(Schedules, ConflictList).ShowDialog();
return;
}
// insert new schedules! xD
//.........这里部分代码省略.........