Example #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtMaBH.Text == "" || cboManv.SelectedIndex == -1 || txtNoicap.Text == "" || txtSotien.Text == "" || txtBaohiem.Text == "")
            {
                MessageBox.Show("Bạn cần nhập đầy đủ thông tin.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            BAOHIEM TK = db.BAOHIEMs.Find(int.Parse(txtMaBH.Text));

            if (TK != null)
            {
                MessageBox.Show("Mã bảo hiểm đã được dùng.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            BAOHIEM BH = new BAOHIEM();

            BH.MASOBH     = int.Parse(txtMaBH.Text);
            BH.MANV       = cboManv.Text;
            BH.NOICAP     = txtNoicap.Text;
            BH.TENBH      = txtBaohiem.Text;
            BH.SOTIENDONG = float.Parse(txtSotien.Text);
            BH.THOIGIAN   = dtpThoiGian.Value;
            db.BAOHIEMs.Add(BH);
            db.SaveChanges();
            MessageBox.Show("Thêm thành công.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            fmBaohiem_Load(sender, e);
        }
Example #2
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (ID == null)
            {
                MessageBox.Show("Bạn cần chọn dữ liệu.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            BAOHIEM BH = db.BAOHIEMs.Find(ID);

            db.BAOHIEMs.Remove(BH);
            db.SaveChanges();
            MessageBox.Show("Xóa thành công.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            fmBaohiem_Load(sender, e);
        }