Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (String.IsNullOrWhiteSpace(txtPrivledgeName.Text))
                {
                    errfrmPrivledgeAddUpdate.SetError(txtPrivledgeName, Constants.Messages.RequiredField);
                    txtPrivledgeName.SelectAll();
                    txtPrivledgeName.Focus();
                    return;
                }

                Status    status;
                Privledge privledge = new Privledge();
                privledge.PrivledgeId   = this.PrivledgeId;
                privledge.PrivledgeName = txtPrivledgeName.Text;
                privledge.ControlName   = txtControlName.Text;
                Enum.TryParse <Status>(cbxStatus.SelectedValue.ToString(), out status);
                privledge.Status = status == Status.Active;

                bool result = this.PrivledgeId > 0 ? applicationFacade.UpdatePrivledge(privledge) : applicationFacade.AddPrivledge(privledge);

                if (result)
                {
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }