Beispiel #1
0
        protected void ToolbarClick(object sender, RadToolBarEventArgs e)
        {
            if (e.Item.Text == "New")
            {
                Grid.SelectedIndexes.Clear();
                ResetForm();
            }
            else if (e.Item.Text == "Save")
            {
                var cC = new CProgramCourseLevel();
                var c  = new Erp2016.Lib.ProgramCourseLevel();
                c.ProgramCourseId = Convert.ToInt32(RadComboBoxProgramCourse.SelectedValue);
                c.IsActive        = RadButtonActive.Checked;
                c.Level           = RadTextBoxProgramCourseLevel.Text;
                c.Description     = RadTextBoxDescription.Text;
                c.CreatedId       = CurrentUserId;
                c.CreatedDate     = DateTime.Now.Date;

                if (cC.Add(c) > 0)
                {
                    ShowMessage("'" + c.Level + "' is added.");
                    Grid.Rebind();
                }
                else
                {
                    ShowMessage("Failed to add");
                }
            }
            else if (e.Item.Text == "Update")
            {
                if (Grid.SelectedValue != null)
                {
                    var cC = new CProgramCourseLevel();
                    var c  = cC.Get(Convert.ToInt32(Grid.SelectedValue));
                    c.ProgramCourseId = Convert.ToInt32(RadComboBoxProgramCourse.SelectedValue);
                    c.IsActive        = true;
                    c.Level           = RadTextBoxProgramCourseLevel.Text;
                    c.Description     = RadTextBoxDescription.Text;
                    c.IsActive        = RadButtonActive.Checked;
                    c.UpdatedId       = CurrentUserId;
                    c.UpdatedDate     = DateTime.Now;

                    if (cC.Update(c))
                    {
                        ShowMessage("'" + c.Level + "' is updated.");
                        Grid.Rebind();
                    }
                    else
                    {
                        ShowMessage("Failed to update");
                    }
                }
            }
        }
Beispiel #2
0
 public bool Update(ProgramCourseLevel obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
Beispiel #3
0
 public int Add(ProgramCourseLevel obj)
 {
     try
     {
         _db.ProgramCourseLevels.InsertOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(-1);
     }
     return(_db.ProgramCourseLevels.Max(x => x.ProgramCourseLevelId));
 }