Exemplo n.º 1
0
        public void CapNhatChiTietHoaDon(Chitiet_HoaDonThanhToan ct)
        {
            var query =
                from cthd in dbContext.Chitiet_HoaDonThanhToans
                where
                cthd.id_hoadon == ct.id_hoadon &&
                cthd.id_mon == ct.id_mon
                select cthd;

            foreach (var cthd in query)
            {
                cthd.soluong   += ct.soluong;
                cthd.dongia     = ct.dongia;
                cthd.thanhtien += ct.thanhtien;
            }
            dbContext.SubmitChanges();
        }
Exemplo n.º 2
0
        //public int Layidkhachhang(int iddatban)
        //{
        //    int idkh = 0;
        //    var query = from hd in dbContext.DatBans
        //                where hd.id_datban == iddatban
        //                select hd;
        //    foreach (var i in query)
        //    {
        //        i.id_khachhang = idkh;
        //    }
        //    return idkh;
        //}
        //public void ChuyenKhachHang(int iddatban, HoaDonThanhToan m)
        //{
        //    int idkh = Layidkhachhang(iddatban);
        //}


        public void ChuyenChiTietDatBan(int idban, DateTime today, int idhoadon, List <string> ttdatban)
        {
            int?iddatban      = 0;
            var chitietdatban = from ct in dbContext.Chitiet_DatBans
                                where
                                ct.DatBan.id_ban == idban &&
                                ct.DatBan.thoigian == today &&
                                ct.DatBan.trangthai == ttdatban[0]
                                select new
            {
                ct.id_datban,
                ct.id_mon,
                ct.Mon.tenmon,
                ct.soluong,
                gia = (decimal?)ct.Mon.gia,
                ct.thanhtien
            };

            foreach (var ctdb in chitietdatban)
            {
                Chitiet_HoaDonThanhToan cthoadon = new Chitiet_HoaDonThanhToan();
                cthoadon.id_hoadon = idhoadon;
                cthoadon.id_mon    = ctdb.id_mon;
                cthoadon.soluong   = ctdb.soluong;
                cthoadon.dongia    = ctdb.gia;
                cthoadon.thanhtien = ctdb.thanhtien;
                ThemMoiChiTietHoaDon(cthoadon);
                iddatban = ctdb.id_datban;
            }
            HoaDonThanhToan hdtt = dbContext.HoaDonThanhToans.Single <HoaDonThanhToan>(hd => hd.id_hoadon == idhoadon);
            DatBan          db   = dbContext.DatBans.Single <DatBan>(d => d.id_datban == iddatban);

            hdtt.datra        = db.tiencoc;
            hdtt.id_khachhang = db.id_khachhang;

            // update
            dbContext.SubmitChanges();
        }
Exemplo n.º 3
0
        private void btnThemMon_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            if (txt_idHoadon.Text != "")
            {
                Chitiet_HoaDonThanhToan cthd = new Chitiet_HoaDonThanhToan();
                cthd.id_hoadon = int.Parse(txt_idHoadon.Text);
                if (gridView_ThucDon.EditingValue == null)
                {
                    cthd.soluong = 1;
                }
                else
                {
                    cthd.soluong = int.Parse(gridView_ThucDon.EditingValue.ToString());
                }

                cthd.dongia    = decimal.Parse(gridView_ThucDon.GetFocusedRowCellValue(thucdon_gia).ToString());
                cthd.thanhtien = cthd.soluong * cthd.dongia;
                cthd.id_mon    = int.Parse(gridView_ThucDon.GetFocusedRowCellValue(thucdon_idmon).ToString());
                if (phucvubll.KiemTraMonDaCoChua(cthd.id_hoadon, cthd.id_mon) > 0)
                {
                    //update
                    phucvubll.CapNhatChiTietHoaDon(cthd);
                    MessageBox.Show("Thêm món thành công");
                }
                else
                {
                    //add new
                    phucvubll.ThemMoiChiTietHoaDon(cthd);
                    MessageBox.Show("Thêm món mới thành công");
                }
                phucvubll.LoadChiTietHoaDon(idhoadonSelected, gridControl_ChitietHoaDon);
            }
            else
            {
                MessageBox.Show("Bàn chưa có khách!");
            }
        }
Exemplo n.º 4
0
 public void ThemMoiChiTietHoaDon(Chitiet_HoaDonThanhToan ct)
 {
     dbContext.Chitiet_HoaDonThanhToans.InsertOnSubmit(ct);
     dbContext.SubmitChanges();
 }