Exemple #1
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtViPham.EditValue == null)
            {
                MessageBox.Show("Vi phạm không hợp lê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtViPham, "Hãy chọn lại vi phạm");
                txtViPham.Focus();
                return;
            }
            HoSoViPham hs = new HoSoViPham();

            hs.MaHSViPham = txtMaHS.Text;
            hs.NgayLap    = Commons.ConvertStringToDate(txtNgayLap.Text);
            hs.TinhTrang  = 0;
            if (txtTongTien.Text.Length > 0)
            {
                hs.TongTienPhat = int.Parse(txtTongTien.Text);
            }
            else
            {
                hs.TongTienPhat = 0;
            }
            hs.GhiChu     = txtGhichu.Text;
            hs.MaViPham   = txtViPham.EditValue.ToString();
            hs.MaThueMB   = maTMB;
            hs.MaNhanVien = maNV;
            if (vp.ThemHSViPham(hs))
            {
                MessageBox.Show("Thêm vi phạm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                maVP = txtMaHS.EditValue.ToString();
                this.Close();
            }
        }
        private void btnLuu_ItemClick(object sender, ItemClickEventArgs e)
        {
            errorProvider1.Clear();
            if (txtMaThue.EditValue == null)
            {
                MessageBox.Show("Mã thuê không hợp lệ", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtMaThue, "Hãy chọn lại mã thuê");
                txtMaThue.Focus();
                return;
            }
            if (txtViPham.EditValue == null)
            {
                MessageBox.Show("Vi phạm không hợp lê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                errorProvider1.SetError(txtViPham, "Hãy chọn lại vi phạm");
                txtViPham.Focus();
                return;
            }
            HoSoViPham hs = new HoSoViPham();

            hs.MaHSViPham = txtMaHS.Text;
            hs.NgayLap    = DateTime.Now;
            if (cboTinhTrang.Text == "Chưa đóng")
            {
                hs.TinhTrang = 0;
            }
            else
            {
                hs.TinhTrang = 1;
            }
            if (txtTienPhat.Text.Length > 0)
            {
                string tien     = txtTienPhat.Text.ToString().Remove(txtTienPhat.Text.Length - 4);
                int    tongtien = int.Parse(tien.Replace(",", ""));
                hs.TongTienPhat = tongtien;
            }
            else
            {
                hs.TongTienPhat = 0;
            }
            hs.GhiChu     = txtGhiChu.Text;
            hs.MaViPham   = txtViPham.EditValue.ToString();
            hs.MaThueMB   = txtMaThue.Text;
            hs.MaNhanVien = maNV;
            if (vp.ThemHSViPham(hs))
            {
                MessageBox.Show("Thêm vi phạm thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Click_BtnLuu();
                dgvDSViPham.Focus();
                dgvDSViPham_FocusedRowChanged(null, null);
                cboTinhTrang.ReadOnly = true;
                LoadDSHoSoViPham();
                LoadAllMaThue();
            }
        }
Exemple #3
0
        public string LayMaXuLyTuSinh()
        {
            string     result = "AEON_SLVP0001";
            HoSoViPham lh     = db.HoSoViPhams.Where(x => x.MaHSViPham.Contains($"AEON_SLVP"))
                                .OrderByDescending(x => x.MaHSViPham).FirstOrDefault();

            if (lh != null && !string.IsNullOrWhiteSpace(lh.MaHSViPham))
            {
                int so = Convert.ToInt32(lh.MaHSViPham.Replace("AEON_SLVP", "")) + 1;
                result = "AEON_SLVP" + so.ToString().PadLeft(4, '0');
            }
            return(result);
        }
Exemple #4
0
        public bool XoaViPhamn(string maViPham)
        {
            try
            {
                HoSoViPham nv = db.HoSoViPhams.Where(x => x.MaHSViPham.Equals(maViPham)).FirstOrDefault();
                db.HoSoViPhams.DeleteOnSubmit(nv);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Exemple #5
0
        public bool SuaHSViPham(HoSoViPham hs)
        {
            try
            {
                HoSoViPham hoSoViPham = db.HoSoViPhams.Where(t => t.MaHSViPham == hs.MaHSViPham).FirstOrDefault();
                hoSoViPham = hs;
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Exemple #6
0
        public bool ThemHSViPham(HoSoViPham hs)
        {
            try
            {
                HoSoViPham hoSoViPham = new HoSoViPham();
                hoSoViPham = hs;
                db.HoSoViPhams.InsertOnSubmit(hoSoViPham);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Exemple #7
0
        public HoSoViPham LayThongTinHoSoVP(string ma)
        {
            HoSoViPham hs = db.HoSoViPhams.Where(t => t.MaHSViPham.Equals(ma)).Select(t => t).FirstOrDefault();

            return(hs);
        }
 public bool SuaHSViPham(HoSoViPham hs)
 {
     return(vp.SuaHSViPham(hs));
 }
 public bool ThemHSViPham(HoSoViPham hs)
 {
     return(vp.ThemHSViPham(hs));
 }