Esempio n. 1
0
        public bool XoaCTHoaDonDichVu(string maHD)
        {
            try
            {
                CT_DichVu hd = db.CT_DichVus.Where(t => t.MaPhieuDV.Equals(maHD)).FirstOrDefault();
                db.CT_DichVus.DeleteOnSubmit(hd);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Esempio n. 2
0
        public bool SuaCTHoaDonDichVu(CT_DichVu ct)
        {
            try
            {
                CT_DichVu pdv = db.CT_DichVus.Where(t => t.MaPhieuDV.Equals(ct.MaPhieuDV) && t.MaDichVu.Equals(ct.MaDichVu)).FirstOrDefault();
                pdv.ChiSoMoi = ct.ChiSoMoi;
                db.CT_DichVus.InsertOnSubmit(pdv);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
Esempio n. 3
0
        public bool ThemCTHoaDonDichVu(CT_DichVu dv)
        {
            try
            {
                CT_DichVu pdv = new CT_DichVu();
                pdv = dv;
                db.CT_DichVus.InsertOnSubmit(pdv);
                db.SubmitChanges();
                return(true);
            }
            catch (Exception)
            {
                return(false);

                throw;
            }
        }
 public bool SuaCTHoaDonDichVu(CT_DichVu tt)
 {
     return(dkThue.SuaCTHoaDonDichVu(tt));
 }
 public bool ThemCTHoaDonDichVu(CT_DichVu dv)
 {
     return(dkThue.ThemCTHoaDonDichVu(dv));
 }
        private void btnLuu_ItemClick(object sender, ItemClickEventArgs e)
        {
            if (txtMaDK.EditValue == null)
            {
                MessageBox.Show("Hãy chọn mã thuê", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtMaDK.Focus();
                return;
            }
            if (string.IsNullOrEmpty(cboTrangThai.Text))
            {
                MessageBox.Show("Hãy chọn trạng thái", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                cboTrangThai.Focus();
                return;
            }
            if (txtSoDienCu.Text == txtSoDienMoi.Text && txtSoNuocMoi.Text == txtSoNuocCu.Text)
            {
                MessageBox.Show("Hãy chọn số điện nước", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtSoDienMoi.Focus();
                return;
            }

            if (check)
            {
                try
                {
                    PhieuDichVu pdv = new PhieuDichVu();
                    pdv.MaPhieuDV     = txtHoaDon.EditValue.ToString();
                    pdv.NgayLap       = Commons.ConvertStringToDate(txtNgayLap.Text);
                    pdv.NgayThanhToan = Commons.ConvertStringToDate(txtNgayLap.Text);
                    pdv.TongTien      = tongTien;
                    if (cboTrangThai.SelectedIndex == 1)
                    {
                        pdv.TinhTrang = 1;
                    }
                    else
                    {
                        pdv.TinhTrang = 0;
                    }
                    pdv.MaThueMB   = txtMaDK.EditValue.ToString();
                    pdv.MaNhanVien = maNV;
                    CT_DichVu ctdvDien = new CT_DichVu();
                    ctdvDien.MaPhieuDV = txtHoaDon.EditValue.ToString();
                    ctdvDien.MaDichVu  = "AEON_MDV0001";
                    ctdvDien.ChiSoMoi  = int.Parse(txtSoDienMoi.EditValue.ToString());
                    ctdvDien.ChiSoCu   = int.Parse(txtSoDienCu.EditValue.ToString());
                    ctdvDien.Gia       = thueMB.LayGiaDien();
                    CT_DichVu ctdvNuoc = new CT_DichVu();
                    ctdvNuoc.MaPhieuDV = txtHoaDon.EditValue.ToString();
                    ctdvNuoc.MaDichVu  = "AEON_MDV0002";
                    ctdvNuoc.ChiSoMoi  = int.Parse(txtSoNuocMoi.EditValue.ToString());
                    ctdvNuoc.ChiSoCu   = int.Parse(txtSoNuocCu.EditValue.ToString());
                    ctdvNuoc.Gia       = thueMB.LayGiaNuoc();
                    bool keys = true;
                    if (!thueMB.ThemHoaDonDichVu(pdv))
                    {
                        keys = false;
                        thueMB.XoaHoaDonDichVu(pdv.MaPhieuDV);
                    }
                    if (!thueMB.ThemCTHoaDonDichVu(ctdvDien) || !thueMB.ThemCTHoaDonDichVu(ctdvNuoc))
                    {
                        keys = false;
                        thueMB.XoaCTHoaDonDichVu(pdv.MaPhieuDV);
                    }
                    if (keys)
                    {
                        DialogResult r = MessageBox.Show("Thêm hóa đơn thành công, bạn có muốn in hóa đơn không", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);

                        DAL.ThongBao tt = new DAL.ThongBao();
                        tt.NgayTao   = Commons.ConvertStringToDate(txtNgayLap.Text);
                        tt.TaiKhoan  = pdv.ThueMatBang.DangKyThue.KhachHang.SDT;
                        tt.MaLoaiTT  = 1;
                        tt.TrangThai = 1;
                        tt.NoiDung   = string.Format(QL_MatBang.NOIDUNGTHONGBAO, (DateTime.Now).Month + "/" + (DateTime.Now).Year);
                        tt.TieuDe    = QL_MatBang.TIEUDETHONGBAO;
                        thueMB.ThemThongBaoDichVu(tt);
                        if (thueMB.KiemTraToken(dgvDSHoaDon.GetFocusedRowCellDisplayText(colKhachHang)))
                        {
                            Root                    root         = new Root();
                            Notification            notification = new Notification();
                            NotificationForCustomer thongbao     = new NotificationForCustomer();
                            root.to                      = thueMB.LayToken(dgvDSHoaDon.GetFocusedRowCellDisplayText(colKhachHang));
                            notification.title           = tt.TieuDe;
                            notification.body            = tt.NoiDung;
                            notification.mutable_content = "True";
                            notification.sound           = "Tri-tone";
                            root.notification            = notification;
                            thongbao.ThongBaoChoKhachHang(root);
                        }


                        if (r == DialogResult.Yes)
                        {
                            PhieuDichVu p = new PhieuDichVu();
                            p = thueMB.LayThongTinPhieuDV(txtHoaDon.EditValue.ToString());
                            List <CT_DichVu> c = new List <CT_DichVu>();
                            c = thueMB.LayThongTinCT_DichVu2(txtHoaDon.EditValue.ToString());
                            InHoaDon(p, c);
                        }
                    }
                    Click_BtnLuu();
                    LoadDSHoaDon();
                    LoadCboMaThue();
                    LoadCboAllMaThue();
                    dgvDSHoaDon_FocusedRowChanged(null, null);
                }
                catch (Exception)
                {
                    MessageBox.Show("Đã có lỗi xẩy ra", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    throw;
                }
            }
            else
            {
                PhieuDichVu pdv = new PhieuDichVu();
                pdv.TongTien = tongTien;
                if (cboTrangThai.SelectedIndex == 1)
                {
                    pdv.TinhTrang = 1;
                }
                else
                {
                    pdv.TinhTrang = 0;
                }
                var ctdvd = thueMB.LayThongTinCT_DichVu(txtMaDK.EditValue.ToString(), "AEON_MDV0001");
                var ctdvm = thueMB.LayThongTinCT_DichVu(txtMaDK.EditValue.ToString(), "AEON_MDV0002");



                if (!thueMB.SuaHoaDonDichVu(pdv))
                {
                    MessageBox.Show("Đã có lỗi xẩy ra không thể sửa hóa đơn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                if (!ctdvd.ChiSoMoi.ToString().Equals(txtSoDienMoi.EditValue))
                {
                    CT_DichVu ctdvDien = new CT_DichVu();
                    ctdvd.MaPhieuDV   = txtHoaDon.EditValue.ToString();
                    ctdvDien.MaDichVu = "AEON_MDV0001";
                    ctdvDien.ChiSoMoi = int.Parse(txtSoDienMoi.EditValue.ToString());
                    if (!thueMB.SuaCTHoaDonDichVu(ctdvDien))
                    {
                        MessageBox.Show("Đã có lỗi xẩy ra không thể sửa hóa đơn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                if (!ctdvm.ChiSoMoi.ToString().Equals(txtSoNuocMoi.EditValue))
                {
                    CT_DichVu ctdvNuoc = new CT_DichVu();
                    ctdvd.MaPhieuDV   = txtHoaDon.EditValue.ToString();
                    ctdvNuoc.MaDichVu = "AEON_MDV0002";
                    ctdvNuoc.ChiSoMoi = int.Parse(txtSoDienMoi.EditValue.ToString());
                    if (!thueMB.SuaCTHoaDonDichVu(ctdvNuoc))
                    {
                        MessageBox.Show("Đã có lỗi xẩy ra không thể sửa hóa đơn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }
                }
                MessageBox.Show("Sửa thành công hóa đơn dịch vụ :" + txtHoaDon.EditValue, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Click_BtnLuu();
                LoadDSHoaDon();
                LoadCboMaThue();
                LoadCboAllMaThue();
                dgvDSHoaDon_FocusedRowChanged(null, null);
            }
        }