public static string DayToString(enumDay day) { if (day == enumDay.Monday) { return("Понедельник"); } if (day == enumDay.Thuesday) { return("Вторник"); } if (day == enumDay.Wednesday) { return("Среда"); } if (day == enumDay.Thursday) { return("Четверг"); } if (day == enumDay.Friday) { return("Пятница"); } if (day == enumDay.Saturday) { return("Суббота"); } if (day == enumDay.Sunday) { return("Воскресенье"); } return("Неизвестно"); }
public static enumDay StringToDay(string day) { day = day.Trim(); if (day.ToLower() == "понедельник") { return(enumDay.Monday); } if (day.ToLower() == "вторник") { return(enumDay.Thuesday); } if (day.ToLower() == "среда") { return(enumDay.Wednesday); } if (day.ToLower() == "четверг") { return(enumDay.Thursday); } if (day.ToLower() == "пятница") { return(enumDay.Friday); } if (day.ToLower() == "суббота") { return(enumDay.Saturday); } if (day.ToLower() == "воскресенье") { return(enumDay.Sunday); } return(enumDay.Null); }
private void BtTask_Click(object sender, EventArgs e) { InputForm inputForm = new InputForm("Введите день недели"); if (inputForm.ShowDialog() == DialogResult.OK) { enumDay day = Lesson.StringToDay(inputForm.inText); if (day == enumDay.Null) { MessageBox.Show("Вы ввели некорректный день", "Ошибка"); return; } List <DataGridViewRow> rowList = new List <DataGridViewRow>(); foreach (DataGridViewRow row in dgv.Rows) { if (Lesson.StringToDay(row.Cells[2].Value.ToString()) != day) { rowList.Add(row); } } foreach (DataGridViewRow row in rowList) { dgv.Rows.Remove(row); } dgv.Sort(dgv.Columns[3], ListSortDirection.Ascending); } }
public Lesson(string name, string teacher, enumDay day, int pair, int room) { this.name = name; this.teacher = teacher; this.day = day; this.pair = pair; this.room = room; }
public Lesson() { name = "Name"; teacher = "Teacher"; day = enumDay.Null; pair = 1; room = 1; }
// Перевод из строки в экзмепляр Coffee public static Lesson RowToLesson(DataGridViewRow row) { string name = row.Cells[0].Value.ToString(); string teacher = row.Cells[1].Value.ToString(); enumDay day = Lesson.StringToDay(row.Cells[2].Value.ToString()); int pair = Int32.Parse(row.Cells[3].Value.ToString()); int room = Int32.Parse(row.Cells[4].Value.ToString()); return(new Lesson(name, teacher, day, pair, room)); }