private void btnOK_Click(object sender, System.EventArgs e)
        {
            string strMess="";

            Events evt = new Events();
            evt.EventID = EventID;

            strMess = evt.CheckClassEvent();
            if(strMess=="") strMess = evt.CheckProgramEvent();

            if(strMess!="")
            {
                BusinessLayer.Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                Close();
                this.DialogResult=DialogResult.Cancel;
                return;
            }
            if (Convert.ToBoolean(rdDeleteChoice.EditValue))
            {
                evt.CalendarEventID = CalendarEventID;
                evt.DeleteData(false);
                if (!evt.CheckEventExists(EventID))
                {
                    string module = string.Empty;
                    int _uid = 0;
                    int _eventtypeindex = 0;
                    Events objEvent = new Events();
                    //Returns Course/Program ID
                    _uid = objEvent.GetEvent(EventID, ref module, ref _eventtypeindex);
                    objEvent.EventID = 0;
                    objEvent.UpdateClassEvent(_uid, "EventId");
                }
            }
            else
            {
                evt.DeleteData(true);
                evt.DeleteCalendarEvent();
                string module = string.Empty;
                int _uid = 0;
                int _eventtypeindex = 0;
                Events objEvent = new Events();
                //Returns Course/Program ID
                _uid = objEvent.GetEvent(EventID, ref module, ref _eventtypeindex);
                objEvent.EventID = 0;
                objEvent.UpdateClassEvent(_uid, "EventId");
            }

            Close();
            this.DialogResult=DialogResult.OK;
        }
Beispiel #2
0
 /// <summary>
 /// Loads Events with filters
 /// </summary>
 /// <param name="dtStart">Start date</param>
 /// <param name="dtEnd">End Date</param>
 /// <param name="client">Client name</param>
 /// <param name="instructor">Instructor name</param>
 /// <param name="program">Programm name</param>
 /// <param name="course">Course Name</param>
 /// <returns></returns>
 public DataTable FetchGridData(DateTime dtStart, DateTime dtEnd, string client, string instructor, string program, string course)
 {
     Events evt = new Events();
     return evt.LoadCalendarDataNew(dtStart, dtEnd, client, instructor, program, course);
     //return evt.LoadCalendarData(dtStart, dtEnd, client, instructor, program, course);
 }
Beispiel #3
0
        private void btnSave_Click(object sender, System.EventArgs e)
        {
            string sConflictingEvent="";
            if(!IsValid()) return;

            //check real teacher first
            string strOverLapMess="";

            strOverLapMess = strOverLapMess.Trim();

            //AutoSave=false;
            //GenerateEvent(IsRecurrenceFlag);
            //AutoSave=true;

            if(cmbTeacher2.Text.Trim()!="")
            {
                bool Ok=false;
                if(dtblDates==null)
                {
                    Ok = IsCheckOverlapTime(ref sConflictingEvent, "Real", ref strOverLapMess);
                }
                else
                {
                    foreach(DataRow dr in dtblDates.Rows)
                    {
                        Ok = IsCheckOverlapTime(ref sConflictingEvent, "Real", dr[0].ToString(), dr[1].ToString(), ref strOverLapMess);
                        if(Ok) break;
                    }
                }
                if(Ok)
                {
                    DialogResult dlg =
                        BusinessLayer.Message.MsgConfirmation(
                        "<" + cmbTeacher2.Text + "> is already scheduled in <" +
                        sConflictingEvent + ">" + strOverLapMess +
                        "\nDo you still wish to save this event?");
                    if(dlg==DialogResult.No)
                    {
                        return;
                    }
                }
            }
            else
            {
                //if real instructor is blank then check scheduled teacher
                bool Ok=false;
                if(dtblDates==null)
                    Ok = IsCheckOverlapTime(ref sConflictingEvent, "Scheduled", ref strOverLapMess);
                else
                    foreach(DataRow dr in dtblDates.Rows)
                    {
                        Ok = IsCheckOverlapTime(ref sConflictingEvent, "Scheduled", dr[0].ToString(), dr[1].ToString(), ref strOverLapMess);
                        if(Ok) break;
                    }

                if(Ok)
                {
                    DialogResult dlg =
                        BusinessLayer.Message.MsgConfirmation(
                        "<" + cmbTeacher1.Text + "> is already scheduled in <" +
                        sConflictingEvent + ">" + strOverLapMess +
                        "\nDo you still wish to save this event?");
                    if(dlg==DialogResult.No)
                        return;
                }
            }

            // Saving Logic
            /* Differentiate on the basis of current mode. For Edit mode, the event will
             * be updated after ensuring no conflicts arise as a result of the changes.
             * For Add, the event will be added after ensuring no conflicts arise.
             */
            Boolean boolSuccess = false;
            if (_mode == "Edit")
            {
                //TODO:Differentiate between Class and Program
                if(objEvent.CalendarEventID > 0)
                    if (!objEvent.IsConflicting(dtStart.Value, dtEnd.Value))
                    {
                        SaveCalendarData(dtStart.Value, dtEnd.Value);

                        if (_eventtype == EventType.Initial || _eventtype == EventType.MidTerm || _eventtype == EventType.Final)
                        {
                            objEvent.RepeatRule = "";
                            objEvent.NegativeException = "";
                            objEvent.RecurrenceText = "";
                            objEvent.Description = txtDescription.Text;
                            objEvent.EventStatus = cmbEventStatus.SelectedIndex;

                            boolSuccess = objEvent.UpdateData();

                            if (!boolSuccess)
                            {
                                Scheduler.BusinessLayer.Message.ShowException("Updating Event record.", objEvent.Message);
                                return;
                            }
                        }
                    }
            }
            else if (_mode == "Add")
            {
                //Create a new 'Event' object
                objEvent = new Events();

                if (_eventtype == EventType.Extra)
                {
                    //Add Extra Class - add record to 'CalendarEvent' table ONLY
                    SaveCalendarEvent(dtStart.Value, dtEnd.Value);
                }
                else if (_eventtype == EventType.Final || _eventtype == EventType.Initial || _eventtype == EventType.MidTerm)
                {
                    //Add Test Event - add record to 'Event' AND 'CalendarEvent' tables AND update 'Course' table
                    string strField = "";
                    if (intClassID != 0 || intProgramID != 0)
                    {
                        switch (_eventtype)
                        {
                            default: case EventType.Initial: strField = "TestInitialEventID"; break;
                            case EventType.MidTerm: strField = "TestMidtermEventID"; break;
                            case EventType.Final: strField = "TestFinalEventID"; break;
                        }

                        SaveData();
                        SaveCalendarEvent(dtStart.Value, dtEnd.Value);
                        if (intClassID != 0)
                            objEvent.UpdateClassEvent(intClassID, strField);
                        else if (intProgramID != 0)
                            objEvent.UpdateProgramEvent(intProgramID, strField);
                    }
                }
            }

            /*
            if(boolSaveSeries)
            {
                SaveData();
                if(_mode=="Edit") objEvent.DeleteCalendarEvent();
                //GenerateEvent(IsRecurrenceFlag);
            }
            else
                SaveCalendarData(dtStart.Value, dtEnd.Value);

            if(!OpenFromClsProg)
            {
                //Updating the Test Event
                string strField="";
                if(intClassID!=0)
                {
                    if(cmbEvent.SelectedIndex==0) strField="EventID";
                    else if(cmbEvent.SelectedIndex==1) strField="TestInitialEventID";
                    else if(cmbEvent.SelectedIndex==2) strField="TestMidtermEventID";
                    else if(cmbEvent.SelectedIndex==3) strField="TestFinalEventID";

                    objEvent.UpdateTestEvent("Class", strField, objEvent.EventID, intClassID);
                }
                else if(intProgramID!=0)
                {
                    if(cmbEvent.SelectedIndex==0) strField="TestInitialEventID";
                    else if(cmbEvent.SelectedIndex==1) strField="TestMidtermEventID";
                    else if(cmbEvent.SelectedIndex==2) strField="TestFinalEventID";

                    objEvent.UpdateTestEvent("Program", strField, objEvent.EventID, intProgramID);
                }
                else
                {
                    objEvent.RemoveTestEvent(objEvent.EventID, intClassID);
                }
            }
            */
            this.DialogResult = DialogResult.OK;
        }
Beispiel #4
0
        public void LoadData()
        {
            if(_mode=="Edit")
            {
                DataTable dtbl=null;

                this.Text = "Editing Event...";

                objEvent=new Scheduler.BusinessLayer.Events();
                objEvent.EventID = _eventid;

                if(_calendareventid>0)
                    objEvent.CalendarEventID=_calendareventid;

                dtbl = objEvent.LoadData();

                string strClient="", strDept="", strClass="", strProgram="";

                foreach(DataRow dr in dtbl.Rows)
                {
                    if(dr["Client"]!=System.DBNull.Value) strClient = dr["Client"].ToString();
                    if(dr["Department"]!=System.DBNull.Value) strDept = dr["Department"].ToString();
                    if(dr["Program"]!=System.DBNull.Value) strProgram = dr["Program"].ToString();
                    if(dr["Class"]!=System.DBNull.Value) strClass = dr["Class"].ToString();

                    if(dr["ProgramID"]!=System.DBNull.Value) intProgramID = Convert.ToInt32(dr["ProgramID"].ToString());
                    if(dr["CourseID"]!=System.DBNull.Value) intClassID = Convert.ToInt32(dr["CourseID"].ToString());

                    cmbClient.Text = strClient;
                    if(strClient.Trim()!="")
                    {
                        intClientID = Common.GetCompanyID(
                            "Select ContactID From Contact " +
                            "Where (CompanyName =@CompanyName OR NickName=@CompanyName)", cmbClient.Text
                            );

                        if(intClientID!=0)
                        {
                            cmbDept.Text = strDept;

                            intDepartmentID = Common.GetCompanyID(
                                "Select D.DepartmentID from Department D, Contact C " +
                                "Where D.ContactID=C.ContactID and (C.CompanyName= @CompanyName OR NickName=@CompanyName)", cmbDept.Text
                                );
                        }
                        if(intDepartmentID!=0)
                        {
                            cmbProgram.Text = strProgram;
                            intProgramID = Common.GetCompanyID(
                                "Select ProgramID From Program " +
                                "Where ([Name]= @CompanyName OR NickName=@CompanyName)", cmbProgram.Text
                                );
                        }
                        if(intProgramID!=0)
                        {
                            cmbClass.Text = strClass;
                            intClassID = Common.GetCompanyID(
                                "Select CourseID From Course " +
                                "Where ([Name]= @CompanyName OR NickName=@CompanyName) and ProgramID=" + intProgramID.ToString(), cmbClass.Text
                                );
                        }

                        if(dr["TestEvent"]!=System.DBNull.Value)
                        {
                            cmbEvent.Text = dr["TestEvent"].ToString();
                            cmbEvent.Tag = cmbEvent.SelectedIndex.ToString();
                        }
                    }

                    RepeatRule= dr["RepeatRule"].ToString();
                    NegativeException = dr["NegetiveException"].ToString();

                    txtName.Text = dr["Name"].ToString();
                    txtPhonetic.Text = dr["NamePhonetic"].ToString();
                    txtRomaji.Text = dr["NameRomaji"].ToString();

                    if (dr["EventType"] != System.DBNull.Value)
                    {
                        cmbEventType.SelectedIndex = cmbEventType.Items.IndexOf(dr["EventType"].ToString());

                        switch (dr["EventType"].ToString())
                        {
                            case "Extra Class": _eventtype = EventType.Extra; break;
                            case "Test Initial": _eventtype = EventType.Initial; break;
                            case "Test Midterm": _eventtype = EventType.MidTerm; break;
                            case "Test Final": _eventtype = EventType.Final; break;
                        }
                    }
                    else
                        SetDefaultEventType();
                        //cmbEventType.SelectedIndex = -1;

                    txtLocation.Text = dr["Location"].ToString();
                    cmbBlock.Text = dr["BlockCode"].ToString();
                    txtRoomNo.Text = dr["RoomNumber"].ToString();
                    txtDescription.Text = dr["Description"].ToString();
                    txtNote.Text = dr["Note"].ToString();

                    if(dr["ExceptionReason"]!=System.DBNull.Value)
                        cmbExceptionReason.Text = dr["ExceptionReason"].ToString();

                    cmbEventStatus.SelectedIndex = Convert.ToInt16(dr["EventStatus"].ToString());
                    cmbTeacher1.Text = dr["ScheduledTeacher"].ToString();
                    cmbTeacher2.Text = dr["RealTeacher"].ToString();
                    txtChangeReason.Text = dr["ChangeReason"].ToString();

                    if(dr["IsHoliday"]==System.DBNull.Value)
                        chkIsHoliday.Checked=false;
                    else
                        chkIsHoliday.Checked = (Convert.ToInt16(dr["IsHoliday"])>0);

                    XMLData = dr["RepeatRule"].ToString();

                    if(dr["RecurrenceText"]!=System.DBNull.Value)
                        if(dr["RecurrenceText"].ToString()!="")
                            IsRecurrenceFlag = 1;

                    dtStart.Value = Convert.ToDateTime(dr["StartDateTime"].ToString());
                    dtEnd.Value = Convert.ToDateTime(dr["EndDateTime"].ToString());

                    StartTime = dtStart.Value.ToString("HH:mm");
                    EndTime = dtEnd.Value.ToString("HH:mm");
                    try
                    {
                        SetTime(cmbStartTime, Convert.ToDateTime(StartTime).ToString("HH:mm"));
                        SetTime(cmbEndTime, Convert.ToDateTime(EndTime).ToString("HH:mm"));
                    }
                    catch{}

                    dtDateComplete.Value = Convert.ToDateTime(dr["DateCompleted"].ToString());

                    StartDate = dtStart.Value.ToShortDateString() + " " + cmbStartTime.Text;
                    EndDate = dtEnd.Value.ToShortDateString() + " " + cmbEndTime.Text;

                    break;
                }

                if (dtbl.Rows.Count <= 0)
                {
                    _mode = "Add";
                    _eventid = 0;
                    dtDateComplete.Value = DateTime.Now;
                    dtStart.Value = DateTime.Now;
                    dtEnd.Value = DateTime.Now;
                    if (File.Exists(strAppPath))
                        File.Delete(strAppPath);

                    this.Text = "Adding Event...";
                    //GenerateTimeCombo();
                    cmbEventStatus.SelectedIndex = 0;
                    SetDefaultEventType();
                    //cmbEventType.SelectedIndex = -1;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Saves data to the 'Event' Table
        /// </summary>
        private void SaveData()
        {
            bool boolSuccess;
            objEvent=null;

            /*
            if(File.Exists(strAppPath))
            {
                StreamReader re = File.OpenText(strAppPath);
                XMLData = re.ReadToEnd();
                re.Close();
                re=null;
            }
            else
            {
                XMLData="";
                IsRecurrenceFlag=0;
            }*/

            objEvent=new Scheduler.BusinessLayer.Events();
            objEvent.EventID=0;
            //objEvent.RepeatRule = XMLData;
            objEvent.RepeatRule = "";
            objEvent.NegativeException = "";
            objEvent.RecurrenceText = "";
            objEvent.Description = txtDescription.Text;
            objEvent.EventStatus = cmbEventStatus.SelectedIndex;

            /*
            if(IsRecurrenceFlag>0)
                objEvent.RecurrenceText = lblRecurrenceText.Text;
            else
                objEvent.RecurrenceText = "";
            */

            if(objEvent.Exists())
            {
                Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Name not allowed");
                txtName.Focus();
                return;
            }

            boolSuccess = objEvent.InsertData();
            _eventid = objEvent.EventID;

            if(!boolSuccess)
            {
                Scheduler.BusinessLayer.Message.ShowException("Inserting Event record.", objEvent.Message);
                return;
            }

            //this.DialogResult = DialogResult.OK;
            //Close();
        }
Beispiel #6
0
        /*
        private void GenerateEvent(int IsRecur)
        {
            DateTime StartDate = dtStart.Value;
            DateTime EndDate = dtEnd.Value;

            if(IsRecur>0)
            {
                if(ReccType=="Daily")
                {
                    if(Pattern1!="")
                    {
                        GenerateDataForDaily("EveryDay");
                    }
                    else if(Pattern2!="")
                    {
                        GenerateDataForDaily("EveryWeekDay");
                    }
                }
                else if(ReccType=="Weekly")
                {
                    if(Pattern1!="")
                    {
                        GenerateDataForWeekly();
                    }
                }
                else if(ReccType=="Monthly")
                {
                    if(Pattern1!="")
                    {
                        GenerateDataForMonthly();
                    }
                }
                else if(ReccType=="Yearly")
                {
                    if(Pattern1!="")
                    {
                        GenerateDataForYearly();
                    }
                }
            }
            else
            {
                //No Recurrence....
                SaveCalendarEvent(StartDate, EndDate);
            }

        }

        private void GenerateDataForDaily(string option)
        {
            int NoOfRecords=0;
            DateTime StartDate=Convert.ToDateTime(null);
            StartDate = dtStart.Value;

            if(NoEntries=="")
            {
                TimeSpan ts = dtEnd.Value - StartDate;
                NoOfRecords = ts.Days;
                NoOfRecords++;
            }
            else
            {
                NoOfRecords = Convert.ToInt16(NoEntries);
                if(option=="EveryWeekDay")
                {
                    NoOfRecords = NoOfRecords*7;
                }
            }

            if(option=="EveryDay")
            {
                while(NoOfRecords>0)
                {
                    //MessageBox.Show(StartDate.ToString());
                    SaveCalendarEvent(StartDate, StartDate);
                    StartDate = StartDate.AddDays(1);
                    NoOfRecords--;
                }
            }
            else if(option=="EveryWeekDay")
            {
                bool boolOk=false;
                while(NoOfRecords>0)
                {
                    if((Pattern2=="Monday") && (StartDate.DayOfWeek==DayOfWeek.Monday)) boolOk=true;
                    else if((Pattern2=="Tuesday") && (StartDate.DayOfWeek==DayOfWeek.Tuesday)) boolOk=true;
                    else if((Pattern2=="Wednesday") && (StartDate.DayOfWeek==DayOfWeek.Wednesday)) boolOk=true;
                    else if((Pattern2=="Thursday") && (StartDate.DayOfWeek==DayOfWeek.Thursday)) boolOk=true;
                    else if((Pattern2=="Friday") && (StartDate.DayOfWeek==DayOfWeek.Friday)) boolOk=true;
                    else if((Pattern2=="Saturday") && (StartDate.DayOfWeek==DayOfWeek.Saturday)) boolOk=true;
                    else if((Pattern2=="Sunday") && (StartDate.DayOfWeek==DayOfWeek.Sunday)) boolOk=true;

                    if(boolOk)
                    {
                        //MessageBox.Show(StartDate.ToString());
                        SaveCalendarEvent(StartDate, StartDate);
                    }
                    StartDate = StartDate.AddDays(1);
                    NoOfRecords--;

                    boolOk=false;
                }
            }
        }

        private void GenerateDataForWeekly()
        {
            int NoOfRecords=0;
            DateTime StartDate=Convert.ToDateTime(null);
            StartDate = dtStart.Value;

            int WeekNo=0;
            string WeekDay="";

            WeekNo = Convert.ToInt16(Pattern1);

            string[] arr = Pattern2.Split(new char[]{'|'});
            int counter=arr.Length-1;
            WeekDay = Pattern2;

            bool boolEntries=false;
            if(NoEntries=="")
            {
                TimeSpan ts = dtEnd.Value - StartDate;
                NoOfRecords = ts.Days;
                NoOfRecords++;
            }
            else
            {
                NoOfRecords = Convert.ToInt16(NoEntries);
                boolEntries=true;
            }

            bool boolOk=false;
            int cnt=0;
            while(NoOfRecords>0)
            {
                foreach(string s in arr)
                {
                    if(s!="")
                    {
                        boolOk=false;
                        if((s=="Monday") && (StartDate.DayOfWeek==DayOfWeek.Monday)) boolOk=true;
                        else if((s=="Tuesday") && (StartDate.DayOfWeek==DayOfWeek.Tuesday)) boolOk=true;
                        else if((s=="Wednesday") && (StartDate.DayOfWeek==DayOfWeek.Wednesday)) boolOk=true;
                        else if((s=="Thursday") && (StartDate.DayOfWeek==DayOfWeek.Thursday)) boolOk=true;
                        else if((s=="Friday") && (StartDate.DayOfWeek==DayOfWeek.Friday)) boolOk=true;
                        else if((s=="Saturday") && (StartDate.DayOfWeek==DayOfWeek.Saturday)) boolOk=true;
                        else if((s=="Sunday") && (StartDate.DayOfWeek==DayOfWeek.Sunday)) boolOk=true;

                        if(boolOk)
                        {
                            if(cnt<counter)
                            {
                                if(boolOk)
                                {
                                    boolOk=false;
                                }
                                SaveCalendarEvent(StartDate, StartDate);
                                if(boolEntries) NoOfRecords--;
                            }
                            cnt++;
                        }
                    }
                }
                if(cnt==WeekNo*counter) cnt=0;
                StartDate = StartDate.AddDays(1);
                if(boolEntries==false) NoOfRecords--;
            }
        }

        private void GenerateDataForMonthly()
        {
            int NoOfRecords=0;
            DateTime StartDate=Convert.ToDateTime(null);
            StartDate = dtStart.Value;

            int DayNo=0;
            int MonthFreqiency=0;

            DayNo = Convert.ToInt16(Pattern1);
            MonthFreqiency = Convert.ToInt16(Pattern2);

            if(NoEntries=="")
            {
                TimeSpan ts = dtEnd.Value - StartDate;
                NoOfRecords = ts.Days;
                NoOfRecords++;
            }
            else
            {
                NoOfRecords = Convert.ToInt16(NoEntries);
                DateTime dtCaclEnd = StartDate.AddMonths(NoOfRecords);
                TimeSpan ts = new TimeSpan();
                ts = dtCaclEnd.Subtract(StartDate);
                NoOfRecords = (int)Math.Round(ts.TotalDays,0);
                //NoOfRecords = NoOfRecords*31;
            }

            bool boolOk=false;
            int cnt=0;
            while(NoOfRecords>0)
            {
                if(StartDate.Day==DayNo) boolOk=true;
                if(boolOk)
                {
                    if(cnt==0)
                    {
                        //MessageBox.Show(StartDate.ToString());
                        SaveCalendarEvent(StartDate, StartDate);
                    }
                    cnt++;
                    if(cnt==MonthFreqiency) cnt=0;
                }
                StartDate = StartDate.AddDays(1);
                NoOfRecords--;

                boolOk=false;
            }
        }

        private void GenerateDataForYearly()
        {
            int NoOfRecords=0;
            DateTime StartDate=Convert.ToDateTime(null);
            StartDate = dtStart.Value;

            string Month="";
            int DayNo=0;

            Month = Pattern1;
            DayNo = Convert.ToInt16(Pattern2);

            if(NoEntries=="")
            {
                TimeSpan ts = dtEnd.Value - StartDate;
                NoOfRecords = ts.Days;
                NoOfRecords++;
            }
            else
            {
                NoOfRecords = Convert.ToInt16(NoEntries);
                NoOfRecords = NoOfRecords*366;
            }

            int MonthNo=0;
            bool boolOk=false;

            if(Month=="January") MonthNo=1;
            else if(Month=="February") MonthNo=2;
            else if(Month=="March") MonthNo=3;
            else if(Month=="April") MonthNo=4;
            else if(Month=="May") MonthNo=5;
            else if(Month=="June") MonthNo=6;
            else if(Month=="July") MonthNo=7;
            else if(Month=="August") MonthNo=8;
            else if(Month=="September") MonthNo=9;
            else if(Month=="October") MonthNo=10;
            else if(Month=="November") MonthNo=11;
            else if(Month=="December") MonthNo=12;

            while(NoOfRecords>0)
            {
                if((StartDate.Day==DayNo) && (StartDate.Month==MonthNo)) boolOk=true;
                if(boolOk)
                {
                    //MessageBox.Show(StartDate.ToString());
                    SaveCalendarEvent(StartDate, StartDate);
                }
                StartDate = StartDate.AddDays(1);
                NoOfRecords--;

                boolOk=false;
            }
        }
        */
        //Adds a Calendar Event to database
        private void SaveCalendarEvent(DateTime mStart, DateTime mEnd)
        {
            /*
             if(!AutoSave)
            {
                if(dtblDates!=null)
                {
                    dtblDates.Rows.Add(new object[]{mStart, mEnd});
                }
                return true;
            }*/

            bool boolSuccess=false;
            string StartTime="";
            string EndTime="";
            int startlength=8;
            int endlength=8;

            if(objEvent==null) objEvent	= new Scheduler.BusinessLayer.Events();

            objEvent.EventID = _eventid;
            objEvent.Name = txtName.Text;
            objEvent.NamePhonetic = txtPhonetic.Text;
            objEvent.NameRomaji = txtRomaji.Text;

            string[] arr1 = cmbTeacher1.Text.Split(new char[]{','});
            string[] arr2 = cmbTeacher1.Text.Split(new char[]{','});

            string str1="", str2="";
            str1 = arr1[0].Trim();
            if(arr1.Length>1) str2 = arr1[1].Trim();

            objEvent.SchedulerTeacherID = Common.GetTeacherID(
                    "Select ContactID From Contact " +
                    "Where FirstName =@FirstName and LastName = @LastName and ContactType=1 ", str2, str1
                    );

            str1="";
            str2="";
            arr1 = cmbTeacher2.Text.Split(new char[]{','});
            arr2 = cmbTeacher2.Text.Split(new char[]{','});
            str1 = arr2[0].Trim();
            if(arr2.Length>1) str2 = arr2[1].Trim();

            objEvent.RealTeacherID = Common.GetTeacherID(
                    "Select ContactID From Contact " +
                    "Where FirstName =@FirstName and LastName = @LastName and ContactType=1 ", str2, str1
                    );

            objEvent.EventType = cmbEventType.Text;
            objEvent.Location = txtLocation.Text;
            objEvent.BlockCode = cmbBlock.Text;
            objEvent.RoomNo = txtRoomNo.Text;
            objEvent.ChangeReason = txtChangeReason.Text;

            try
            {
                startlength = cmbStartTime.Text.Length;
                endlength = cmbEndTime.Text.Length;

                StartTime = mStart.ToShortDateString() + " " + cmbStartTime.Text.Trim();
                EndTime = mEnd.ToShortDateString() + " " + cmbEndTime.Text.Trim();

                mStart=Convert.ToDateTime(StartTime);
                mEnd=Convert.ToDateTime(EndTime);
            }
            catch{}
            objEvent.StartDate = mStart;
            objEvent.EndDate = mEnd;
            objEvent.DateCompleted = dtDateComplete.Value;

            if(chkIsHoliday.Checked)
                objEvent.IsHoliday = 1;
            else
                objEvent.IsHoliday = 0;

            objEvent.Description = txtDescription.Text;
            objEvent.Notes = txtNote.Text;
            objEvent.ExceptionReason = cmbExceptionReason.Text;

            objEvent.CalendarEventStatus = cmbEventStatus.SelectedIndex;

            boolSuccess = objEvent.InsertCalendarEventData();

            if(!boolSuccess)
            {
                Scheduler.BusinessLayer.Message.ShowException("Inserting Calendar Event record.", objEvent.Message);
                return;
            }
        }
Beispiel #7
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;
        }
Beispiel #8
0
        private void Delete()
        {
            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());

                    if (Message.MsgDelete())
                    {
                        User objUser = new User();
                        objUser.UserID = intUserID;
                        objUser.ContactID = intContactID;
                        if (!objUser.DeleteData())
                        {
                            Message.MsgWarning("User cannot be deleted");
                            fUser.grdUser.Focus();
                            return;
                        }

                        fUser.LoadUser();
                        fUser.grdUser.Focus();
                        fUser.gvwUser.FocusedRowHandle = Row - 1;
                        if (fUser.gvwUser.RowCount > 0)
                        {
                            if (fUser.gvwUser.FocusedRowHandle < 0)
                            {
                                fUser.gvwUser.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if ((strMenuOption == "Contact...") || (strMenuOption == "Instructor...") || (strMenuOption == "Client..."))
            {
                string strtemp = "";
                int Row = fContact.gvwContact.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intID =
                        Convert.ToInt32(
                            fContact.gvwContact.GetRowCellValue(fContact.gvwContact.FocusedRowHandle, fContact.gcolContactID).ToString());
                    strtemp = strMenuOption;
                    strtemp = strtemp.Replace("...", "");

                    if (Message.MsgDelete())
                    {
                        Contact objContact = new Contact();
                        objContact.ContactID = intID;
                        //objContact.DeleteData();
                        if (!objContact.DeleteData())
                        {
                            Message.MsgWarning(strtemp + " cannot be deleted");
                            fContact.grdContact.Focus();
                            return;
                        }

                        fContact.LoadContact(strtemp);
                        fContact.grdContact.Focus();
                        fContact.gvwContact.FocusedRowHandle = Row - 1;
                        if (fContact.gvwContact.RowCount > 0)
                        {
                            if (fContact.gvwContact.FocusedRowHandle < 0)
                            {
                                fContact.gvwContact.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            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());

                    if (Message.MsgDelete())
                    {
                        Department objDept = new Department();
                        objDept.DeptID = intDeptID;
                        objDept.ContactID = intContactID;
                        //objDept.DeleteData();
                        if (!objDept.DeleteData())
                        {
                            Message.MsgWarning("Department cannot be deleted");
                            fDept.grdDept.Focus();
                            return;
                        }

                        fDept.LoadDepartment();
                        fDept.grdDept.Focus();
                        fDept.gvwDept.FocusedRowHandle = Row - 1;
                        if (fDept.gvwDept.RowCount > 0)
                        {
                            if (fDept.gvwDept.FocusedRowHandle < 0)
                            {
                                fDept.gvwDept.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if (strMenuOption == "Program...")
            {
                int Row = fProgram.gvwProgram.FocusedRowHandle;
                if (Row >= 0)
                {
                    int intID =
                        Convert.ToInt32(
                            fProgram.gvwProgram.GetRowCellValue(fProgram.gvwProgram.FocusedRowHandle, fProgram.gcolProgID).ToString());

                    if (Message.MsgDelete())
                    {
                        Program objProg = new Program();
                        objProg.ProgramID = intID;
                        //objProg.DeleteData();
                        if (!objProg.DeleteData())
                        {
                            Message.MsgWarning("Program cannot be deleted");
                            fProgram.grdProgram.Focus();
                            return;
                        }

                        fProgram.LoadProgram();
                        fProgram.grdProgram.Focus();
                        fProgram.gvwProgram.FocusedRowHandle = Row - 1;
                        if (fProgram.gvwProgram.RowCount > 0)
                        {
                            if (fProgram.gvwProgram.FocusedRowHandle < 0)
                            {
                                fProgram.gvwProgram.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            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());

                    if (Message.MsgDelete())
                    {
                        Course objCourse = new Course();
                        objCourse.CourseId = intID;
                        //objCourse.DeleteData();
                        if (!objCourse.DeleteData())
                        {
                            Message.MsgWarning("Class cannot be deleted");
                            fCourse.grdCourse.Focus();
                            return;
                        }

                        fCourse.LoadCourse();
                        fCourse.grdCourse.Focus();
                        fCourse.gvwCourse.FocusedRowHandle = Row - 1;
                        if (fCourse.gvwCourse.RowCount > 0)
                        {
                            if (fCourse.gvwCourse.FocusedRowHandle < 0)
                            {
                                fCourse.gvwCourse.FocusedRowHandle = 0;
                            }
                        }
                    }
                }
            }
            else if (strMenuOption == "Event...")
            {
                int Row = fEvt.gvwEvent.FocusedRowHandle;
                bool IsRecur = false;

                if (Row >= 0)
                {
                    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());
                    int CourseId = Convert.ToInt32(fEvt.gvwEvent.GetRowCellValue(fEvt.gvwEvent.FocusedRowHandle, fEvt.gcolCourseId).ToString());

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

                    if (IsRecur)
                    {
                        frmDeleteEvents frmDelEvt = new frmDeleteEvents(intID, intCalID);
                        if (frmDelEvt.ShowDialog() == DialogResult.OK)
                        {
                            fEvt.LoadEvent();
                            fEvt.grdEvent.Focus();
                            fEvt.gvwEvent.FocusedRowHandle = Row - 1;
                            if (fEvt.gvwEvent.RowCount > 0)
                            {
                                if (fEvt.gvwEvent.FocusedRowHandle < 0)
                                    fEvt.gvwEvent.FocusedRowHandle = 0;
                            }
                        }
                        frmDelEvt.Close();
                        frmDelEvt.Dispose();
                        frmDelEvt = null;
                    }
                    else
                    {
                        if (Message.MsgDelete())
                        {
                            string strMess = "";
                            Events evt = new Events();
                            evt.EventID = intID;
                            strMess = evt.CheckClassEvent();
                            if (strMess == "") strMess = evt.CheckProgramEvent();

                            if (strMess != "")
                            {
                                Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                                return;
                            }

                            //evt.DeleteData(true);
                            if (evt.EventType=="Extra Class")
                                evt.DeleteSingleCalendarEvent();
                            else
                                evt.DeleteTestEvent("Course", CourseId);

                            fEvt.LoadEvent();
                            fEvt.grdEvent.Focus();
                            fEvt.gvwEvent.FocusedRowHandle = Row - 1;
                            if (fEvt.gvwEvent.RowCount > 0)
                                if (fEvt.gvwEvent.FocusedRowHandle < 0)
                                    fEvt.gvwEvent.FocusedRowHandle = 0;
                        }
                    }
                }
            }
            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;

                    if (IsRecur)
                    {
                        frmDeleteEvents frmDelEvt = new frmDeleteEvents(intEventID, intCalID);
                        if (frmDelEvt.ShowDialog() == DialogResult.OK)
                        {
                            fCalendar.LoadCalendar();
                        }
                        frmDelEvt.Close();
                        frmDelEvt.Dispose();
                        frmDelEvt = null;
                    }
                    else
                    {
                        if (Message.MsgDelete())
                        {
                            string strMess = "";
                            Events evt = new Events();
                            evt.EventID = intEventID;
                            strMess = evt.CheckClassEvent();
                            if (strMess == "") strMess = evt.CheckProgramEvent();

                            if (strMess != "")
                            {
                                Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                                return;
                            }

                            evt.DeleteData(true);
                            fCalendar.LoadCalendar();
                        }
                    }
                }
            }
        }
Beispiel #9
0
        private bool SaveCalendarData(int _eventid, int _calid, DateTime mStart, DateTime mEnd)
        {
            bool boolSuccess = false;
            string StartTime = "";
            string EndTime = "";
            int startlength = 8;
            int endlength = 8;

            if (objEvent == null) objEvent = new Scheduler.BusinessLayer.Events();
            objEvent.EventID = _eventid;
            objEvent.Name = txtName_I.Text;
            objEvent.NamePhonetic = txtPhonetic_I.Text;
            objEvent.NameRomaji = txtRomaji_I.Text;
            objEvent.CalendarEventID = _calid;

            string[] arr1 = cmbTeacher1_I.Text.Split(new char[] { ',' });
            string[] arr2 = cmbTeacher1_I.Text.Split(new char[] { ',' });

            string str1 = "", str2 = "";
            str1 = arr1[0].Trim();
            if (arr1.Length > 1) str2 = arr1[1].Trim();

            objEvent.SchedulerTeacherID = Common.GetTeacherID(
                "Select ContactID From Contact " +
                "Where FirstName =@FirstName and LastName = @LastName and ContactType=1 ", str2, str1
                );

            str1 = "";
            str2 = "";
            arr1 = cmbTeacher2_I.Text.Split(new char[] { ',' });
            arr2 = cmbTeacher2_I.Text.Split(new char[] { ',' });
            str1 = arr2[0].Trim();
            if (arr2.Length > 1) str2 = arr2[1].Trim();

            objEvent.RealTeacherID = Common.GetTeacherID(
                "Select ContactID From Contact " +
                "Where FirstName =@FirstName and LastName = @LastName and ContactType=1 ", str2, str1
                );

            objEvent.ChangeReason = txtChangeReason_I.Text;
            //objEvent.EventType = cmbEventType_I.SelectedIndex;
            objEvent.EventType = cmbEventType_I.Text;
            objEvent.Location = txtLocation_I.Text;
            objEvent.BlockCode = cmbBlock_I.Text;
            objEvent.RoomNo = txtRoomNo_I.Text;

            try
            {
                startlength = cmbStartTime.Text.Length;
                endlength = cmbEndTime.Text.Length;

                StartTime = mStart.ToShortDateString() + " " + cmbStartTime.Text.Trim();
                EndTime = mEnd.ToShortDateString() + " " + cmbEndTime.Text.Trim();

                mStart = Convert.ToDateTime(StartTime);
                mEnd = Convert.ToDateTime(EndTime);
            }
            catch { }
            objEvent.StartDate = mStart;
            objEvent.EndDate = mEnd;
            objEvent.DateCompleted = dtDateComplete_I.Value;

            if (chkIsHoliday.Checked)
                objEvent.IsHoliday = 1;
            else
                objEvent.IsHoliday = 0;

            objEvent.Description = txtDescription_I.Text;
            objEvent.Notes = txtNote_I.Text;
            objEvent.ExceptionReason = cmbExceptionReason_I.Text;

            if (chkEventStatus_I.Checked)
                objEvent.CalendarEventStatus = 1;
            else
                objEvent.CalendarEventStatus = 0;
            //objEvent.CalendarEventStatus = cmbEventStatus_I.SelectedIndex;

            boolSuccess = objEvent.UpdateCalendarEventData();
            if (!boolSuccess)
            {
                Scheduler.BusinessLayer.Message.ShowException("Updating Calendar Event record.", objEvent.Message);
            }

            return boolSuccess;
        }
Beispiel #10
0
        private void LoadEvent(int _eventid, int CalendarID)
        {
            if (saved)
            {
                saved = false;
                return;
            }
            if (_eventid == 0) return;
            _curreventid = _eventid;
            DataTable dtbl = null;

            objEvent = new Scheduler.BusinessLayer.Events();
            objEvent.EventID = _eventid;

            //pnlTop_I.Visible=false;
            //btn_ClearRecc.Visible=true;

            if (CalendarID > 0) objEvent.CalendarEventID = CalendarID;
            dtbl = objEvent.LoadData();

            if (dtbl.Rows.Count <= 0)
            {
                _eventid = 0;
                CalendarID = 0;
                _calendareventid_Initial = 0;
                _eventid_Initial = 0;
            }

            if (CalendarID != 0)
            {
                //means opening a single occurrence
                pnlTop_I.Visible = true;
                pnlBottom.Visible = false;
                objEvent.CalendarEventID = CalendarID;
                boolSaveSeries_initial = false;
            }
            else
            {
                pnlTop_I.Visible = false;
                pnlBottom.Visible = true;
                //Commented our because the 'Clear Recurrence' button should not be visible for non-repeating class events
                //btn_ClearRecc.Visible = true;
                //boolSaveSeries_initial = true;
            }

            //Adjust Textbox height
            if (pnlBottom.Visible)
                txtNote_I.Height = 130;
            else
                txtNote_I.Height = 150;

            if (dtbl.Rows.Count <= 0)
            {
                InitializeEventForm();
                return;
            }

            foreach (DataRow dr in dtbl.Rows)
            {
                RepeatRule = dr["RepeatRule"].ToString();
                NegativeException = dr["NegetiveException"].ToString();

                txtName_I.Text = dr["Name"].ToString();
                txtPhonetic_I.Text = dr["NamePhonetic"].ToString();
                txtRomaji_I.Text = dr["NameRomaji"].ToString();

                if (dr["EventType"] != System.DBNull.Value)
                {
                    cmbEventType_I.SelectedIndex = cmbEventType_I.Items.IndexOf(dr["EventType"].ToString());
                    //cmbEventType_I.SelectedIndex = Convert.ToInt16(dr["EventType"].ToString());
                }
                else
                    cmbEventType_I.SelectedIndex = -1;

                txtLocation_I.Text = dr["Location"].ToString();
                cmbBlock_I.Text = dr["BlockCode"].ToString();
                txtRoomNo_I.Text = dr["RoomNumber"].ToString();
                txtDescription_I.Text = dr["Description"].ToString();
                txtNote_I.Text = dr["Note"].ToString();
                if (dr["ExceptionReason"] != System.DBNull.Value)
                    cmbExceptionReason_I.Text = dr["ExceptionReason"].ToString();

                //cmbEventStatus_I.SelectedIndex = Convert.ToInt16(dr["EventStatus"].ToString());
                if (Convert.ToInt16(dr["EventStatus"].ToString()) == 1)
                    chkEventStatus_I.Checked = true;
                else
                    chkEventStatus_I.Checked = false;
                cmbTeacher1_I.Text = dr["ScheduledTeacher"].ToString();
                cmbTeacher2_I.Text = dr["RealTeacher"].ToString();
                txtChangeReason_I.Text = dr["ChangeReason"].ToString();

                if (dr["IsHoliday"] == System.DBNull.Value)
                    chkIsHoliday.Checked = false;
                else
                    chkIsHoliday.Checked = (Convert.ToInt16(dr["IsHoliday"]) > 0);

                XMLData_Initial = dr["RepeatRule"].ToString();

                IsRecurrenceFlag_Initial = 0;
                if (dr["RecurrenceText"] != System.DBNull.Value)
                    if (dr["RecurrenceText"].ToString() != "")
                        IsRecurrenceFlag_Initial = 1;

                if (IsRecurrenceFlag_Initial == 1)
                {
                    //For loading series or one occurrence in a series
                    if (dtblDates == null)
                    {
                        dtblDates = new DataTable();
                        dtblDates.Columns.Add("StartDate", Type.GetType("System.DateTime"));
                        dtblDates.Columns.Add("EndDate", Type.GetType("System.DateTime"));
                    }
                    else
                    {
                        dtblDates.Rows.Clear();
                    }

                    FileInfo fi = new FileInfo(strAppPath);
                    StreamWriter Tex = fi.CreateText();
                    Tex.Write(XMLData_Initial);
                    Tex.Close();
                    Tex = null;

                    if (AP == null) AP = new Serialize();
                    AP = AP.Load(strAppPath);

                    if (AP == null)
                    {
                        dtStart.Value = Convert.ToDateTime(dr["StartDateTime"].ToString());
                        dtEnd.Value = Convert.ToDateTime(dr["EndDateTime"].ToString());

                        cmbStartTime.Text = Convert.ToDateTime(dr["StartDateTime"]).ToString("HH:mm");
                        SetTime(cmbEndTime, Convert.ToDateTime(dr["EndDateTime"]).ToString("HH:mm"));

                        StartTime = cmbStartTime.Text;
                        EndTime = cmbEndTime.Text;
                    }
                    else
                    {
                        try
                        {
                            setToConfig();
                            dtStart.Value = Convert.ToDateTime(_startdate_Initial);
                            dtEnd.Value = Convert.ToDateTime(_enddate_Initial);

                            SetTime(cmbStartTime, Convert.ToDateTime(_startdate_Initial).ToString("HH:mm"));
                            SetTime(cmbEndTime, Convert.ToDateTime(_enddate_Initial).ToString("HH:mm"));

                            StartTime = cmbStartTime.Text;
                            EndTime = cmbEndTime.Text;
                            SeforRecurrence(true);
                        }
                        catch { }
                    }
                }
                else
                {
                    //For single class events that do not repeat.
                    dtStart.Value = Convert.ToDateTime(dr["StartDateTime"].ToString());
                    dtEnd.Value = Convert.ToDateTime(dr["EndDateTime"].ToString());

                    StartTime = dtStart.Value.ToString("HH:mm");
                    EndTime = dtEnd.Value.ToString("HH:mm");
                    try
                    {
                        SetTime(cmbStartTime, Convert.ToDateTime(StartTime).ToString("HH:mm"));
                        SetTime(cmbEndTime, Convert.ToDateTime(EndTime).ToString("HH:mm"));
                    }
                    catch { }
                }

                if ((_eventid > 0) && (boolSaveSeries_initial == false))
                {
                    dtStart.Value = Convert.ToDateTime(dr["StartDateTime"].ToString());
                    dtEnd.Value = Convert.ToDateTime(dr["EndDateTime"].ToString());

                    string StartTime = "";
                    string EndTime = "";
                    StartTime = dtStart.Value.ToString("HH:mm");
                    EndTime = dtEnd.Value.ToString("HH:mm");
                    try
                    {
                        //StartTime
                        StartTime = Convert.ToDateTime(StartTime).ToString("HH:mm");
                        if (StartTime.Substring(0, 1) == "0")
                        {
                            StartTime = StartTime.Substring(1, StartTime.Length - 1);
                        }
                        cmbStartTime.Text = StartTime;
                        SetTime(cmbEndTime, Convert.ToDateTime(EndTime).ToString("HH:mm"));
                    }
                    catch { }
                }

                dtDateComplete_I.Value = Convert.ToDateTime(dr["DateCompleted"].ToString());

                StartDate = dtStart.Value.ToShortDateString() + " " + cmbStartTime.Text;
                EndDate = dtEnd.Value.ToShortDateString() + " " + cmbEndTime.Text;

                break;
            }

            if (!chkEventStatus_I.Checked && cmbTeacher2_I.SelectedIndex <= 0 && cmbExceptionReason_I.SelectedIndex <= 0 && cmbExceptionReason_I.Text == "")
                SetEventModificationControls(false);
            else
                SetEventModificationControls(true);
        }
Beispiel #11
0
        /*
        private void LoadEvent()
        {
            llblEvent.Text = "None";
            llblInitialEvt.Text = "None";
            llblMidEvt.Text = "None";
            llblFinalEvt.Text = "None";

            Scheduler.BusinessLayer.Course objCourse=new Scheduler.BusinessLayer.Course();
            objCourse.CourseId = _courseid;
            objCourse.LoadData();

            foreach(DataRow dr in objCourse.CourseDataTable.Rows)
            {
                txtEvent.Text = dr["EventID"].ToString();
                txtInitialEvent.Text = dr["TestInitialEventId"].ToString();
                txtMidtermEvent.Text = dr["TestMidTermEventId"].ToString();
                txtFinalEvent.Text = dr["TestFinalEventId"].ToString();
                break;
            }

            string strHint="";

            llblEvent.Text = objCourse.getEventText(txtEvent.Text, "Event", ref strHint);
            if(strHint!="") llblEvent.Text = strHint;

            strHint="";
            llblInitialEvt.Text = objCourse.getEventText(txtInitialEvent.Text, "Initial", ref strHint);
            strHint="";

            llblMidEvt.Text = objCourse.getEventText(txtMidtermEvent.Text, "Midterm", ref strHint);
            strHint="";

            llblFinalEvt.Text = objCourse.getEventText(txtEvent.Text, "Event", ref strHint);
            strHint="";
        }
        */
        private bool LoadEvent(int _eventid, ref ArrayList arrEvent)
        {
            //SaveEventData(ref _eventid);

            if (_eventid == 0) return false;
            DataTable dtbl = null;
            DateTime dt1 = Convert.ToDateTime(null);
            DateTime dt2 = Convert.ToDateTime(null);
            string sReccText = string.Empty;

            objEvent = new Scheduler.BusinessLayer.Events();
            objEvent.EventID = _eventid;

            dtbl = objEvent.LoadData();
            if (dtbl.Rows.Count <= 0)
            {
                return false;
            }

            arrEvent.Add("");
            foreach (DataRow dr in dtbl.Rows)
            {
                bool IsRecc = false;
                #region oldCode
                /*if(dr["RecurrenceText"]!=System.DBNull.Value)
                {
                    if(dr["RecurrenceText"].ToString()!="")
                    {
                        IsRecc=true;
                        FileInfo fi = new FileInfo(strAppPath);
                        StreamWriter Tex =fi.CreateText();
                        Tex.Write(XMLData_Initial);
                        Tex.Close();
                        Tex=null;

                        if(AP==null) AP = new Serialize();
                        AP = AP.Load(strAppPath);

                        if(AP==null)
                        {
                            dt1 = Convert.ToDateTime(dr["StartDateTime"].ToString());
                            dt2 = Convert.ToDateTime(dr["EndDateTime"].ToString());
                        }
                        else
                        {
                            try
                            {
                                setToConfig();
                                dt1 = Convert.ToDateTime(_startdate_Initial);
                                dt2 = Convert.ToDateTime(_enddate_Initial);

                                sReccText = SeforRecurrence();
                            }
                            catch{}
                        }

                    }
                }*/
                #endregion
                if (IsRecc == false)
                {
                    dt1 = Convert.ToDateTime(dr["StartDateTime"].ToString());
                    dt2 = Convert.ToDateTime(dr["EndDateTime"].ToString());
                }

                arrEvent.Add(dr["Name"].ToString());
                arrEvent.Add(dr["NamePhonetic"].ToString());
                arrEvent.Add(dr["NameRomaji"].ToString());

                arrEvent.Add(dt1.ToString());
                arrEvent.Add(dt2.ToString());
                //arrEvent.Add(sReccText.Trim());

                arrEvent.Add(dr["Location"].ToString());
                arrEvent.Add(dr["BlockCode"].ToString());
                arrEvent.Add(dr["RoomNumber"].ToString());
                if (dr["IsHoliday"] == System.DBNull.Value)
                {
                    arrEvent.Add("No");
                }
                else
                {
                    if (Convert.ToInt16(dr["IsHoliday"]) > 0)
                        arrEvent.Add("Yes");
                    else
                        arrEvent.Add("No");
                }
                if (dr["DateCompleted"] != System.DBNull.Value)
                {
                    arrEvent.Add(dr["DateCompleted"].ToString());
                }
                else
                {
                    arrEvent.Add("");
                }
                if (Convert.ToInt16(dr["EventStatus"].ToString()) == 0)
                {
                    arrEvent.Add("Active");
                }
                else
                {
                    arrEvent.Add("Inactive");
                }
                arrEvent.Add(dr["ScheduledTeacher"].ToString());
                arrEvent.Add(dr["RealTeacher"].ToString());

                if (dr["ChangeReason"] != System.DBNull.Value)
                {
                    arrEvent.Add(dr["ChangeReason"].ToString());
                }
                else
                {
                    arrEvent.Add("");
                }
                if (dr["ExceptionReason"] != System.DBNull.Value)
                {
                    arrEvent.Add(dr["ExceptionReason"].ToString());
                }
                else
                {
                    arrEvent.Add("");
                }
                if (dr["Description"] != System.DBNull.Value)
                {
                    arrEvent.Add(dr["Description"].ToString());
                }
                else
                {
                    arrEvent.Add("");
                }
                if (dr["Note"] != System.DBNull.Value)
                {
                    arrEvent.Add(dr["Note"].ToString());
                }
                else
                {
                    arrEvent.Add("");
                }

                break;

            }
            return true;
        }
Beispiel #12
0
        private void btnDel_Click(object sender, EventArgs e)
        {
            string strMessage = gvwEvents.GetRowCellValue(gvwEvents.FocusedRowHandle, gcolEventType).ToString();

            if (Scheduler.BusinessLayer.Message.MsgDelete(strMessage))
            {
                //Delete Event - both from 'Event' and 'CalendarEvent'
                int _eid,_ceid;
                string strEventType;
                bool boolSuccess = false;

                 _ceid = int.Parse(gvwEvents.GetRowCellValue(gvwEvents.FocusedRowHandle, gcolCaldendarEventID).ToString());
                 _eid = int.Parse(gvwEvents.GetRowCellValue(gvwEvents.FocusedRowHandle, gcolEventID).ToString());
                 strEventType = gvwEvents.GetRowCellValue(gvwEvents.FocusedRowHandle, gcolEventType).ToString();

                objEvent = new Events();
                objEvent.EventID = _eid;
                objEvent.CalendarEventID = _ceid;
                objEvent.EventType = strEventType;

                if (objEvent.EventType == "Extra Class")
                    boolSuccess = objEvent.DeleteSingleCalendarEvent();
                else
                    boolSuccess = objEvent.DeleteTestEvent("Course", CourseId);

                if (!boolSuccess)
                {
                    Scheduler.BusinessLayer.Message.ShowException("Deleting Event Data.", objEvent.Message);
                    return;
                }

                LoadData();
                LoadOtherEvents();
            }
        }
Beispiel #13
0
        void DeleteEvent()
        {
            System.Data.DataRow eventRow = null;

            if (gvwEvent.SelectedRowsCount > 0)
                eventRow = gvwEvent.GetDataRow(gvwEvent.FocusedRowHandle);
            if (eventRow != null)
            {
                bool isRecur = false;
                int calEventID = Convert.ToInt32(eventRow["CalendarEventID"]);
                int eventID = Convert.ToInt32(eventRow["EventID"]);
                string strRecurrenceText = Common.GetString("select RecurrenceText from Event where EventID=" + eventID.ToString());

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

                if (isRecur)
                {
                    #region Delete Recurrence
                    frmDeleteEvents frmDelEvt = new frmDeleteEvents(eventID, calEventID);
                    if (frmDelEvt.ShowDialog() == DialogResult.OK)
                    {
                        LoadEvent();
                    }
                    frmDelEvt.Close();
                    frmDelEvt.Dispose();
                    #endregion

                }
                else
                {
                    #region DeleteEvent
                    if (Message.MsgDelete())
                    {
                        string strMess;
                        Events evt = new Events();
                        evt.EventID = eventID;
                        strMess = evt.CheckClassEvent();
                        if (strMess == "") strMess = evt.CheckProgramEvent();

                        if (strMess != "") {
                            Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                            return;
                        }

                        evt.DeleteData(true);
                        if (!evt.CheckEventExists(eventID))
                        {
                            string module = string.Empty;
                            int _uid = 0;
                            int _eventtypeindex = 0;
                            Events objEvent = new Events();
                            //Returns Course/Program ID
                            _uid = objEvent.GetEvent(eventID, ref module, ref _eventtypeindex);
                            objEvent.EventID = 0;
                            objEvent.UpdateClassEvent(_uid, "EventId");
                        }
                        LoadEvent();
                    }
                    #endregion
                }

            }
        }
Beispiel #14
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();
            }*/
        }
Beispiel #15
0
        private void SaveEventData(ref int _eventid)
        {
            bool boolSuccess;
            objEvent = null;

            if (File.Exists(strAppPath))
            {
                StreamReader re = File.OpenText(strAppPath);
                XMLData_Initial = re.ReadToEnd();
                re.Close();
                re = null;
            }
            else
            {
                XMLData_Initial = "";
                IsRecurrenceFlag_Initial = 0;
            }

            objEvent = new Scheduler.BusinessLayer.Events();
            objEvent.EventID = 0;
            objEvent.RepeatRule = XMLData_Initial;
            objEvent.NegativeException = "";
            objEvent.Description = txtDescription_I.Text;

            //if (cmbEventStatus_I.SelectedIndex == -1)
            //    cmbEventStatus_I.SelectedIndex = 0;
            if (chkEventStatus_I.Checked)
                objEvent.EventStatus = 1;
            else
                objEvent.EventStatus = 0;
            //objEvent.EventStatus = cmbEventStatus_I.SelectedIndex;

            if (IsRecurrenceFlag_Initial > 0)
                objEvent.RecurrenceText = lblRecurrenceText_I.Text;
            else
                objEvent.RecurrenceText = "";

            if (_eventid <= 0)
            {
                if (objEvent.Exists())
                {
                    Scheduler.BusinessLayer.Message.MsgInformation("Duplicate Course Name not allowed");
                    txtName_I.Focus();
                    return;
                }
                boolSuccess = objEvent.InsertData();
                _eventid_Initial = objEvent.EventID;
                _eventid = objEvent.EventID;
                setEventID(objEvent.EventID);
            }
            else
            {
                objEvent.EventID = _eventid;
                boolSuccess = objEvent.UpdateData();
            }
            if (!boolSuccess)
            {
                if (_eventid == 0)
                    Scheduler.BusinessLayer.Message.ShowException("Inserting Event record.", objEvent.Message);
                else
                    Scheduler.BusinessLayer.Message.ShowException("Updating Event record.", objEvent.Message);
                return;
            }
        }
Beispiel #16
0
        private void iDelete_Click(object sender, EventArgs e)
        {
            if (schedulerControl1.SelectedAppointments.Count > 0) {
                Appointment apt = schedulerControl1.SelectedAppointments[0];
                bool IsRecur = false;

                controller = new AppointmentFormController(schedulerControl1, apt);

                //int intCalID = Convert.ToInt32(apt.GetValue(schedulerControl1.Storage,"CEID"));
                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;

                if (IsRecur) {
                    frmDeleteEvents frmDelEvt = new frmDeleteEvents(intEventID, intCalID);
                    if (frmDelEvt.ShowDialog() == DialogResult.OK) {
                        schedulerStorage1.Appointments.DataSource = FetchGridData();

                    }
                    frmDelEvt.Close();
                    frmDelEvt.Dispose();
                } else {
                    if (Message.MsgDelete()) {
                        string strMess;
                        Events evt = new Events();
                        evt.EventID = intEventID;
                        strMess = evt.CheckClassEvent();
                        if (strMess == "") strMess = evt.CheckProgramEvent();

                        if (strMess != "") {
                            Message.MsgWarning("This Event is linked with" + strMess + ".\n\nEvent cannot be deleted.");
                            return;
                        }

                        evt.DeleteData(true);
                        schedulerStorage1.Appointments.DataSource = FetchGridData();

                    }
                }

            }
        }
Beispiel #17
0
        private void btnDelete1_Click(object sender, System.EventArgs e)
        {
            int _eventid=0;
            if(Scheduler.BusinessLayer.Message.MsgDelete())
            {
                Events evt = new Events();
                /*
                if(pnlEvent.Parent==tbpInitial)
                {
                    _eventid=eventid[0];

                    evt.EventID = _eventid;
                    evt.DeleteData(true);

                    //Update the Class data
                    evt.UpdateClassEvent("TestInitialEventID", 0, _courseid);

                    eventid[0]=0;
                }
                else if(pnlEvent.Parent==tbpMidterm)
                {
                    _eventid=eventid[1];
                    evt.EventID = _eventid;
                    evt.DeleteData(true);

                    //Update the Class data
                    evt.UpdateClassEvent("TestMidTermEventID", 0, _courseid);

                    eventid[1]=0;
                }
                else if(pnlEvent.Parent==tbpFinal)
                {
                    _eventid=eventid[2];
                    evt.EventID = _eventid;
                    evt.DeleteData(true);

                    //Update the Class data
                    evt.UpdateClassEvent("TestFinalEventID", 0, _courseid);

                    eventid[2]=0;
                }
                else*/ if(pnlEvent.Parent==tbpClassEvent)
                {
                    _eventid=eventid[3];
                    evt.EventID = _eventid;
                    evt.DeleteData(true);

                    //Update the Class data
                    evt.UpdateClassEvent("EventID", 0, _courseid);

                    eventid[3]=0;
                }

                _curreventid=0;

                InitializeEventForm();
                IsEventChanged=false;
            }
        }
Beispiel #18
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;
                }
            }
        }
Beispiel #19
0
        public void LoadEvent()
        {
            isProcess=false;
            //int year=0, month=0;

            DateTime dtStart = SqlDateTime.MinValue.Value;
            DateTime dtEnd = SqlDateTime.MaxValue.Value;

            if(IsLoad)
            {
                PopulateDropDowns();
                LoadFilterSettings();

            }

            if (datePickerStart.Checked)
                dtStart = datePickerStart.Value;

            if (datePickerEnd.Checked)
                dtEnd = datePickerEnd.Value;

            IsLoad=false;

            objEvent = new Events();
            //dtbl = objEvent.LoadData(dtStart, dtEnd, cmbClient.Text, cmbInstructor.Text, cmbProgram.Text, cmbClass.Text);
            //dtbl = objEvent.LoadData(dtStart, dtEnd, ((ValuePair)cmbClient.SelectedItem).Value, ((ValuePair)cmbInstructor.SelectedItem).Value, "", "",true);
            if (!isNewLoad)
            {
                dtbl = objEvent.LoadDataNew(dtStart, dtEnd, ((ValuePair)cmbClient.SelectedItem).Value, ((ValuePair)cmbInstructor.SelectedItem).Value, ((ValuePair)cmbProgram.SelectedItem).Value, ((ValuePair)cmbClass.SelectedItem).Value, true);
                //dtbl = objEvent.LoadDataNew(dtStart, dtEnd, "", "", "", "", true);
                grdEvent.DataSource = dtbl;
            }

            isProcess = true;
            isNewLoad = false;
        }