/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnProgramSave_Click(object sender, EventArgs e) { if (txtProgram.Text != "") { Programs prog = new Programs(); if (_programId != 0) prog.LoadByPrimaryKey(_programId); else prog.AddNew(); prog.Name = txtProgram.Text; prog.Description = txtProgramDescription.Text; prog.ParentID = cboProgram.Visible ? Convert.ToInt32(cboProgram.SelectedValue) : 0; prog.Save(); PopulatePrograms(); ResetProgram(); } else { txtProgram.BackColor = Color.FromArgb(251, 214, 214); } }
/// <summary> /// Handles the TreeProgram focused node changed and updates the form accordingly /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TreeProgram_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e) { int selected = Convert.ToInt32(TreeProgram.Selection[0]["ID"]); Programs prog = new Programs(); prog.LoadByPrimaryKey(selected); if (prog.ParentID != 0) { cboProgram.SelectedValue = prog.ParentID.ToString(); //lblProgram.Text = "Sub Program"; cboProgram.Visible = true; //lbPro.Visible = true; } else { cboProgram.SelectedValue = prog.ID.ToString(); cboProgram.Visible = false; //lbPro.Visible = false; //lblProgram.Text = "Program"; } txtProgram.Text = prog.Name; txtProgramDescription.Text = prog.Description; _programId = prog.ID; }