예제 #1
0
        private void schedulerControl_EditAppointmentFormShowing(object sender, AppointmentFormEventArgs e)
        {
            Appointment apt = e.Appointment;

            controller = new AppointmentFormController(schedulerControl1, apt);
            // Required to open the recurrence form via context menu.
            bool isNewApp = schedulerStorage1.Appointments.IsNewAppointment(apt);

            if (isNewApp)
            {
                e.Handled = true;
                return;
            }

            frmEventDlg fEvtDlg = null;
            bool IsRecur = false;
            bool IsExtraClass = false;
            e.Handled = true;

            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());
            IsExtraClass = apt.Subject.Contains("Extra Class");

            if (strRecurrenceText != "")
                IsRecur = true;

            int Option = -1;
            if (IsRecur)
            {
                if (!IsExtraClass)
                {
                    frmOpenEvents frmOpenEvt = new frmOpenEvents();
                    if (frmOpenEvt.ShowDialog() == DialogResult.OK)
                    {
                        Option = frmOpenEvt.Option;
                    }
                    else
                    {
                        e.Handled = true;
                        frmOpenEvt.Close();
                        frmOpenEvt.Dispose();
                        return;
                    }
                }

            }
            if (Option == 1)
            {
                //fEvtDlg=new frmEventDlg(intEventID, intCalID);
                //fEvtDlg.Mode="Edit";
                //fEvtDlg.EventID = intEventID;
                //fEvtDlg.LoadData();

                string module = string.Empty;
                int _uid;
                int _eventtypeindex = 0;
                Events objEvent = new Events();
                _uid = objEvent.GetEvent(intEventID, ref module, ref _eventtypeindex);

                if (module != "")
                {
                    if (module == "Class")
                    {
                        frmClassDlg frm = new frmClassDlg(_uid, _eventtypeindex, intCalID);
                        frm.Mode = "Edit";
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            LoadCalendar();
                            frm.Close();
                            frm.Dispose();
                        }
                    }
                    else if (module == "Program")
                    {
                        frmProgramDlg frm = new frmProgramDlg(_uid, _eventtypeindex, intCalID);
                        frm.Mode = "Edit";
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            LoadCalendar();
                            frm.Close();
                            frm.Dispose();
                        }
                    }
                }
                else
                {
                    fEvtDlg = new frmEventDlg();
                    fEvtDlg.Mode = "Edit";
                    fEvtDlg.EventID = intEventID;
                    fEvtDlg.LoadData();
                }
            }
            else
            {
                string module = string.Empty;
                int _uid;
                int _eventtypeindex = 0;
                Events objEvent = new Events();
                _uid = objEvent.GetEvent(intEventID, ref module, ref _eventtypeindex);
                if (IsExtraClass) _eventtypeindex = 4;

                if (module != "")
                {
                    if (module == "Class")
                    {
                        frmClassDlg frm = new frmClassDlg(_uid, _eventtypeindex);
                        frm.Mode = "Edit";
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            LoadCalendar();
                            frm.Close();
                            frm.Dispose();

                        }
                    }
                    else if (module == "Program")
                    {
                        frmProgramDlg frm = new frmProgramDlg(_uid, _eventtypeindex);
                        frm.Mode = "Edit";
                        if (frm.ShowDialog() == DialogResult.OK)
                        {
                            LoadCalendar();
                            frm.Close();
                            frm.Dispose();

                        }
                    }
                }
            }
            /*
            if (fEvtDlg != null)
            {
                if (fEvtDlg.ShowDialog() == DialogResult.OK)
                {
                    schedulerStorage1.Appointments.DataSource = FetchGridData();
                    e.Handled = true;
                }
                e.Handled = true;
                fEvtDlg.Close();
                fEvtDlg.Dispose();
            }*/
        }
예제 #2
0
        //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;
                }
            }
        }
예제 #3
0
        public void OpenEvent()
        {
            int row = 0;
            int intEventID = 0;
            bool IsRecur = false;

            row = gvwEvent.FocusedRowHandle;

            if (gvwEvent.FocusedRowHandle < 0)
            {
                Message.MsgInformation("No record exists.");
                return;
            }

            intEventID = Convert.ToInt32(gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, gcolEventID));
            int intCalID = Convert.ToInt32(gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, colCalendarEventID).ToString());
            //int CourseId = Common.ConvertToInteger(gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, gcolCourseId).ToString());
            //int ProgramID = Common.ConvertToInteger(gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, gcolProgramId).ToString());
            string strEventType = gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, gcolEventType).ToString();

            if (gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, gcolIsRecur).ToString() != "")
                IsRecur = true;

            int Option = -1;

            if (IsRecur)
            {
                if (strEventType != "Extra Class")
                {
                    frmOpenEvents frmOpenEvt = new frmOpenEvents();
                    if (frmOpenEvt.ShowDialog() == DialogResult.OK)
                    {
                        Option = frmOpenEvt.Option;
                    }
                    else
                    {
                        frmOpenEvt.Close();
                        frmOpenEvt.Dispose();
                        return;
                    }
                }
            }

            //frmEventDlg fEvtDlg = null;
            //Option '0' means a single occurence and '1' means the entire series
            if (Option == 1)
            {
                //fEvtDlg=new frmEventDlg(intEventID, intCalID);
                //fEvtDlg.Mode="Edit";
                //fEvtDlg.EventID = intEventID;
                //fEvtDlg.LoadData();

                string module = string.Empty;
                int _uid = 0;
                int _eventtypeindex = 0;
                Events objEvent = new Events();
                //Returns Course/Program ID
                _uid = objEvent.GetEvent(intEventID, ref module, ref _eventtypeindex);

                if (module != "")
                {
                    if (module == "Class")
                    {
                        frmClassDlg frm = new frmClassDlg(_uid, _eventtypeindex, intCalID);
                        frm.Mode = "Edit";
                       //if (frm.ShowDialog() == DialogResult.OK)
                        frm.ShowDialog();
                        {
                            LoadEvent();
                            frm.Close();
                            frm.Dispose();
                            frm = null;
                        }
                    }
                    else if (module == "Program")
                    {
                        frmProgramDlg frm = new frmProgramDlg(_uid, _eventtypeindex);
                        frm.Mode = "Edit";
                        //if (frm.ShowDialog() == DialogResult.OK)
                        frm.ShowDialog();
                        {
                            LoadEvent();
                            frm.Close();
                            frm.Dispose();
                            frm = null;
                        }
                    }
                }
                //				else
                //				{
                //					fEvtDlg=new frmEventDlg();
                //					fEvtDlg.Mode="Edit";
                //					fEvtDlg.EventID = intEventID;
                //					fEvtDlg.LoadData();
                //				}
            }
            /*else if(Option==-1 && strEventType!="Event")
            {
                //For Extra Classes and Test Events;
                fEvtDlg = new frmEventDlg(int.Parse(gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, gcolEventID).ToString()), int.Parse(gvwEvent.GetRowCellValue(gvwEvent.FocusedRowHandle, colCalendarEventID).ToString()));
                fEvtDlg.Mode = "Edit";
                fEvtDlg.CourseId = CourseId;

                Course _course = new Course();
                _course.CourseId = CourseId;
                _course.LoadData();
                fEvtDlg.AllowExtraClasses = _course.IsRecurring();
                if (fEvtDlg.ShowDialog() == DialogResult.OK)
                    LoadEvent();
                fEvtDlg.Close();
                fEvtDlg.Dispose();
                fEvtDlg = null;
            }*/
            else
            {
                string module = string.Empty;
                int _uid = 0;
                int _eventtypeindex = 0;
                Events objEvent = new Events();
                _uid = objEvent.GetEvent(intEventID, ref module, ref _eventtypeindex);
                if (strEventType == "Extra Class") _eventtypeindex = 4;

                if (module != "")
                {
                    if (module == "Class")
                    {
                        frmClassDlg frm = new frmClassDlg(_uid, _eventtypeindex);
                        frm.Mode = "Edit";
                     //   if (frm.ShowDialog() == DialogResult.OK)
                        frm.ShowDialog();
                        {
                            LoadEvent();
                            frm.Close();
                            frm.Dispose();
                            frm = null;
                        }
                    }
                    else if (module == "Program")
                    {
                        frmProgramDlg frm = new frmProgramDlg(_uid, _eventtypeindex);
                        frm.Mode = "Edit";
                     //   if (frm.ShowDialog() == DialogResult.OK)
                        frm.ShowDialog();
                        {
                            LoadEvent();
                            frm.Close();
                            frm.Dispose();
                            frm = null;
                        }
                    }
                }
                //				else
                //				{
                //					fEvtDlg=new frmEventDlg();
                //					fEvtDlg.Mode="Edit";
                //					fEvtDlg.EventID = intEventID;
                //					fEvtDlg.LoadData();
                //				}
            }
            /*
            if(fEvtDlg!=null)
            {
                if(fEvtDlg.ShowDialog()==DialogResult.OK)
                {
                    LoadEvent();
                }

                fEvtDlg.Close();
                fEvtDlg.Dispose();
                fEvtDlg=null;
            }
            */
            gvwEvent.FocusedRowHandle = row;
        }