private void NewDialog() { if (strMenuOption == "User...") { frmUserDlg fUserDlg = new frmUserDlg(); fUserDlg.Mode = "Add"; fUserDlg.ShowDialog(); fUserDlg.Close(); fUserDlg.Dispose(); fUserDlg = null; ReloadUsersList(); } else if (strMenuOption == "Contact...") { frmContactDlg fContDlg = new frmContactDlg(); fContDlg.Mode = "Add"; fContDlg.ShowDialog(); fContDlg.Close(); fContDlg.Dispose(); fContDlg = null; ReloadContactsGrid(); } else if (strMenuOption == "Instructor...") { frmInstructorDlg fInstructorDlg = new frmInstructorDlg(); fInstructorDlg.Mode = "Add"; fInstructorDlg.ShowDialog(); fInstructorDlg.Close(); fInstructorDlg.Dispose(); fInstructorDlg = null; ReloadInstructorsList(); } else if (strMenuOption == "Client...") { frmClientDlg fClientDlg = new frmClientDlg(); fClientDlg.Mode = "Add"; fClientDlg.LoadData(); fClientDlg.ShowDialog(); fClientDlg.Close(); fClientDlg.Dispose(); fClientDlg = null; ReloadClientsList(); } else if (strMenuOption == "Department...") { frmDepartmentDlg fDeptDlg = new frmDepartmentDlg(); fDeptDlg.Mode = "Add"; fDeptDlg.LoadData(); fDeptDlg.ShowDialog(); fDeptDlg.Close(); fDeptDlg.Dispose(); fDeptDlg = null; ReloadDepartmentsList(); } else if (strMenuOption == "Class...") { frmClassDlg fClassDlg = new frmClassDlg(); fClassDlg.Mode = "Add"; fClassDlg.LoadData(); fClassDlg.ShowDialog(); fClassDlg.Close(); fClassDlg.Dispose(); fClassDlg = null; ReloadClassesList(); } else if (strMenuOption == "Program...") { frmProgramDlg fProgDlg = new frmProgramDlg(); fProgDlg.Mode = "Add"; fProgDlg.LoadData(); fProgDlg.ShowDialog(); fProgDlg.Close(); fProgDlg.Dispose(); fProgDlg = null; ReloadProgramList(); } else if (strMenuOption == "Event..." || strMenuOption == "Calendar...") { //MessageBox.Show(strMenuOption); MessageBox.Show( "New events can't be created from this window, please use program or class properties to manage events !", "Adding new event", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (strMenuOption == "Calendar...") { DateTime dtSelect = fCalendar.schedulerControl1.SelectedInterval.Start.Date; TimeSpan StartTS = fCalendar.schedulerControl1.SelectedInterval.Start.TimeOfDay; string strStartTime = StartTS.ToString(); strStartTime = strStartTime.Substring(0, 5); TimeSpan EndTS = StartTS.Add(new TimeSpan(0, 0, 30, 0, 0)); string strEndTime = EndTS.ToString(); strEndTime = strEndTime.Substring(0, 5); frmEventDlg fEvtDlg = null; if (strCalendar == "Day") { fEvtDlg = new frmEventDlg(dtSelect, strStartTime, strEndTime, "Calendar"); } else { fEvtDlg = new frmEventDlg(dtSelect, "", "", "Calendar"); } fEvtDlg.Mode = "Add"; fEvtDlg.ShowDialog(); fEvtDlg.Close(); fEvtDlg.Dispose(); fEvtDlg = null; if (fCalendar != null) { fCalendar.LoadCalendar(); } } }
//TO DO: Remove Stored Procs. private void Duplicate() { if (strMenuOption == "User...") { int Row = fUser.gvwUser.FocusedRowHandle; if (Row >= 0) { int intUserID = Convert.ToInt32(fUser.gvwUser.GetRowCellValue(fUser.gvwUser.FocusedRowHandle, fUser.gcolUserID).ToString()); int intContactID = Convert.ToInt32(fUser.gvwUser.GetRowCellValue(fUser.gvwUser.FocusedRowHandle, fUser.gcolContactID).ToString()); //intContactID = Contact.CloneData(intContactID); //intUserID = User.Clone(intUserID); //Changing the mode to 'AddClone' and passing the same IDs for loading data frmUserDlg fUserDlg = new frmUserDlg(); fUserDlg.Mode = "AddClone"; fUserDlg.UserID = intUserID; fUserDlg.ContactID = intContactID; fUserDlg.LoadData(); fUserDlg.ShowDialog(); fUserDlg.Close(); fUserDlg.Dispose(); fUserDlg = null; ReloadUsersList(); } } else if (strMenuOption == "Contact...") { int Row = fContact.gvwContact.FocusedRowHandle; if (Row >= 0) { int intID = Convert.ToInt32( fContact.gvwContact.GetRowCellValue(fContact.gvwContact.FocusedRowHandle, fContact.gcolContactID).ToString()); //intID = Contact.CloneData(intID); frmContactDlg fContDlg = new frmContactDlg(); fContDlg.Mode = "AddClone"; fContDlg.ContactID = intID; fContDlg.LoadData(); fContDlg.ShowDialog(); fContDlg.Close(); fContDlg.Dispose(); fContDlg = null; ReloadContactsGrid(); } } else if (strMenuOption == "Instructor...") { int Row = fContact.gvwContact.FocusedRowHandle; if (Row >= 0) { int intID = Convert.ToInt32( fContact.gvwContact.GetRowCellValue(fContact.gvwContact.FocusedRowHandle, fContact.gcolContactID).ToString()); //intID = Contact.CloneData(intID); frmInstructorDlg fInstructorDlg = new frmInstructorDlg(); fInstructorDlg.Mode = "AddClone"; fInstructorDlg.ContactID = intID; fInstructorDlg.LoadData(); fInstructorDlg.ShowDialog(); fInstructorDlg.Close(); fInstructorDlg.Dispose(); fInstructorDlg = null; ReloadInstructorsList(); } } else if (strMenuOption == "Client...") { int Row = fContact.gvwContact.FocusedRowHandle; if (Row >= 0) { int intID = Convert.ToInt32( fContact.gvwContact.GetRowCellValue(fContact.gvwContact.FocusedRowHandle, fContact.gcolContactID).ToString()); //intID = Contact.CloneData(intID); frmClientDlg fClientDlg = new frmClientDlg(); fClientDlg.Mode = "AddClone"; fClientDlg.ContactID = intID; fClientDlg.LoadData(); fClientDlg.ShowDialog(); fClientDlg.Close(); fClientDlg.Dispose(); fClientDlg = null; ReloadClientsList(); } } else if (strMenuOption == "Department...") { int Row = fDept.gvwDept.FocusedRowHandle; if (Row >= 0) { int intDeptID = Convert.ToInt32(fDept.gvwDept.GetRowCellValue(fDept.gvwDept.FocusedRowHandle, fDept.gColDeptID).ToString()); int intContactID = Convert.ToInt32(fDept.gvwDept.GetRowCellValue(fDept.gvwDept.FocusedRowHandle, fDept.gColContactID).ToString()); //int[] array = new int[2]; //array = Department.CloneData(intDeptID); //intDeptID = array[0]; //intContactID = array[1]; frmDepartmentDlg fDeptDlg = new frmDepartmentDlg(); fDeptDlg.Mode = "AddClone"; fDeptDlg.DeptID = intDeptID; fDeptDlg.ContactID = intContactID; fDeptDlg.LoadData(); fDeptDlg.ShowDialog(); fDeptDlg.Close(); fDeptDlg.Dispose(); fDeptDlg = null; ReloadDepartmentsList(); } } else if (strMenuOption == "Program...") { int Row = fProgram.gvwProgram.FocusedRowHandle; if (Row >= 0) { int intProgID = Convert.ToInt32( fProgram.gvwProgram.GetRowCellValue(fProgram.gvwProgram.FocusedRowHandle, fProgram.gcolProgID).ToString()); //intProgID = Program.CloneData(intProgID); frmProgramDlg fProgDlg = new frmProgramDlg(intProgID); fProgDlg.Mode = "AddClone"; fProgDlg.LoadData(); fProgDlg.ShowDialog(); fProgDlg.Close(); fProgDlg.Dispose(); fProgDlg = null; ReloadProgramList(); } } else if (strMenuOption == "Class...") { int Row = fCourse.gvwCourse.FocusedRowHandle; if (Row >= 0) { int intID = Convert.ToInt32( fCourse.gvwCourse.GetRowCellValue(fCourse.gvwCourse.FocusedRowHandle, fCourse.gcolCourseId).ToString()); //intID = Course.CloneData(intID); frmClassDlg fClassDlg = new frmClassDlg(); fClassDlg.Mode = "AddClone"; fClassDlg.CourseId = intID; fClassDlg.LoadData(); fClassDlg.ShowDialog(); fClassDlg.Close(); fClassDlg.Dispose(); fClassDlg = null; ReloadClassesList(); } } else if (strMenuOption == "Event...") { if (fEvt != null) { int Row = fEvt.gvwEvent.FocusedRowHandle; if (Row >= 0) { bool IsRecur = false; int intID = Convert.ToInt32(fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.gcolEventID).ToString()); int intCalID = Convert.ToInt32(fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.colCalendarEventID).ToString()); if (fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.gcolIsRecur).ToString() != "") IsRecur = true; int Option = -1; if (IsRecur) { frmOpenEvents frmOpenEvt = new frmOpenEvents(); if (frmOpenEvt.ShowDialog() == DialogResult.OK) { Option = frmOpenEvt.Option; } else { frmOpenEvt.Close(); frmOpenEvt.Dispose(); frmOpenEvt = null; return; } } //this part was copy-pasted from frmCalendar.cs we exit if no module linked to the event string module = string.Empty; int _uid = 0; int _eventtypeindex = 0; Events objEvent = new Events(); _uid = objEvent.GetEvent(intID, ref module, ref _eventtypeindex); if (module == "") { return; } //--- //frmEventDlg fEvtDlg = null; if (Option == 1) { if (module == "Class") { frmClassDlg frm = new frmClassDlg(_uid, _eventtypeindex, intCalID); frm.Mode = "AddClone"; if (frm.ShowDialog() == DialogResult.OK) { frm.Close(); frm.Dispose(); frm = null; } } else if (module == "Program") { frmProgramDlg frm = new frmProgramDlg(_uid, _eventtypeindex, intCalID); frm.Mode = "AddClone"; if (frm.ShowDialog() == DialogResult.OK) { frm.Close(); frm.Dispose(); frm = null; } } /* fEvtDlg = new frmEventDlg(intID, intCalID); fEvtDlg.Mode = "Edit"; fEvtDlg.EventID = intID; fEvtDlg.LoadData(); */ } else { if (module == "Class") { frmClassDlg frm = new frmClassDlg(_uid, _eventtypeindex); frm.Mode = "AddClone"; if (frm.ShowDialog() == DialogResult.OK) { frm.Close(); frm.Dispose(); frm = null; } } else if (module == "Program") { frmProgramDlg frm = new frmProgramDlg(_uid, _eventtypeindex); frm.Mode = "AddClone"; if (frm.ShowDialog() == DialogResult.OK) { frm.Close(); frm.Dispose(); frm = null; } } /* fEvtDlg = new frmEventDlg(); fEvtDlg.Mode = "Edit"; fEvtDlg.EventID = intID; fEvtDlg.LoadData(); */ } /* if (fEvtDlg.ShowDialog() == DialogResult.OK) { fEvt.LoadEvent(); } fEvtDlg.Close(); fEvtDlg.Dispose(); fEvtDlg = null; fEvt.gvwEvent.FocusedRowHandle = Row; */ } }/* else { }*/ } else if (strMenuOption == "Calendar...") { if (fCalendar.schedulerControl1.SelectedAppointments.Count > 0) { Appointment apt = fCalendar.schedulerControl1.SelectedAppointments[0]; bool IsRecur = false; controller = new AppointmentFormController(fCalendar.schedulerControl1, apt); int intCalID = Convert.ToInt32(controller.LabelId.ToString()); int intEventID = Common.GetID("select EventID from CalendarEvent where CalendarEventID=" + intCalID.ToString()); string strRecurrenceText = Common.GetString("select RecurrenceText from Event where EventID=" + intEventID.ToString()); if (strRecurrenceText != "") IsRecur = true; int Option = -1; if (IsRecur) { frmOpenEvents frmOpenEvt = new frmOpenEvents(); if (frmOpenEvt.ShowDialog() == DialogResult.OK) { Option = frmOpenEvt.Option; } else { frmOpenEvt.Close(); frmOpenEvt.Dispose(); frmOpenEvt = null; return; } } frmEventDlg fEvtDlg = null; if (Option == 1) { fEvtDlg = new frmEventDlg(intEventID, intCalID); fEvtDlg.Mode = "Edit"; fEvtDlg.EventID = intEventID; fEvtDlg.LoadData(); } else { fEvtDlg = new frmEventDlg(); fEvtDlg.Mode = "Edit"; fEvtDlg.EventID = intEventID; fEvtDlg.LoadData(); } if (fEvtDlg.ShowDialog() == DialogResult.OK) { fCalendar.LoadCalendar(); } fEvtDlg.Close(); fEvtDlg.Dispose(); fEvtDlg = null; } } }
private void grdCourse_DoubleClick(object sender, System.EventArgs e) { int row=0; int intCourse= 0; int intEventId = 0; int intIndex = 0; frmClassDlg fClassDlg = null; row=gvwCourse.FocusedRowHandle; if(gvwCourse.FocusedRowHandle<0) { Scheduler.BusinessLayer.Message.MsgInformation("No record exists."); return; } intCourse = Convert.ToInt32(gvwCourse.GetRowCellValue(gvwCourse.FocusedRowHandle, gcolCourseId)); intEventId = Convert.ToInt32(gvwCourse.GetRowCellValue(gvwCourse.FocusedRowHandle, gcolEventId)); //Two possibilities exist here. Either a class event exists or it doesn't. if (intEventId != 0) { intIndex = 3; fClassDlg = new frmClassDlg(intCourse, intIndex); } else { fClassDlg = new frmClassDlg(intCourse); fClassDlg.Mode = "Edit"; fClassDlg.LoadData(); } if(fClassDlg.ShowDialog()==DialogResult.OK) LoadCourse(); fClassDlg.Close(); fClassDlg.Dispose(); fClassDlg=null; gvwCourse.FocusedRowHandle=row; }