Пример #1
0
        //Lấy toàn bộ hóa đơn có trong database
        public List <eBill> getAllBill()
        {
            var listMed = (from b in db.hoaDons
                           join c in db.khachHangs on b.maKH equals c.maKH //Lấy tên của loại thuốc
                           join n in db.nhanViens on b.maNV equals n.maNV  //Lấy tên của loại NCC
                           select new
            {
                b.maHoaDon,
                b.ngayLapHD,
                c.tenKH,
                n.tenNV
            }
                           ).ToList();
            var listBill = (from m in db.hoaDons
                            select m).ToList();
            List <eBill> ls = new List <eBill>();

            foreach (var m in listMed)
            {
                eBill e = new eBill();
                e.BillID     = m.maHoaDon;
                e.OrderDate  = m.ngayLapHD.Value;
                e.CustomerID = m.tenNV;
                e.EmployeeID = m.tenKH;

                ls.Add(e);
            }
            return(ls);
        }
Пример #2
0
        public List <eBill> orderStatistic_Y(DateTime date)
        {
            eBill hd;

            List <eBill> ls = new List <eBill>();

            var s = db.hoaDons;

            if (s == null)
            {
                return(null);
            }
            else
            {
                foreach (var item in s)
                {
                    if (item.ngayLapHD.Value.Year == date.Year)
                    {
                        hd            = new eBill();
                        hd.BillID     = item.maHoaDon;
                        hd.OrderDate  = (DateTime)item.ngayLapHD;
                        hd.EmployeeID = item.maNV;
                        hd.CustomerID = item.maKH;

                        ls.Add(hd);
                    }
                }
            }
            return(ls);
        }
Пример #3
0
        //NÚT THANH TOÁN
        private void btnPay_Click(object sender, EventArgs e)
        {
            eBill or = new eBill();

            or.OrderDate  = DateTime.Now;
            or.CustomerID = txtCusID.Text;
            or.EmployeeID = empID;

            int orderID = bB.insertOrders(or);

            List <eBillDetail> listBill = new List <eBillDetail>();

            //Thêm chi tiết vào hóa đơn đã tạo
            for (int i = 0; i < lstvBill.Items.Count; i++)
            {
                eBillDetail ord = new eBillDetail();
                ord.BillID     = orderID.ToString();
                ord.MedicineID = this.lstvBill.Items[i].SubItems[0].Text;
                ord.Quantity   = int.Parse(this.lstvBill.Items[i].SubItems[2].Text);
                ord.Price      = double.Parse(this.lstvBill.Items[i].SubItems[3].Text);
                ord.Discount   = 0.1;

                listBill.Add(ord);
            }
            bBD.insertOrderDetail(listBill);
            MessageBox.Show("Thêm hóa đơn mới thành công !", "Thêm HĐ", MessageBoxButtons.OK, MessageBoxIcon.Information);
            lstvBill.Clear();
            InsertColumnsListView();
            btnCancelBill.Enabled = false;
            btnPay.Enabled        = false;
            txtTotalMoney.Text    = "0";
        }
Пример #4
0
        public int insertOrders(eBill or) //Thêm hóa đơn
        {
            hoaDon ortempt = new hoaDon();

            ortempt.ngayLapHD = or.OrderDate;
            ortempt.maKH      = or.CustomerID;
            ortempt.maNV      = or.EmployeeID;

            db.hoaDons.InsertOnSubmit(ortempt);
            db.SubmitChanges();
            return(ortempt.maHoaDon);
        }
Пример #5
0
        public eBill getBillFromID(int id)
        {
            hoaDon hd = db.hoaDons.Where(x => x.maHoaDon == id).FirstOrDefault();

            eBill temp = new eBill();

            temp.BillID     = hd.maHoaDon;
            temp.CustomerID = hd.maKH;
            temp.EmployeeID = hd.maNV;
            temp.OrderDate  = (DateTime)hd.ngayLapHD;

            return(temp);
        }
Пример #6
0
 public int insertOrders(eBill or) //Thêm hóa đơn
 {
     return(dB.insertOrders(or));
 }