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 llblTeacher2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { frmInstructorDlg fContDlg=new frmInstructorDlg(); fContDlg.Mode="Add"; if(fContDlg.ShowDialog()==DialogResult.OK) { Common.PopulateDropdown( cmbTeacher2, "Select " + "TeacherName = CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END From " + "Contact Where ContactType=1 and " + "ContactStatus=0 Order By LastName, FirstName "); cmbTeacher1.Tag = cmbTeacher1.Text; cmbTeacher1.Items.Clear(); foreach(string s in cmbTeacher2.Items) { cmbTeacher1.Items.Add(s); } cmbTeacher1.Text = cmbTeacher1.Tag.ToString(); } fContDlg.Close(); fContDlg.Dispose(); fContDlg=null; }
private void grdContact_DoubleClick(object sender, System.EventArgs e) { int intContact=0; int row=0; row=gvwContact.FocusedRowHandle; if(gvwContact.FocusedRowHandle<0) { Scheduler.BusinessLayer.Message.MsgInformation("No record exists."); return; } intContact = Convert.ToInt32(gvwContact.GetRowCellValue(gvwContact.FocusedRowHandle, gcolContactID)); if(Option=="Contact") { frmContactDlg fContactDlg = new frmContactDlg(); fContactDlg.ContactID = intContact; fContactDlg.Mode="Edit"; fContactDlg.LoadData(); if(fContactDlg.ShowDialog()==DialogResult.OK) { LoadContact(option); } fContactDlg.Close(); fContactDlg.Dispose(); fContactDlg=null; } else if(Option=="Instructor") { frmInstructorDlg fContactDlg = new frmInstructorDlg(); fContactDlg.ContactID = intContact; fContactDlg.Mode="Edit"; fContactDlg.LoadData(); if(fContactDlg.ShowDialog()==DialogResult.OK) { LoadContact(option); } fContactDlg.Close(); fContactDlg.Dispose(); fContactDlg=null; } else if(Option=="Client") { frmClientDlg fContactDlg = new frmClientDlg(); fContactDlg.ContactID = intContact; fContactDlg.Mode="Edit"; fContactDlg.LoadData(); if(fContactDlg.ShowDialog()==DialogResult.OK) { LoadContact(option); } fContactDlg.Close(); fContactDlg.Dispose(); fContactDlg=null; } gvwContact.FocusedRowHandle=row; }
private void OpenInstructor(object sender) { ComboBox cbx = (ComboBox)sender; frmInstructorDlg fContDlg=new frmInstructorDlg(); fContDlg.Mode="Add"; if(fContDlg.ShowDialog()==DialogResult.OK) { Common.PopulateDropdown( cbx, "Select " + "CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END as TeacherName From " + "Contact Where ContactType=1 " + " Order By LastName, FirstName "); cbx.SelectedIndex = cbx.Items.Count-1; string query = "Select " + "CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END as TeacherName From " + "Contact Where ContactType=1 and " + "ContactStatus=1 Order By LastName, FirstName "; IDataReader reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["TeacherName"] != DBNull.Value && reader["TeacherName"].ToString() != cbx.Text) { cbx.Items.Remove(reader["TeacherName"].ToString()); ; } } //cmbTeacher2_I.Tag = cmbTeacher2_I.Text; /*cmbTeacher2_I.Items.Clear(); foreach(string s in cmbTeacher1_I.Items) { cmbTeacher2_I.Items.Add(s); } cmbTeacher2_I.Text = cmbTeacher2_I.Tag.ToString(); */ } fContDlg.Close(); fContDlg.Dispose(); fContDlg=null; }
private void llblTeacher2_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { frmInstructorDlg fContDlg=new frmInstructorDlg(); fContDlg.Mode="Add"; if(fContDlg.ShowDialog()==DialogResult.OK) { Common.PopulateDropdown( cmbTeacher2, "Select " + "CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END AS TeacherName From " + "Contact Where ContactType=1 " + " Order By LastName, FirstName "); cmbTeacher2.SelectedIndex = cmbTeacher2.Items.Count - 1; string query = "Select " + "CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END AS TeacherName From " + "Contact Where ContactType=1 and " + "ContactStatus=1 Order By LastName, FirstName "; IDataReader reader = DAC.SelectStatement(query); while (reader.Read()) { if (reader["TeacherName"] != DBNull.Value && reader["TeacherName"].ToString() != cmbTeacher2.Text) { cmbTeacher2.Items.Remove(reader["TeacherName"].ToString()); } } cmbTeacher1.Tag = cmbTeacher1.Text; cmbTeacher1.Items.Clear(); foreach(string s in cmbTeacher2.Items) { cmbTeacher1.Items.Add(s); } cmbTeacher1.Text = cmbTeacher1.Tag.ToString(); } fContDlg.Close(); fContDlg.Dispose(); fContDlg=null; }
private void OpenInstructor(object sender) { ComboBox cbx = (ComboBox)sender; frmInstructorDlg fContDlg=new frmInstructorDlg(); fContDlg.Mode="Add"; if(fContDlg.ShowDialog()==DialogResult.OK) { Common.PopulateDropdown( cbx, "Select " + "TeacherName = CASE " + "WHEN NickName IS NULL THEN LastName + ', ' + FirstName " + "WHEN NickName = '' THEN LastName + ', ' + FirstName " + "ELSE NickName " + "END From " + "Contact Where ContactType=1 and " + "ContactStatus=0 Order By LastName, FirstName "); cbx.SelectedIndex = cbx.Items.Count-1; //cmbTeacher2_I.Tag = cmbTeacher2_I.Text; /*cmbTeacher2_I.Items.Clear(); foreach(string s in cmbTeacher1_I.Items) { cmbTeacher2_I.Items.Add(s); } cmbTeacher2_I.Text = cmbTeacher2_I.Tag.ToString(); */ } fContDlg.Close(); fContDlg.Dispose(); fContDlg=null; }