コード例 #1
0
ファイル: usrHoaDon.cs プロジェクト: WendyAnne/Hotel-software
 private void btnDongY_Click(object sender, EventArgs e)
 {
     if (hd == 1)
     {
         if (MessageBox.Show("Bạn có chắc là muốn xóa hóa đơn này chứ ?") == DialogResult.OK)
         {
             BUS.BUSCTCHIETKHAU _CTCK = new BUS.BUSCTCHIETKHAU();
             foreach (DTO.DTOCTCHIETKHAU _ck in _CTCK.LayTatCaCTCHIETKHAU().Where(a => a.MAHD == LayHoaDon().MAHD))
             {
                 _CTCK.XoaCTCHIETKHAU(_ck.MACK,_ck.MAHD);
             }
             BUS.BUSCTPHUTHU _CTPT = new BUS.BUSCTPHUTHU();
             foreach (DTO.DTOCTPHUTHU _pt in _CTPT.LayTatCaCTPHUTHU().Where(a => a.MAHD == LayHoaDon().MAHD))
             {
                 _CTPT.XoaCTPHUTHU(_pt.MAPT, _pt.MAHD);
             }
             HoaDon.XoaHOADON(LayHoaDon().MAHD);
             LoadHoaDon();
             BUS.BUSPHIEUNHANPHONG _np = new BUS.BUSPHIEUNHANPHONG();
             DTO.DTOPHIEUNHANPHONG _dtonp=_np.LayTheoMaPHIEUNHANPHONG(LayHoaDon().MAPHIEU)[0];
             _dtonp.THANHTOAN = false;
             _np.CapnhatPHIEUNHANPHONG(_dtonp);
             DTO.DTOCheckData _cdHoadon = checkdata.LayTheoMaCheckData("PHIEUNHANPHONG").Last();
             _cdHoadon.Version += 1;
             checkdata.CapnhatCheckData(_cdHoadon);
             btnXoaHD.Visible = true;
             btnDongY.Visible = false;
             btnHuy.Visible = false;
             hd = 0;
         }
     }
 }
コード例 #2
0
        private void btnThanhToan_Click_1(object sender, EventArgs e)
        {
            if (dtoPhieuNhanPhong.Count == busPhieuNhanPhong.LayTatCaPHIEUNHANPHONG().Count)
            {
                if (txtTienNhan.Text.Trim() != "")
                {
                    btnThanhToan.Enabled = false;
                    txtTienThua.Text = (int.Parse(txtTienNhan.Text) - int.Parse(txtTongTien.Text)).ToString();
                    if ((int.Parse(txtTienNhan.Text) - int.Parse(txtTongTien.Text) > 0))
                    {
                        busHoaDon = new BUS.BUSHOADON();
                        DTO.DTOHOADON dtoHoadon = new DTO.DTOHOADON();
                        dtoHoadon.MAHD = MaHD;
                        dtoHoadon.MANV = clsXuLy.MANV;
                        dtoHoadon.MAPHIEU = MaPhieu;
                        dtoHoadon.NGAYHD = DateTime.Now;
                        dtoHoadon.TONGTIEN = int.Parse(txtTongTien.Text);
                        busHoaDon.ThemHOADON(dtoHoadon);
                        BUS.BUSCTCHIETKHAU _busCTCK = new BUS.BUSCTCHIETKHAU();
                        int _mahd = busHoaDon.LayTatCaHOADON().OrderBy(a => a.MAHD).Last().MAHD;

                        #region Them 1 CTCHIETKHAU trong
                        var _dtoCTCK = new DTO.DTOCTCHIETKHAU();
                        _dtoCTCK.MACK = 23;
                        _dtoCTCK.MAHD = _mahd;
                        _dtoCTCK.PHANTRAMCK = 0;
                        _busCTCK.ThemCTCHIETKHAU(_dtoCTCK);
                        #endregion

                        foreach (DataGridViewRow _row in grdCK.Rows)
                        {
                            if (_row.Cells[3].Value != null && (bool)_row.Cells[3].Value == true)
                            {
                                DTO.DTOCTCHIETKHAU _ck = new DTO.DTOCTCHIETKHAU();
                                _ck.MACK = Convert.ToInt32(_row.Cells[0].Value);
                                _ck.MAHD = _mahd;
                                _ck.PHANTRAMCK = Convert.ToInt32(_row.Cells[2].Value);

                                _busCTCK.ThemCTCHIETKHAU(_ck);
                            }
                        }
                        BUS.BUSCTPHUTHU _CTPT = new BUS.BUSCTPHUTHU();

                        #region Them 1 CTPT trong
                        var _dtoPT = new DTO.DTOCTPHUTHU();
                        _dtoPT.MAPT = 15;
                        _dtoPT.MAHD = _mahd;
                        _dtoPT.PHANTRAMPT = 0;
                        _CTPT.ThemCTPHUTHU(_dtoPT);
                        #endregion

                        foreach (DataGridViewRow _row in grdPT.Rows)
                        {
                            if (_row.Cells[3].Value != null && (bool)_row.Cells[3].Value == true)
                            {
                                DTO.DTOCTPHUTHU _pt = new DTO.DTOCTPHUTHU();
                                _pt.MAPT = Convert.ToInt32(_row.Cells[0].Value);
                                _pt.MAHD = _mahd;
                                _pt.PHANTRAMPT = Convert.ToInt32(_row.Cells[2].Value);
                                _CTPT.ThemCTPHUTHU(_pt);
                            }

                        }
                        DTO.DTOPHIEUNHANPHONG _dtoPhieuNhanPhong = new DTO.DTOPHIEUNHANPHONG();
                        _dtoPhieuNhanPhong.MAPHIEU = Convert.ToInt32(lblMaPhieu.Text);
                        _dtoPhieuNhanPhong.MAPHONG = Convert.ToInt32(glkPhong.Text);
                        _dtoPhieuNhanPhong.MANV = clsXuLy.MANV;
                        _dtoPhieuNhanPhong.MAKH = int.Parse(txtMaKH.Text);
                        _dtoPhieuNhanPhong.GIOTRA = DateTime.Now;
                        _dtoPhieuNhanPhong.GIONHAN = dtpNgayNhan.Value;
                        _dtoPhieuNhanPhong.GIAPHONG = int.Parse(lblGia.Text);
                        _dtoPhieuNhanPhong.THANHTOAN = true;
                        busPhieuNhanPhong.CapnhatPHIEUNHANPHONG(_dtoPhieuNhanPhong);
                        DTO.DTOCheckData _cdnp = checkdata.LayTheoMaCheckData("PHIEUNHANPHONG").Last();
                        _cdnp.Version += 1;
                        checkdata.CapnhatCheckData(_cdnp);
                        btnHoaDon_Click(sender, e);
                        btnMakeNew_Click(sender, e);
                    }
                    else
                    {
                        MessageBox.Show("Số tiền nhận ít hơn tổng tiền.", "Chú ý!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        btnThanhToan.Enabled = true;
                    }
                }
                else
                    MessageBox.Show("Bạn cần nhập số tiền nhận.", "Lưu ý!");
            }
            else
            {
                MessageBox.Show("Dữ liệu đã thay đổi, xin refresh lại!");
            }
        }
コード例 #3
0
ファイル: usrHoaDon.cs プロジェクト: WendyAnne/Hotel-software
        private void gridViewHoaDon_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
        {
            if (txtMaHD.Text.Trim() == "") return;
            BUS.BUSCHIETKHAU _ChietKhau = new BUS.BUSCHIETKHAU();
            BUS.BUSPHUTHU _PhuThu = new BUS.BUSPHUTHU();
            BUS.BUSCTCHIETKHAU _CTCK = new BUS.BUSCTCHIETKHAU();
            BUS.BUSCTPHUTHU _CTPT = new BUS.BUSCTPHUTHU();
            BUS.BUSDICHVU _DichVu = new BUS.BUSDICHVU();
            BUS.BUSCHITIETDV _CTDV = new BUS.BUSCHITIETDV();

            var _ctck = from a in _ChietKhau.LayTatCaCHIETKHAU()
                        join b in _CTCK.LayTatCaCTCHIETKHAU() on a.MACK equals b.MACK
                        where b.MAHD == Convert.ToInt32(txtMaHD.Text)
                        select new
                        {
                            MACK = a.MACK,
                            TENCK = a.TENCK,
                            PHANTRAMCK = b.PHANTRAMCK
                        };
            grdCK.DataSource = _ctck.Where(a => a.MACK != 23).ToList(); ;
            var _ctpt = from a in _PhuThu.LayTatCaPHUTHU()
                        join b in _CTPT.LayTatCaCTPHUTHU() on a.MAPT equals b.MAPT
                        where b.MAHD == Convert.ToInt32(txtMaHD.Text)
                        select new
                        {
                            MAPT = a.MAPT,
                            TENPT = a.TENPT,
                            PHANTRAMPT = b.PHANTRAMPT
                        };
            grdPT.DataSource = _ctpt.Where(a => a.MAPT != 15).ToList();
            var _ctdv = from a in _DichVu.LayTatCaDICHVU()
                        join b in _CTDV.LayTatCaCHITIETDV() on a.MADV equals b.MADV
                        where b.MAPHIEU == Convert.ToInt32(cmbMaPhieu.SelectedValue)
                        select new
                        {
                            MADV = a.MADV,
                            TENDV = a.TENDV,
                            NGAYTHUE = b.NGAYTHUE,
                            SOLUONGDV = b.SOLUONGDV,
                            GIADV = b.GIADV
                        };
            grdDV.DataSource = _ctdv;
        }