コード例 #1
0
        private void btncheckout_Click(object sender, EventArgs e)
        {
            if (lsvBill.Tag == null)
            {
                MessageBox.Show("Hãy chọn bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            TableDTO table   = lsvBill.Tag as TableDTO;
            int      idtable = table.ID;
            int      idbill  = BillDAO.GetUncheckedBillIDByTableID(idtable);
            int      giamgia = (int)nmGiamGia.Value;
            //double TongTien = Convert.ToDouble(txtTongTien.Text.Split(',')[0]);
            //double TongTienGiamGia = TongTien - (TongTien/100)*giamgia;
            float TongTienGiamGia = thanhtoan - (thanhtoan / 100) * giamgia;

            if (idbill != -1)
            {
                if (MessageBox.Show(string.Format("Bạn có chắc thanh toán hóa đơn với số tiền là {0}-({1}/100)*{2} = {3}", thanhtoan, thanhtoan, giamgia, TongTienGiamGia), "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    BillDAO.CheckOut(idbill, giamgia, TongTienGiamGia);
                    Showbill(idtable);
                    LoadTable();
                }
            }
            nmGiamGia.Value = 0;
        }
コード例 #2
0
        private void btnPay_Click(object sender, EventArgs e)
        {
            Table table = listViewMenu.Tag as Table;

            BillDAO billDAO  = new BillDAO();
            var     response = billDAO.GetUnPaidBill(table.id);


            String idCurrentBill = response.Content;


            if (idCurrentBill != "0")
            {
                if (MessageBox.Show("Bạn có chắc thanh toán cho " + table.title + " không?", "Thanh toán", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
                {
                    billDAO.CheckOut(idCurrentBill, (float)numericUpDownDiscount.Value);
                    if (numericUpDownDiscount.Value != 0)
                    {
                        double totalPrice  = Convert.ToDouble(txbTotalPrice.Text.Split(',')[0]) * 1000;
                        double final_price = totalPrice - (totalPrice / 100) * (float)numericUpDownDiscount.Value;
                        string text        = "Số tiền bạn cần thanh toán sau khi giảm giá " + numericUpDownDiscount.Value + "% là:\n" + totalPrice.ToString() + " - " + totalPrice.ToString() + " * " + numericUpDownDiscount.Value + "% =" + final_price.ToString() + " VND";
                        MessageBox.Show(text, "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        //SẼ PHÁT TRIỂN THÊM IN HÓA ĐƠN FILE EXCEL
                    }
                    loadMenuByIdTable(table.id);
                    CultureInfo culture    = new CultureInfo("vi-VN");
                    int         finalPrice = 0;
                    txbTotalPrice.Text = finalPrice.ToString("c", culture);
                }
            }
            loadFinalTotalPrice(table.id);
            loadTable(table.id);
            //loadListTable();
            numericUpDownDiscount.Value = 0;
        }
コード例 #3
0
        private void btnaddfood_Click(object sender, EventArgs e)
        {
            if (lsvBill.Tag == null)
            {
                MessageBox.Show("Hãy chọn bàn", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            lsvBill.Items.Clear();
            TableDTO table = lsvBill.Tag as TableDTO;                   //mục đích: lấy id của bàn đang được chọn để thêm

            int idbill = BillDAO.GetUncheckedBillIDByTableID(table.ID); //từ id bàn => lấy được id của hóa đơn
            int idfood = (cbThucAn.SelectedItem as FoodDTO).Id;
            int count  = (int)nmfoodcount.Value;

            if (idbill == -1)//case: chưa có hóa đơn, bàn còn trống
            {
                BillDAO.InsertBill(table.ID);
                //tham số idhoadon: hoa don them sau cung => co id la lon nhat
                //tham số id thức ăn: lấy từ combobox
                //tham số số lượng thức ăn lấy từ nmfoodcount
                BillInfoDAO.InsertBillInfo(BillDAO.GetMaxIdBill(), idfood, count);
            }
            else//case: hóa đơn đã tồn tại => sẽ thêm món mới hoặc cập nhật thêm số lượng món
                //kiểm tra món đã tồn tại hay chưa ta xử lí bên dưới server
            {
                BillInfoDAO.InsertBillInfo(idbill, idfood, count);
            }

            nmfoodcount.Value = 1;
            Showbill(table.ID);
            LoadTable();
        }
コード例 #4
0
        public BaseResponse <decimal> GetAll()
        {
            var list = new BillDAO().GetRevenueMonth();
            BaseResponse <decimal> response = new BaseResponse <decimal>(StatusResponse.Success, "", list.ToList());

            return(response);
        }
コード例 #5
0
        public bool Handle(Bill bill)
        {
            bool kq     = true;
            bool result = new BillDAO().InsertBill(bill);

            if (result)
            {
                foreach (var bdt in bill.ListBillDetail)
                {
                    bool rs = new BillDetailDao().InsertBillDetail(bdt);
                    if (rs)
                    {
                        continue;
                    }
                    else
                    {
                        kq = false;
                        MessageBox.Show("Lỗi");
                        break;
                    }
                }
            }
            else
            {
                kq = false;
            }
            return(kq);
        }
コード例 #6
0
ファイル: Main.cs プロジェクト: nghipq/TOS_WF
        /**
         * Sự kiện chuyên qua trang xác nhận
         */
        private void btnNext_Click(object sender, EventArgs e)
        {
            ticketID        = frmRoom.ticketID;
            strl            = frmRoom.strl;
            frmRoom.Visible = false;
            string str  = "";
            string str1 = "";

            //load seat
            strl.ForEach(item =>
            {
                str += item + " ";
            });
            //load idseat
            ticketID.ForEach(item =>
            {
                str1 += item + " ";
            });


            BillDAO bill = new BillDAO();

            frmConfirmTicket           = new ConfirmTicket(str, str1);
            frmConfirmTicket.MdiParent = this;

            frmConfirmTicket.lblCinema.Text    = C_Name;
            frmConfirmTicket.lblRoom.Text      = Room_Name;
            frmConfirmTicket.lblSchedule.Text  = sche_Name;
            frmConfirmTicket.lblFname.Text     = F_Name;
            frmConfirmTicket.btnConfirm.Click += new System.EventHandler(this.btnConfirm_Click);
            frmConfirmTicket.btnCancel.Click  += new System.EventHandler(this.btnCancel_Click);
            frmConfirmTicket.Show();
        }
コード例 #7
0
 //Doanh thu
 void LoadListBillByDate(DateTime ngayvao, DateTime ngayra)
 {
     dgvbill.DataSource = BillDAO.GetListBillDate(ngayvao, ngayra);
     dgvbill.Columns["tenban"].HeaderText   = "Tên bàn";
     dgvbill.Columns["TongTien"].HeaderText = "Tổng tiền";
     dgvbill.Columns["ngayvao"].HeaderText  = "Ngày vào";
     dgvbill.Columns["ngayra"].HeaderText   = "Ngày ra";
 }
コード例 #8
0
ファイル: CartItemController.cs プロジェクト: thongmap/TMDT2
        public ActionResult OrderDetail(int id)
        {
            //var user = Session["User"] as TMDT.Account;
            //if (user == null)
            //    return RedirectToAction("Login", "Home");
            var model = new BillDAO().GetDetailBill_BillID(id);

            return(View(model));
        }
コード例 #9
0
        private void btnBookRoom_Click(object sender, EventArgs e)
        {
            var dao       = new BillDAO();
            var bill      = dao.initializationBill();
            var fBookRoom = new fBookRoom(bill, 0);

            fBookRoom.bookroomrEven += FbookroomEven;
            fBookRoom.ShowDialog();
        }
コード例 #10
0
        public JsonResult checkStatus(int id)
        {
            var result = new BillDAO().changeStatus(id);

            return(Json(new
            {
                status = result
            }));
        }
コード例 #11
0
        public IHttpActionResult Get(int id)
        {
            var b = new BillDAO().Take(id); // Lay phan tu voi id tuong ung

            if (b == null)
            {
                return(NotFound());
            }
            return(Ok(b));
        }
コード例 #12
0
        public BaseResponse <BillDetail> CreateBill(List <BillDetail> obj)
        {
            var bill = new BillDAO().GetBill(obj[0].BillID);

            var                       result1  = new BillDetailDAO().Create(obj, bill.UserName);
            StatusResponse            status   = result1  ? StatusResponse.Success : StatusResponse.Fail;
            BaseResponse <BillDetail> response = new BaseResponse <BillDetail>(status, "", null);

            return(response);
        }
コード例 #13
0
        private void Confirm_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult result = MessageBox.Show("Are you sure?", "", MessageBoxButton.YesNo);

            switch (result)
            {
            case MessageBoxResult.Yes:

                //cap nhat database
                //cap nhat BillHistory
                //cap nhat Detail Bill
                //init
                //BaseDAO dao1 = BaseDAO
                int tmpIdCashier = LoginForm.Idcashier;

                //chuyen sale.basket sang dang directory
                Dictionary <int, int> tmpbasket = new Dictionary <int, int>();

                foreach (infobasket t in sale.baskets)
                {
                    tmpbasket.Add(t.ProductID, t.size);
                }

                //create new bill
                BillEntity bill = new BillEntity()
                {
                    //set date
                    BillDate = DateTime.Today,

                    //add list product
                    ListProduct = tmpbasket,

                    //set ID cashier
                    CashierID = tmpIdCashier
                };

                //insert and get new bill ID
                BaseDAO dao    = new BillDAO();
                int     billID = dao.insert(bill);

                //bao hieu cap nhat listitems
                flag = true;

                MessageBox.Show("Thanh toán thành công",
                                "Result",
                                MessageBoxButton.OK,
                                MessageBoxImage.Information);
                Close();
                sale.baskets.Clear();
                break;

            case MessageBoxResult.No:
                break;
            }
        }
コード例 #14
0
        public IHttpActionResult Post([FromUri] JObject jsonResult)
        {
            if (!ModelState.IsValid)  // Kiem tra tinh hop le cua giu lieu
            {
                return(BadRequest(ModelState));
            }
            var x    = JsonConvert.DeserializeObject <BillDTO>(jsonResult.ToString());
            var last = new BillDAO().Add(x);

            return(Ok(last));
        }
コード例 #15
0
ファイル: CartItemController.cs プロジェクト: thongmap/TMDT2
        public ActionResult Sort(int?sort, int?date, int?sum)
        {
            var user = Session["User"] as TMDT.Account;

            if (user == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            List <Bill> listbill = new BillDAO().Sort(sort, date, sum, user.AccountID);

            return(View("Order", listbill));
        }
コード例 #16
0
        public IHttpActionResult Delete(int id)
        {
            var dao = new BillDAO();

            if (!dao.isExist(id)) // Kiem tra xem id co hop le hay khong
            {
                return(NotFound());
            }
            var check = dao.Delete(id); // Kiem tra viec thuc hien Delete

            return(Ok(check));
        }
コード例 #17
0
ファイル: MerchantController.cs プロジェクト: thongmap/TMDT2
        public ActionResult OrderMerchant(int id)
        {
            var user = Session["User"] as TMDT.Account;

            if (user == null || user.Level != 1)
            {
                return(RedirectToAction("Login", "Home"));
            }
            var model = new BillDAO().GetDetailM_BillID(id, user.AccountID);

            ViewBag.CustomerInfo = new BillDAO().GetAccount_BillID(id);
            return(View(model));
        }
コード例 #18
0
        public static BillListingEntity[] GetData(string fromdate, string todate)
        {
            var details = new List <BillListingEntity>();

            try
            {
                details = new BillDAO().GetBillsList(fromdate, todate);
            }
            catch (Exception ex)
            {
                // details.Add(new DbStatusEntity(ex.Message));
            }
            return(details.ToArray());
        }
コード例 #19
0
        public static Int64[] CheckBillSettledEnrty(Int64 id)
        {
            List <Int64> lstvalues = new List <Int64>();

            try
            {
                lstvalues = new BillDAO().CheckBillSettledEnrty(id);
            }
            catch (Exception ex)
            {
                // details.Add(new DbStatusEntity(ex.Message));
            }
            return(lstvalues.ToArray());
        }
コード例 #20
0
        public static BillEntity[] EditData(Int64 id)
        {
            var details = new List <BillEntity>();

            try
            {
                details = new BillDAO().EditBill(id);
            }
            catch (Exception ex)
            {
                // details.Add(new DbStatusEntity(ex.Message));
            }
            return(details.ToArray());
        }
コード例 #21
0
        public ActionResult Search(string sdt)
        {
            ReadData(sdt);
            var HoaDonbySDT = new BillDAO().ListBySDT(sdt);

            ViewBag.HoaDonBySDT = HoaDonbySDT;
            var thuebao = new KhachHangDao().ListTheoSDT(sdt);

            ViewBag.SoDT = thuebao;
            IEnumerable <LogInfo> query = ViewBag.query;

            //Hiển thị kết quả bằng hộp thoại
            return(View(query.ToList()));
        }
コード例 #22
0
ファイル: UnitTest1.cs プロジェクト: nghung95/QuanLyQuanCf
        public void TestGetUncheckBillIDByTableID()
        {
            int  billId   = Int32.Parse(TestContext.DataRow[0].ToString());
            bool expected = Boolean.Parse(TestContext.DataRow[1].ToString());

            BillDAO bill = new BillDAO();

            bool actual = false;

            if (bill.GetUncheckBillIDByTableID(billId) != -1)
            {
                actual = true;
            }
            Assert.AreEqual(expected, actual);
        }
コード例 #23
0
ファイル: CartItemController.cs プロジェクト: thongmap/TMDT2
        public ActionResult Order(int?index, int?limitTime, int?status, string email)
        {
            var user = Session["User"] as TMDT.Account;

            if (user != null)
            {
                var model = new BillDAO().ViewOrder(index, limitTime, status, user.AccountID);
                return(View(model));
            }
            else
            {
                var model = new BillDAO().ViewOrder(index, limitTime, status, email);
                return(View(model));
            }
        }
コード例 #24
0
        public IHttpActionResult Put([FromBody] JObject jsonResult)
        {
            if (!ModelState.IsValid)  // Kiem tra tinh hop le cua giu lieu
            {
                return(BadRequest(ModelState));
            }
            var x   = JsonConvert.DeserializeObject <BillDTO>(jsonResult.ToString()); // Ep kieu Json sang DTO
            var dao = new BillDAO();

            if (!dao.isExist(x.ID)) // Kiem tra id co hop le khong
            {
                return(NotFound());
            }
            dao.Update(x); // Cap nhat
            return(Ok());
        }
コード例 #25
0
        public ActionResult Payment(string mobile, string address, string shipName, string email)
        {
            var order = new Bill();

            order.shipname    = shipName;
            order.shipaddress = address;
            order.shipMobile  = mobile;
            order.shipemail   = email;

            try
            {
                var    id        = new BillDAO().Insert(order);
                var    cart      = (List <CartItem>)Session[CartSession];
                var    detailDao = new Model.DAO.BillDetailDAO();
                double total     = 0;
                foreach (var item in cart)
                {
                    var orderDetail = new BillDetail();
                    orderDetail.id       = item.book.id;
                    orderDetail.idBill   = id;
                    orderDetail.price    = item.book.price;
                    orderDetail.quantity = item.quantity;
                    detailDao.Insert(orderDetail);

                    total += (item.book.price * item.quantity);
                }
                string content = System.IO.File.ReadAllText(Server.MapPath("~/assets/client/template/neworder.html"));

                content = content.Replace("{{CustomerName}}", shipName);
                content = content.Replace("{{Phone}}", mobile);
                content = content.Replace("{{Email}}", email);
                content = content.Replace("{{Address}}", address);
                content = content.Replace("{{Total}}", total.ToString("N0"));
                var toEmail = ConfigurationManager.AppSettings["ToEmailAddress"].ToString();

                new MailHepler().SendMail(email, "Đơn hàng mới từ OnlineShop", content);
                new MailHepler().SendMail(toEmail, "Đơn hàng mới từ OnlineShop", content);
            }
            catch (Exception ex)
            {
                //ghi log
                return(Redirect("/loi-thanh-toan"));
            }
            return(Redirect("/hoan-thanh"));
        }
コード例 #26
0
        public IHttpActionResult GetAllUsers(int?number)
        {
            IEnumerable <BillDTO> ls;

            if (number == null)
            {
                ls = new BillDAO().List();
            }
            else
            {
                ls = new BillDAO().List().Take((int)number);
            }
            if (ls == null)
            {
                return(NotFound());
            }
            return(Ok(ls));
        }
コード例 #27
0
        public ActionResult ShowDetailBill()
        {
            if (Regex.IsMatch(Request["OrderID"], "^\\d+$"))
            {
                int id = int.Parse(Request["OrderID"]);
                id -= 491999;
                OrderDetailDAO        dao             = new OrderDetailDAO();
                List <OrderDetailDTO> listOrderDetail = dao.GetBillDetail(id);
                BillDAO daoBill  = new BillDAO();
                float   discount = daoBill.GetDiscount(id);
                string  state    = daoBill.GetState(id);
                ViewBag.Discount = discount;
                ViewBag.State    = state;

                ViewBag.ListOrderDetail = listOrderDetail;
            }
            return(View("ViewDetailBill"));
        }
コード例 #28
0
ファイル: Main.cs プロジェクト: nghipq/TOS_WF
        /**
         * Click Thanh toan
         */
        private void btnConfirm_Click(object sender, EventArgs e)
        {
            frmConfirmTicket.Visible = false;
            string str  = "";
            string str1 = "";

            //load seat
            strl.ForEach(item =>
            {
                str += item + " ";
            });
            //load idseat


            BillDAO       bill = new BillDAO();
            BillDetailDAO bd   = new BillDetailDAO();

            bill.CreateBill(1, 1, frmConfirmTicket.lblTotal.Text);
            //this.Visible = false;
            int getvalue = bill.getMaxIdBill();

            ticketID.ForEach(item =>
            {
                bd.CreateBillDetail(Convert.ToInt32(item), getvalue);
                str1 += item + " ";
                new TicketDAO().changeStatusTicket(Convert.ToInt32(item));
            });



            //this.Visible = false;

            Console.WriteLine(str);
            Console.WriteLine(str1);
            TicketN                  = new frmTicket(str, str1);
            TicketN.MdiParent        = this;
            TicketN.lblBillId.Text   = getvalue.ToString();
            TicketN.lblCinema.Text   = C_Name;
            TicketN.lblRoom.Text     = Room_Name;
            TicketN.lblSchedule.Text = sche_Name;
            TicketN.lblFName.Text    = F_Name;
            TicketN.Show();
        }
コード例 #29
0
ファイル: frmHome.cs プロジェクト: ngocthien0507/WebCuocDT
        private void btn_cuocthang_Click(object sender, EventArgs e)// chưa xong
        {
            CuocBIZ           c     = new CuocBIZ();
            BillDAO           a     = new BillDAO();
            List <HoaDonCuoc> count = db.HoaDonCuocs.Select(b => b).ToList();
            var q = a.ListTableBill();

            if (q.Count == 0)
            {
                c.AddData();
            }

            else
            {
                bill.DeletePayBill();
                bill.DeleteBillInf();
                bill.DeleteBill();
                c.AddData();
            }
        }
コード例 #30
0
        private void PrintBill_Click(object sender, RoutedEventArgs e)
        {
            if (Project.Instance.Bill.FullPrice == 0)
            {
                MessageBox.Show("Bill cannot be empty", "Congratulations", MessageBoxButton.OK, MessageBoxImage.Information);
                this.Close();
            }

            if (IsValid() == false)
            {
                return;
            }
            Project.Instance.Bill.DateOfSale = DateTime.Now;
            Project.Instance.Bill.BillNo     = DateTime.Now.Millisecond;
            BillDAO.Create(Project.Instance.Bill);
            foreach (var b in Project.Instance.Bill.FurnitureForSaleList)
            {
                foreach (var f in Project.Instance.FurnitureList)
                {
                    if (f.ID == b.ID)
                    {
                        BillDAO.AddFurnitureOnBill(Project.Instance.Bill, f);
                        f.Quantity -= b.Quantity;
                        FurnitureDAO.Update(f);
                    }
                }
            }
            foreach (var b in Project.Instance.Bill.AdditionalServiceList)
            {
                foreach (var a in Project.Instance.AdditionalServicesList)
                {
                    BillDAO.AddAdditionalServiceOnBill(Project.Instance.Bill, a);
                }
            }
            MessageBox.Show("Success!", "Congratulations", MessageBoxButton.OK, MessageBoxImage.Information);
            Project.Instance.Bill = new Bill();

            MainWindow.DeleteSoldFurniture();
            this.Close();
        }