Beispiel #1
0
 public bool Update(GradeSchema obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
Beispiel #2
0
 public int Add(GradeSchema obj)
 {
     try
     {
         _db.GradeSchemas.InsertOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(-1);
     }
     return(_db.GradeSchemas.Max(x => x.GradeSchemaId));
 }
Beispiel #3
0
        protected void RadToolBar1_OnButtonClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "Save")
            {
                var cGradeSchema = new CGradeSchema();
                var gradeSchema  = new Erp2016.Lib.GradeSchema();

                // new
                if (Type == "0")
                {
                    gradeSchema                = new Erp2016.Lib.GradeSchema();
                    gradeSchema.CreatedId      = CurrentUserId;
                    gradeSchema.CreatedDate    = DateTime.Now;
                    gradeSchema.SiteLocationId = CurrentSiteLocationId;

                    if (RadComboBoxIsGlobal.SelectedValue == "1")
                    {
                        var result = cGradeSchema.GetGlobal(CurrentSiteLocationId);
                        if (result != null)
                        {
                            Type        = "1";
                            gradeSchema = result;
                        }
                    }
                }
                // modify
                else
                {
                    gradeSchema = cGradeSchema.Get(Id);
                }

                gradeSchema.Name     = RadTextBoxName.Text;
                gradeSchema.IsGlobal = RadComboBoxIsGlobal.SelectedValue == "1" ? true : false;

                if (!string.IsNullOrEmpty(RadComboBoxProgram.SelectedValue))
                {
                    gradeSchema.ProgramId = Convert.ToInt32(RadComboBoxProgram.SelectedValue);
                }

                if (!string.IsNullOrEmpty(RadComboBoxProgramCourse.SelectedValue))
                {
                    gradeSchema.ProgramCourseId = Convert.ToInt32(RadComboBoxProgramCourse.SelectedValue);
                }

                if (!string.IsNullOrEmpty(RadComboBoxProgramCourseLevel.SelectedValue))
                {
                    gradeSchema.ProgramCourseLevelId = Convert.ToInt32(RadComboBoxProgramCourseLevel.SelectedValue);
                }

                if (!string.IsNullOrEmpty(RadComboBoxProgramClass.SelectedValue))
                {
                    gradeSchema.ProgramClassId = Convert.ToInt32(RadComboBoxProgramClass.SelectedValue);
                }

                if (gradeSchema.IsGlobal)
                {
                    gradeSchema.ProgramId            = null;
                    gradeSchema.ProgramCourseId      = null;
                    gradeSchema.ProgramCourseLevelId = null;
                    gradeSchema.ProgramClassId       = null;
                }

                // new
                if (Type == "0")
                {
                    cGradeSchema.Add(gradeSchema);
                }
                // modify
                else
                {
                    gradeSchema.UpdatedId   = CurrentUserId;
                    gradeSchema.UpdatedDate = DateTime.Now;
                    cGradeSchema.Update(gradeSchema);
                }

                RunClientScript("Close();");
            }
        }