예제 #1
0
 public bool Update(ProgramClass obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
예제 #2
0
 public int Add(ProgramClass obj)
 {
     try
     {
         _db.ProgramClasses.InsertOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(-1);
     }
     return(_db.ProgramClasses.Max(x => x.ProgramClassId));
 }
예제 #3
0
        protected void RadToolBarProgramClass_OnButtonClick(object sender, RadToolBarEventArgs e)
        {
            switch (e.Item.Text)
            {
            case "New":
                RadGridProgramClass.SelectedIndexes.Clear();
                ResetForm();
                break;

            case "Save":
                var cC = new CProgramClass();
                var c  = new Erp2016.Lib.ProgramClass();
                c.ProgramId = Convert.ToInt32(RadComboBoxProgram.SelectedValue);

                if (string.IsNullOrEmpty(RadComboBoxProgramCourse.SelectedValue) == false)
                {
                    c.ProgramCourseId = Convert.ToInt32(RadComboBoxProgramCourse.SelectedValue);
                }

                if (string.IsNullOrEmpty(RadComboBoxProgramCourseLevel.SelectedValue) == false)
                {
                    c.ProgramCourseLevelId = Convert.ToInt32(RadComboBoxProgramCourseLevel.SelectedValue);
                }

                c.InstructorId       = Convert.ToInt32(RadComboBoxInstructor.SelectedValue);
                c.ProgramClassRoomId = Convert.ToInt32(RadComboBoxClassRoom.SelectedValue);

                c.StartDate = RadDatePickerStartDate.SelectedDate.Value;
                c.EndDate   = RadDatePickerEndDate.SelectedDate.Value;
                c.ClassWeek = Convert.ToInt32(RadComboBoxWeeks.SelectedValue);

                if (RadTimePickerStartMon.SelectedTime != null && RadTimePickerEndMon.SelectedTime != null)
                {
                    c.MondayStartTime = RadTimePickerStartMon.SelectedTime;
                    c.MondayEndTime   = RadTimePickerEndMon.SelectedTime;
                }
                if (RadTimePickerStartTue.SelectedTime != null && RadTimePickerEndTue.SelectedTime != null)
                {
                    c.TuesdayStartTime = RadTimePickerStartTue.SelectedTime;
                    c.TuesdayEndTime   = RadTimePickerEndTue.SelectedTime;
                }
                if (RadTimePickerStartWed.SelectedTime != null && RadTimePickerEndWed.SelectedTime != null)
                {
                    c.WednesdayStartTime = RadTimePickerStartWed.SelectedTime;
                    c.WednesdayEndTime   = RadTimePickerEndWed.SelectedTime;
                }
                if (RadTimePickerStartThu.SelectedTime != null && RadTimePickerEndThu.SelectedTime != null)
                {
                    c.ThursdayStartTime = RadTimePickerStartThu.SelectedTime;
                    c.ThursdayEndTime   = RadTimePickerEndThu.SelectedTime;
                }
                if (RadTimePickerStartFri.SelectedTime != null && RadTimePickerEndFri.SelectedTime != null)
                {
                    c.FridayStartTime = RadTimePickerStartFri.SelectedTime;
                    c.FridayEndTime   = RadTimePickerEndFri.SelectedTime;
                }

                c.WeekDays   = RadNumericTextBoxClassDays.Value;
                c.WeekHours  = RadNumericTextBoxClassHours.Value;
                c.TotalHours = RadNumericTextBoxTotalHours.Value;

                c.SiteLocationId = CurrentSiteLocationId;
                c.Name           = RadTextBoxProgramClass.Text;
                c.Description    = RadTextBoxDescription.Text;
                c.IsActive       = RadButtonActive.Checked;
                c.CreatedId      = CurrentUserId;
                c.CreatedDate    = DateTime.Now.Date;

                if (cC.Add(c) > 0)
                {
                    ShowMessage("'" + c.Name + "' is added.");
                    RadGridProgramClass.Rebind();
                }
                else
                {
                    ShowMessage("Failed to add");
                }
                break;

            case "Update":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    var cP = new CProgramClass();
                    var p  = cP.Get(Convert.ToInt32(RadGridProgramClass.SelectedValue));
                    p.ProgramId = Convert.ToInt32(RadComboBoxProgram.SelectedValue);

                    if (string.IsNullOrEmpty(RadComboBoxProgramCourse.SelectedValue) == false)
                    {
                        p.ProgramCourseId = Convert.ToInt32(RadComboBoxProgramCourse.SelectedValue);
                    }
                    else
                    {
                        p.ProgramCourseId = null;
                    }

                    if (string.IsNullOrEmpty(RadComboBoxProgramCourseLevel.SelectedValue) == false)
                    {
                        p.ProgramCourseLevelId = Convert.ToInt32(RadComboBoxProgramCourseLevel.SelectedValue);
                    }
                    else
                    {
                        p.ProgramCourseLevelId = null;
                    }

                    p.InstructorId       = Convert.ToInt32(RadComboBoxInstructor.SelectedValue);
                    p.ProgramClassRoomId = Convert.ToInt32(RadComboBoxClassRoom.SelectedValue);

                    p.StartDate = RadDatePickerStartDate.SelectedDate.Value;
                    p.EndDate   = RadDatePickerEndDate.SelectedDate.Value;
                    p.ClassWeek = Convert.ToInt32(RadComboBoxWeeks.SelectedValue);

                    if (RadTimePickerStartMon.SelectedTime != null && RadTimePickerEndMon.SelectedTime != null)
                    {
                        p.MondayStartTime = RadTimePickerStartMon.SelectedTime;
                        p.MondayEndTime   = RadTimePickerEndMon.SelectedTime;
                    }
                    if (RadTimePickerStartTue.SelectedTime != null && RadTimePickerEndTue.SelectedTime != null)
                    {
                        p.TuesdayStartTime = RadTimePickerStartTue.SelectedTime;
                        p.TuesdayEndTime   = RadTimePickerEndTue.SelectedTime;
                    }
                    if (RadTimePickerStartWed.SelectedTime != null && RadTimePickerEndWed.SelectedTime != null)
                    {
                        p.WednesdayStartTime = RadTimePickerStartWed.SelectedTime;
                        p.WednesdayEndTime   = RadTimePickerEndWed.SelectedTime;
                    }
                    if (RadTimePickerStartThu.SelectedTime != null && RadTimePickerEndThu.SelectedTime != null)
                    {
                        p.ThursdayStartTime = RadTimePickerStartThu.SelectedTime;
                        p.ThursdayEndTime   = RadTimePickerEndThu.SelectedTime;
                    }
                    if (RadTimePickerStartFri.SelectedTime != null && RadTimePickerEndFri.SelectedTime != null)
                    {
                        p.FridayStartTime = RadTimePickerStartFri.SelectedTime;
                        p.FridayEndTime   = RadTimePickerEndFri.SelectedTime;
                    }

                    p.WeekDays   = RadNumericTextBoxClassDays.Value;
                    p.WeekHours  = RadNumericTextBoxClassHours.Value;
                    p.TotalHours = RadNumericTextBoxTotalHours.Value;

                    p.SiteLocationId = CurrentSiteLocationId;
                    p.Name           = RadTextBoxProgramClass.Text;
                    p.Description    = RadTextBoxDescription.Text;
                    p.IsActive       = RadButtonActive.Checked;

                    p.UpdatedId   = CurrentUserId;
                    p.UpdatedDate = DateTime.Now.Date;

                    if (cP.Update(p))
                    {
                        ShowMessage("'" + p.Name + "' is updated.");
                        RadGridProgramClass.Rebind();
                    }
                    else
                    {
                        ShowMessage("Failed to update");
                    }
                }
                break;

            case "Student Information":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowStudentClassInfo('" + RadGridProgramClass.SelectedValue + "', '" + RadGridProgramClass.SelectedValues["ProgramCourseId"] + "');");
                }
                break;

            case "Student Attendance":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowStudentClassAttendance('" + RadGridProgramClass.SelectedValue + "');");
                }
                break;

            case "Student Grade":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowStudentClassGrade('" + RadGridProgramClass.SelectedValue + "');");
                }
                break;

            // Schools
            case "Class Summary":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridProgramClass.SelectedValue + "', '" + (int)CConstValue.Report.ClassSummary + "' );");
                }
                break;

            case "Starting Students":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridProgramClass.SelectedValue + "', '" + (int)CConstValue.Report.StartingStudents + "' );");
                }
                break;

            case "Completed Graduates Students":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridProgramClass.SelectedValue + "', '" + (int)CConstValue.Report.CompletedGraduatesStudents + "' );");
                }
                break;

            case "Attendance Sheet":
                if (RadGridProgramClass.SelectedValue != null)
                {
                    RunClientScript("ShowReportPop('" + RadGridProgramClass.SelectedValue + "', '" + (int)CConstValue.Report.AttendanceSheet + "');");
                }
                break;
            }
        }