Example #1
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtiddmuc.Text == "" && txttendmuc.Text == "")
         {
             XtraMessageBox.Show("Bạn phải nhập đầy đủ thông tin!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             ClearDisplay();
             return;
         }
         if (txtiddmuc.Text == "" && txttendmuc.Text == "")
         {
             XtraMessageBox.Show("Bạn chưa nhập tên danh mục!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             ClearDisplay();
             return;
         }
         int.TryParse(txtiddmuc.Text, out int txtiddmuca);
         var model = new DANHMUC_ViewModel
         {
             iddmuc   = txtiddmuca,
             tendmuc  = txttendmuc.Text,
             CreateBy = Properties.Settings.Default.NameLog,
             ModifyBy = Properties.Settings.Default.NameLog
         };
         var msg = new DANHMUCBll().AddDANHMUC(model);
         if (msg != null && msg != "")
         {
             LoadGrid();
             XtraMessageBox.Show(msg, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             ClearDisplay();
             return;
         }
         XtraMessageBox.Show(msg, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
         ClearDisplay();
         return;
     }
     catch
     {
         XtraMessageBox.Show("", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return;
     }
 }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            var result = XtraMessageBox.Show("Bạn có chắc chắn muốn xóa?", "Xác nhận", MessageBoxButtons.YesNo);

            if (result == DialogResult.Yes)
            {
                if (txtidncc.Text == "")
                {
                    XtraMessageBox.Show("Bạn phải chọn danh mục cần xóa !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    ClearDisplay();
                    return;
                }
                int.TryParse(txtidncc.Text, out int txtiddmuca);
                var msg = new DANHMUCBll().DeleteDANHMUC(txtiddmuca);
                LoadGrid();
                XtraMessageBox.Show(msg, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                ClearDisplay();
                return;
            }
        }