Exemplo n.º 1
0
        /// <summary>
        /// 离座/结账按钮 负责点餐收入
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void LeaveDeskButton_Click(object sender, EventArgs e)
        {
            //获取id后设current_id 为0
            if (dataGridView.CurrentRow != null)
            {
                int index = dataGridView.CurrentRow.Index;
                //添加点单收入
                Bill   bill            = new Bill();
                string visit_record_id = (string)dataGridView.Rows[index].Cells["current_record"].Value;
                string desk_name       = (string)dataGridView.Rows[index].Cells["desk_name"].Value;
                var    orders          = orderDao.Select(new { visit_record_id = visit_record_id });
                bill.cost = 0;
                foreach (Order order in orders)
                {
                    var dishes = dishesDao.Select(new { dishes_id = order.dishes_id })[0];
                    bill.cost += dishes.price;
                }
                bill.type      = "订单";
                bill.type_name = desk_name;
                bill.type_id   = visit_record_id;
                billDao.Insert(bill);

                //更新座位状态
                string desk_id = dataGridView.Rows[index].Cells["desk_id"].Value.ToString();
                Desk   desk    = new Desk();
                desk.desk_id        = desk_id;
                desk.current_record = "0";
                deskDao.SetVisitRecord(desk);
                this.DataRefresh();
            }
            else
            {
                MessageBox.Show("尚未选择数据");
            }
        }
Exemplo n.º 2
0
 public ActionResult Create(Order bill1)
 {
     if (ModelState.IsValid)
     {
         var  dao = new BillDao();
         long id  = dao.Insert(bill1);
         if (id > 0)
         {
             return(RedirectToAction("Index", "Bill"));
         }
         else
         {
             ModelState.AddModelError("", "Thêm hóa đơn thành công");
         }
     }
     return(RedirectToAction("Index", "Bill"));
 }
Exemplo n.º 3
0
 public ActionResult Create(Bill Bill)
 {
     if (ModelState.IsValid)
     {
         var  dao = new BillDao();
         long id  = dao.Insert(Bill);
         if (id > 0)
         {
             return(RedirectToAction("Index", "Bill"));
         }
         else
         {
             ModelState.AddModelError("", "Add Bill successfully");
         }
     }
     return(View("Index"));
 }
        private void ConfirmButton_Click(object sender, EventArgs e)
        {
            if (Regex.IsMatch(AddNumBox.Text.Trim(), @"^\d+\.\d+\z|^\d+\z"))
            {
                //更新库存
                decimal addNum = Convert.ToDecimal(AddNumBox.Text.Trim());
                meterial.storage += addNum;
                meterialDao.Update(meterial);
                //记录账单
                Bill bill = new Bill();
                bill.type      = "食材";
                bill.type_name = meterial.meterial_name;
                bill.type_id   = meterial.meterial_id;
                bill.cost      = -(meterial.price * addNum);
                billDao.Insert(bill);

                MessageBox.Show("进货成功");
            }
            else
            {
                MessageBox.Show("请输入数字");
            }
        }
        public void Create(chiso entity)
        {
            //BillDao db = new BillDao();
            //int list = db.GetOldBill(1);
            //var ss = (UserLogin)System.Web.HttpContext.Current.Session[QuanLyCapNuoc.common.CommonConstants.NV_SESSION];
            BillDao db = new BillDao();


            var hd_luongtieuthu    = 0;
            var hd_chisokytruoc1   = 0;
            var hd_tieuthukytruoc1 = 0;
            var hd_chisokytruoc2   = 0;
            var hd_tieuthukytruoc2 = 0;


            //Lấy hóa đơn cuối cùng và hóa đơn kỳ trước và trước nữa
            //lấy chỉ số cuối cùng
            //lấy chỉ số dựa trên các hd trước
            //tính lượng tiêu thụ
            //var hd_chisokynay = db.GetLastIndex(kh_id);
            var hd_chisokynay          = entity.cs_chiso;
            var check_hd_chisokytruoc1 = db.GetLastBill(entity.kh_id);

            if (check_hd_chisokytruoc1 != null)
            {
                hd_chisokytruoc1 = check_hd_chisokytruoc1.cs_chiso;
                hd_luongtieuthu  = (hd_chisokynay) - (hd_chisokytruoc1);
                var check_hd_chisokytruoc2 = db.GetIndexBefore(entity.kh_id, check_hd_chisokytruoc1.k_id);
                if (check_hd_chisokytruoc2 != null)
                {
                    hd_chisokytruoc2   = check_hd_chisokytruoc2.cs_chiso;
                    hd_tieuthukytruoc1 = db.GetChiSo(entity.kh_id, check_hd_chisokytruoc1.k_id).cs_chiso;
                    var check_hd_chisokytruoc3 = db.GetIndexBefore(entity.kh_id, check_hd_chisokytruoc2.k_id);
                    if (check_hd_chisokytruoc3 != null)
                    {
                        hd_tieuthukytruoc2 = db.GetChiSo(entity.kh_id, check_hd_chisokytruoc3.k_id).cs_chiso - db.GetChiSo(entity.kh_id, check_hd_chisokytruoc3.k_id).cs_chiso;
                    }
                }
                else
                {
                    hd_tieuthukytruoc1 = 0;
                    hd_chisokytruoc2   = 0;
                    hd_tieuthukytruoc2 = 0;
                }
            }
            else
            {
                hd_luongtieuthu    = entity.cs_chiso;
                hd_chisokytruoc1   = 0;
                hd_tieuthukytruoc1 = 0;
                hd_chisokytruoc2   = 0;
                hd_tieuthukytruoc2 = 0;
            }



            //lấy đơn giá
            var temp   = db.GetLKH(entity.kh_id);
            var dongia = db.GetUnitPrice(temp);
            var bill   = new hoadon();

            bill.nv_id              = (int)((UserLogin)System.Web.HttpContext.Current.Session[QuanLyCapNuoc.common.CommonConstants.NV_SESSION]).nv_id;
            bill.kh_id              = entity.kh_id;
            bill.k_id               = entity.k_id;
            bill.hd_ngaylap         = DateTime.Now;
            bill.hd_dongia          = dongia;
            bill.hd_pttt            = "Tiền mặt";
            bill.hd_luongtieuthu    = hd_luongtieuthu;
            bill.hd_chisokytruoc1   = hd_chisokytruoc1;
            bill.hd_tieuthukytruoc1 = hd_tieuthukytruoc1;
            bill.hd_chisokytruoc2   = hd_chisokytruoc2;
            bill.hd_tieuthukytruoc2 = hd_tieuthukytruoc2;
            bill.hd_tongtien        = hd_luongtieuthu * (int)dongia;

            bool list = db.Insert(bill);


            //return RedirectToAction("Index", "Bill");
        }