Пример #1
0
        private void btnXacnhanThanhtoan_Click(object sender, EventArgs e)
        {
            int      phonghatID = (int)dgvPhonghat.CurrentRow.Cells["ID"].Value;
            Hoadon   hoadon     = db.Hoadons.Where(x => x.PhonghatID == phonghatID).OrderByDescending(x => x.ID).FirstOrDefault();
            Phonghat phonghat   = db.Phonghats.FirstOrDefault(x => x.ID == phonghatID);

            var tienphong = Convert.ToInt32(txtTienphong.Text);

            hoadon.Tienphong = tienphong;

            var tiendoan = 0;

            foreach (var cthd in hoadon.ChitietHoadons)
            {
                var soluong       = cthd.Soluong;
                var dongia        = cthd.Product.Dongia;
                var sotienphaitra = Convert.ToInt32(soluong * dongia);
                tiendoan += sotienphaitra;
            }
            hoadon.Thanhtien = tiendoan + tienphong;

            phonghat.IsReserved = false;
            phonghat.Trangthai  = true;

            showGroupThanhtoan(false);

            db.SaveChanges();
            reload();

            reportHoadonThanhtoan.hoadonID = hoadon.ID;
            reportHoadonThanhtoan rp = new reportHoadonThanhtoan();

            rp.Show();
        }
Пример #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            Phonghat phonghat = new Phonghat();

            phonghat.TenPhong = txtTenphong.Text;
            phonghat.Size     = Convert.ToInt32(txtSonguoi.Text);
            phonghat.Dongia   = Convert.ToInt32(txtDongia.Text);

            db.Phonghats.Add(phonghat);
            reload();
        }
Пример #3
0
        private void btnXacnhan_Click(object sender, EventArgs e)
        {
            cbbKhachhang.Visible = false;
            btnChon.Visible      = false;
            label2.Visible       = false;
            lbLoaiphong.Visible  = false;
            cbbLoaiphong.Visible = false;

            int khachhangID = (int)cbbKhachhang.SelectedValue;
            int phongID     = (int)dgvPhonghat.CurrentRow.Cells["ID"].Value;

            //Dat truoc
            if (button1.Enabled == false)
            {
                button1.Enabled = true;

                Phonghat phonghat = db.Phonghats.FirstOrDefault(x => x.ID == phongID);
                phonghat.IsReserved    = true;
                phonghat.IsReserverdBy = khachhangID;
                phonghat.Trangthai     = false;

                db.SaveChanges();
                reload();
            }

            //sudung
            if (button2.Enabled == false)
            {
                Hoadon hoadon = new Hoadon();
                hoadon.NhanvienID     = nhanvienID;
                hoadon.KhachhangID    = khachhangID;
                hoadon.PhonghatID     = phongID;
                hoadon.LoaiPhong      = Convert.ToBoolean(cbbLoaiphong.SelectedIndex);
                hoadon.ThoigianBatdau = DateTime.Now;

                Phonghat phonghat = db.Phonghats.FirstOrDefault(x => x.ID == phongID);
                phonghat.Trangthai     = false;
                phonghat.IsReserved    = false;
                phonghat.IsReserverdBy = null;

                db.Hoadons.Add(hoadon);
                db.SaveChanges();
                reload();

                button2.Enabled = true;
            }
        }
Пример #4
0
        private void btnThanhtoan_Click(object sender, EventArgs e)
        {
            int      phonghatID = (int)dgvPhonghat.CurrentRow.Cells["ID"].Value;
            Hoadon   hoadon     = db.Hoadons.Where(x => x.PhonghatID == phonghatID).OrderByDescending(x => x.ID).FirstOrDefault();
            Phonghat phonghat   = db.Phonghats.FirstOrDefault(x => x.ID == phonghatID);

            showGroupThanhtoan(true);

            //thanh toán
            double tienphong = 0;

            if ((bool)hoadon.LoaiPhong)
            {
                var hours = (DateTime.Now - hoadon.ThoigianBatdau).Value.TotalHours;
                tienphong         = (double)phonghat.Dongia * hours;
                txtTienphong.Text = Convert.ToInt32((Math.Round(tienphong / 1000) * 1000)).ToString();
            }
        }