Ejemplo 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");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected void GetProgramCourse()
        {
            ResetForm();
            if (Grid.SelectedValue != null)
            {
                var cP = new CProgramCourse();
                var c  = cP.Get(Convert.ToInt32(Grid.SelectedValue));
                if (c != null)
                {
                    var cProgram = new CProgram();
                    var program  = cProgram.Get(c.ProgramId);

                    if (program != null)
                    {
                        if (program.ProgramGroupId != null)
                        {
                            var programGroup = new CProgramGroup().Get(Convert.ToInt32(program.ProgramGroupId));
                            if (programGroup != null)
                            {
                                RadComboBoxFaculty.SelectedValue = programGroup.FacultyId.ToString();
                                LoadProgramGroup(RadComboBoxFaculty.SelectedValue);
                            }
                            RadComboBoxProgramGroup.SelectedValue = program.ProgramGroupId.ToString();
                            LoadProgram(RadComboBoxProgramGroup.SelectedValue);
                        }
                        RadComboBoxProgram.SelectedValue = program.ProgramId.ToString();
                        RadTextBoxProgramCourse.Text     = c.CourseName;
                    }
                    RadTextBoxDescription.Text = c.Description;
                    RadButtonActive.Checked    = c.IsActive;
                }

                RadToolBarProgramGroup.FindItemByText("New").Enabled = true;
                if (RadToolBarProgramGroup.FindItemByText("Save") != null)
                {
                    RadToolBarProgramGroup.FindItemByText("Save").Text = "Update";
                }
            }
        }