void LoadTime() { int i = 1; dgTime.Rows.Clear(); using (Maintenance _maintain = new Maintenance()) { _maintain.GetTime().OrderBy(o => o.TimeCode).ToList().ForEach(x => { dgTime.Rows.Add(x.ID, i, string.Format("{0} to {1}", x.TimeStart.Value.ToLongTimeString(), x.TimeEnd.Value.ToLongTimeString()), false, x.TimeCode); i++; }); } }
void LoadTime() { dgTime.Rows.Clear(); int i = 1; using (Maintenance _maintain = new Maintenance()) { _maintain.GetTime().OrderBy(y => y.TimeCode).ToList().ForEach(x => { dgTime.Rows.Add(x.ID, i, x.TimeCode, x.TimeStart, x.TimeEnd, x.Active); i++; }); } ObjEnable(false); }
void GetDayAndTime() { dgDay.Rows.Clear(); dgTime.Rows.Clear(); using (Maintenance maintain = new Maintenance()) { maintain.GetDay().Where(y => y.Active == true).ToList().ForEach(x => { dgDay.Rows.Add(x.Day, false); }); maintain.GetTime().Where(y => y.Active == true).ToList().ForEach(t => { dgTime.Rows.Add(t.ID, string.Format("{0} to {1}", t.TimeStart.Value.ToShortTimeString(), t.TimeEnd.Value.ToShortTimeString()), false, t.TimeCode); }); } }
void LoadTime(string RoomCode) { int i = 1; dgTime.Rows.Clear(); using (Maintenance _maintain = new Maintenance()) { var valueGetTime = _maintain.GetTime(); valueGetTime.ForEach(x => { var valueRoomAndTime = _maintain.GetRoomTime().Where(xx => xx.RoomCode == RoomCode && xx.TimeCode == x.TimeCode).FirstOrDefault(); dgTime.Rows.Add(valueRoomAndTime != null ? valueRoomAndTime.ID : x.ID, i, x.TimeStart.Value.ToString("HH:mm:ss tt") + " to " + x.TimeEnd.Value.ToString("HH:mm:ss tt"), valueRoomAndTime != null ? valueRoomAndTime.Status : false, valueRoomAndTime != null ? valueRoomAndTime.TimeCode : x.TimeCode); i++; }); } }
void dgTime_CellClick(object sender, DataGridViewCellEventArgs e) { if (dgTime.Rows.Count > 0) { using (Maintenance _maintain = new Maintenance()) { var value = _maintain.GetTime().Where(x => x.ID == Convert.ToInt64(dgTime.SelectedRows[0].Cells[0].Value)).FirstOrDefault(); if (value != null) { dtStart.Value = value.TimeStart.Value; dtEnd.Value = value.TimeEnd.Value; txtCode.Text = value.TimeCode; cbActive.Checked = value.Active.Value; btnDelete = SystemProperties.BtnProperties(btnDelete, true, Imagename.Delete.ToString(), Imagename._delete.ToString()); btnEdit = SystemProperties.BtnProperties(btnEdit, true, Imagename.Edit.ToString(), Imagename._edit.ToString()); } } } }
void Save() { T_RegisteredStudentSemester ret = new T_RegisteredStudentSemester(); var StudentSelected = dgStudentList.Rows.Cast <DataGridViewRow>().Where(x => Convert.ToBoolean(x.Cells[6].Value)).ToList(); var DaySelected = dgDay.Rows.Cast <DataGridViewRow>().Where(d => Convert.ToBoolean(d.Cells[1].Value)).ToList(); var TimeSelected = dgTime.Rows.Cast <DataGridViewRow>().Where(t => Convert.ToBoolean(t.Cells[2].Value)).ToList(); if (StudentSelected.Count > 0) { StudentSelected.ForEach(s => { ret.StudentID = s.Cells[2].Value.ToString(); using (Students std = new Students()) { var stud = std.GetStudentInfo().Where(x => x.StudentID == s.Cells[2].Value.ToString()).FirstOrDefault(); ret.Active = true; ret.RFID = stud.RFIDNo; ret.RoomCode = cmbRoomCode.Text; ret.MessageID = cmbMessage.Text; ret.SubjectCode = cmbSubjectCode.Text; ret.SubjectDescription = txtSubjectDesc.Text; ret.Semester = SystemProperties.SemesterActive.Semester; ret.SemStartDate = SystemProperties.SemesterActive.Start; ret.SemEndDate = SystemProperties.SemesterActive.End; ret.YearClass = SystemProperties.SemesterActive.YearSemester; using (Parents parent = new Parents()) { var part = parent.GetParentsInfo().Where(pp => pp.StudentID == stud.StudentID).FirstOrDefault(); ret.ParentsNo = !string.IsNullOrWhiteSpace(part.MomContactNo)?part.MomContactNo:part.DadContactNo; } if (DaySelected.Count > 0) { DaySelected.ForEach(dd => { ret.Day = dd.Cells[0].Value.ToString(); if (TimeSelected.Count > 0) { TimeSelected.ForEach(tt => { var _tt = tt.Cells[3].Value.ToString(); using (Maintenance maintain = new Maintenance()) { var TimeStartEnd = maintain.GetTime().Where(ttt => ttt.TimeCode == _tt).FirstOrDefault(); ret.TimeStart = TimeStartEnd.TimeStart.Value; ret.TImeEnd = TimeStartEnd.TimeEnd.Value; using (SMSNotification notify = new SMSNotification()) { string msgRet = ""; notify.Save(ret, ref msgRet); lblMessage.Text = msgRet; } } }); } else { SystemProperties.ShowMessage.MessageError("Select time first", "Time Error"); } }); } else { SystemProperties.ShowMessage.MessageError("Select day first", "Day Error"); } } }); } GetDayAndTime(); GetRoomSubjectMessage(); LoadStudent(); ObjEnable(false); SystemProperties.Cleared(this, false, true, true); dgDay.Enabled = dgTime.Enabled = dgStudentList.Enabled = false; txtRoomDesc.ReadOnly = true; txtSubjectDesc.ReadOnly = true; }