Beispiel #1
0
 private void btnOkSua_Click(object sender, EventArgs e)
 {
     if (DateTime.Compare(dtpNgaySinh.Value, DateTime.Today) < 0)
     {
         if ((txtMaDG.Text != "") && (txtTenDG.Text != "") && (txtDiaChi.Text != "") && (txtSoCMT.Text != "") && (txtMK.Text != ""))
         {
             try
             {
                 DocGia_DTO docGia = new DocGia_DTO(txtMaDG.Text, txtTenDG.Text, cboGioiTinh.SelectedItem.ToString(), dtpNgaySinh.Value, txtDiaChi.Text, txtSoCMT.Text, (string)cboLoaiDG.SelectedValue, txtMK.Text);
                 BUS_OBJ.suaDG(docGia);
                 autoSuaUser();
                 HienThiDuLieu();
             }
             catch (Exception ex)
             {
                 MetroFramework.MetroMessageBox.Show(this, ex.Message);
             }
             finally
             {
                 btnCancel_Click(sender, e);
                 //if (conn.State == ConnectionState.Open) conn.Close();
             }
         }
         else
         {
             MessageBox.Show(this, "Nhập thiếu dữ liệu.", "Lỗi.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
             if (txtMK.Text == "")
             {
                 txtMK.Focus();
             }
             if (txtSoCMT.Text == "")
             {
                 txtSoCMT.Focus();
             }
             if (txtDiaChi.Text == "")
             {
                 txtDiaChi.Focus();
             }
             if (txtTenDG.Text == "")
             {
                 txtTenDG.Focus();
             }
             //if (txtMaDG.Text == "") txtMaDG.Focus();
         }
     }
     else
     {
         MetroFramework.MetroMessageBox.Show(this, "Nhập ngày sinh sai.", "Lỗi.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }