示例#1
0
 /// <summary>
 /// Saves disposal info
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnDisposalSave_Click(object sender, EventArgs e)
 {
     if (txtReasons.Text != "")
     {
         DisposalReasons reason = new DisposalReasons();
         if (_disposalReasonId != 0)
         {
             reason.LoadByPrimaryKey(_disposalReasonId);
         }
         else
         {
             reason.AddNew();
         }
         reason.Reason      = txtReasons.Text.Trim();
         reason.Description = txtDisposalDescription.Text;
         reason.Save();
         reason.LoadAll();
         PopulateDisposalReason(reason);
         ResetDisposalForm();
     }
     else
     {
         txtReasons.BackColor = Color.FromArgb(251, 214, 214);
     }
 }
示例#2
0
        /// <summary>
        /// Handles the gridViewReason focused node changed and updates the form accordingly
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void gridViewReason_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            DataRow dr = gridViewReason.GetFocusedDataRow();

            if (dr != null)
            {
                DisposalReasons reason   = new DisposalReasons();
                int             reasonId = Convert.ToInt32(dr["ID"]);
                reason.LoadByPrimaryKey(reasonId);
                txtReasons.Text             = reason.Reason;
                txtDisposalDescription.Text = reason.Description;
                _disposalReasonId           = reason.ID;
                btnDisposalSave.Text        = "Update";
            }
        }