Пример #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (cboManv.SelectedIndex == -1 || txtSotien.Text == "")
            {
                MessageBox.Show("Bạn cần điền đầy đủ thông tin.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            var TKTU = db.TAMUNGs.ToList();

            foreach (var item in TKTU)
            {
                if (item.NGAYTU.Month == dtpNgayTU.Value.Month && item.NGAYTU.Year == dtpNgayTU.Value.Year && item.MANV == cboManv.Text)
                {
                    MessageBox.Show("Bạn đã ứng một khoản tiền trong tháng này", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
                }
            }
            TAMUNG TU = new TAMUNG();

            TU.MANV     = cboManv.Text;
            TU.NGAYTU   = dtpNgayTU.Value;
            TU.SOTIENTU = float.Parse(txtSotien.Text);
            db.TAMUNGs.Add(TU);
            db.SaveChanges();
            MessageBox.Show("Bạn đã thêm thành công.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            fmTamung_Load(sender, e);
        }
Пример #2
0
        private void btnCapnhat_Click(object sender, EventArgs e)
        {
            if (Manv == null)
            {
                MessageBox.Show("Bạn chưa chọn dữ liệu.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            TAMUNG TU = db.TAMUNGs.Find(Manv, NgayTU);

            TU.SOTIENTU = int.Parse(txtSotien.Text);
            db.SaveChanges();
            MessageBox.Show("Cập nhật dữ liệu thành công.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            fmTamung_Load(sender, e);
        }
Пример #3
0
        private void btnXoa_Click(object sender, EventArgs e)
        {
            if (Manv == null)
            {
                MessageBox.Show("Bạn chưa chọn dữ liệu.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); return;
            }
            TAMUNG TU = db.TAMUNGs.Find(Manv, NgayTU);

            db.TAMUNGs.Remove(TU);
            db.SaveChanges();
            MessageBox.Show("Xóa dữ liệu thành công.", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information);
            fmTamung_Load(sender, e);
        }