示例#1
0
 private void bt_xoa_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa Tỉnh có mã là " + txt_ma.Text + " hay không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
     {
         BUS_Tinh.delete(txt_ma.Text);
         MessageBox.Show("Xóa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         loadFull();
     }
 }
示例#2
0
 private void bt_capnhat_Click(object sender, EventArgs e)
 {
     if (flag)
     {
         if (txt_ma.Text == "" || txt_ten.Text == "")
         {
             lb_loi.Text = "Hãy điền đầy đủ thông tin.";
         }
         else if (BUS_Tinh.KiemTra(txt_ma.Text) == "true")
         {
             lb_loi.Text = "Mã tỉnh này đã tồn tại.";
         }
         else
         {
             if (BUS_Tinh.insert(txt_ma.Text, txt_ten.Text) == "true")
             {
                 MessageBox.Show("Thêm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 loadFull();
             }
             else
             {
                 MessageBox.Show("Lỗi từ hệ thống, hãy liên hệ với bộ phận kỹ thuật.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 loadFull();
             }
         }
     }
     else
     {
         if (txt_ma.Text == "" || txt_ten.Text == "")
         {
             lb_loi.Text = "Hãy điền đầy đủ thông tin.";
         }
         else if (BUS_Tinh.KiemTra_sua(macu, txt_ma.Text) == "true")
         {
             lb_loi.Text = "Mã tỉnh này đã tồn tại.";
         }
         else
         {
             if (BUS_Tinh.update(macu, txt_ma.Text, txt_ten.Text) == "true")
             {
                 MessageBox.Show("Sửa thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 loadFull();
             }
             else
             {
                 MessageBox.Show("Lỗi từ hệ thống, hãy liên hệ với bộ phận kỹ thuật.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 loadFull();
             }
         }
     }
 }
示例#3
0
 public void loadFull()
 {
     txt_ma.Text          = txt_ten.Text = "";
     txt_ma.Enabled       = txt_ten.Enabled = false;
     grid_tinh.Enabled    = bt_them.Enabled = true;
     bt_restart.Enabled   = bt_capnhat.Enabled = false;
     lb_loi.Text          = "";
     grid_tinh.DataSource = BUS_Tinh.selectTinh();
     binding();
     if (grid_tinh.MainView.RowCount > 0)
     {
         bt_sua.Enabled = bt_xoa.Enabled = true;
     }
     else
     {
         bt_xoa.Enabled = bt_sua.Enabled = false;
     }
 }