Exemplo n.º 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 CProgramCourse();
                var c  = new Erp2016.Lib.ProgramCourse();
                c.ProgramId   = Convert.ToInt32(RadComboBoxProgram.SelectedValue);
                c.IsActive    = RadButtonActive.Checked;
                c.CourseName  = RadTextBoxProgramCourse.Text;
                c.Description = RadTextBoxDescription.Text;
                c.CreatedId   = CurrentUserId;
                c.CreatedDate = DateTime.Now.Date;

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

                    if (cC.Update(c))
                    {
                        ShowMessage("'" + c.CourseName + "' is updated.");
                        Grid.Rebind();
                    }
                    else
                    {
                        ShowMessage("Failed to update");
                    }
                }
            }
        }
Exemplo n.º 2
0
 public bool Update(ProgramCourse obj)
 {
     try
     {
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
 public int Add(ProgramCourse obj)
 {
     try
     {
         _db.ProgramCourses.InsertOnSubmit(obj);
         _db.SubmitChanges();
     }
     catch (Exception ex)
     {
         Debug.Print(ex.Message);
         return(-1);
     }
     return(_db.ProgramCourses.Max(x => x.ProgramCourseId));
 }