protected void ToolbarClick(object sender, RadToolBarEventArgs e) { if (e.Item.Text == "New") { Grid.SelectedIndexes.Clear(); ResetForm(); } else if (e.Item.Text == "Save") { var cProg = new CProgramGroup(); var prog = new Erp2016.Lib.ProgramGroup(); prog.SiteId = CurrentSiteId; if (!string.IsNullOrEmpty(RadComboBoxFaculty.SelectedValue)) { prog.FacultyId = Convert.ToInt32(RadComboBoxFaculty.SelectedValue); } prog.IsActive = RadButtonActive.Checked; prog.Name = tbProgram.Text; prog.Description = tbDescript.Text; prog.CreatedId = CurrentUserId; prog.CreatedDate = DateTime.Now.Date; if (cProg.Add(prog) > 0) { ShowMessage("'" + prog.Name + "' is added."); Grid.Rebind(); } else { ShowMessage("Failed to add"); } } else if (e.Item.Text == "Update") { if (Grid.SelectedValue != null) { var cProg = new CProgramGroup(); var prog = cProg.Get(Convert.ToInt32(Grid.SelectedValue)); if (RadComboBoxFaculty.SelectedValue != null) { prog.FacultyId = Convert.ToInt32(RadComboBoxFaculty.SelectedValue); } prog.Name = tbProgram.Text; prog.IsActive = RadButtonActive.Checked; prog.Description = tbDescript.Text; prog.UpdatedId = CurrentUserId; prog.UpdatedDate = DateTime.Now; if (cProg.Update(prog)) { ShowMessage("'" + prog.Name + "' is updated."); Grid.Rebind(); } else { ShowMessage("Failed to update"); } } } }
protected void GetProgram() { ResetForm(); if (Grid.SelectedValue != null) { var cProg = new CProgramGroup(); var prog = cProg.Get(Convert.ToInt32(Grid.SelectedValue)); RadComboBoxFaculty.SelectedValue = prog.FacultyId.ToString(); tbProgram.Text = prog.Name; tbDescript.Text = prog.Description; RadButtonActive.Checked = prog.IsActive; RadToolBarProgramGroup.FindItemByText("New").Enabled = true; if (RadToolBarProgramGroup.FindItemByText("Save") != null) { RadToolBarProgramGroup.FindItemByText("Save").Text = "Update"; } } }