Example #1
0
        private void btnThanhToan_Click_1(object sender, EventArgs e)
        {
            if (ban != null && BLL.HOA_DON_BLL.Instance.checkHoaDon(ban.ID_BAN))
            {
                if (txtPhoneCustomer.Text != "")
                {
                    int       dtl = Convert.ToInt32(txtThanhTien.Text) / 10000;
                    KHACHHANG kh  = Customer_BLL.Instance.GetKHByInfo(txtPhoneCustomer.Text);
                    if (kh != null)
                    {
                        Customer_BLL.Instance.updateDTL(kh, dtl);
                    }
                    else
                    {
                        Customer_BLL.Instance.AddCustomer_BLL(txtPhoneCustomer.Text, dtl);
                    }
                }


                BILL bill = new BILL(BLL.HOA_DON_BLL.Instance.GetIdByTable(ban.ID_BAN), 1, txtPhoneCustomer.Text);
                txtPhoneCustomer.Text = "";
                button1_Click(new object(), new EventArgs());

                bill.ShowDialog();
            }
            else
            {
                MessageBox.Show("Chua chon ban can thanh toan hoac ban khong co du lieu!!!");
            }
        }
Example #2
0
        // GET: BILLs/Edit/5
        public ActionResult Edit(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            //Lay ra object thong qua id
            BILL bILL = db.BILLS.Find(id);

            if (bILL == null)
            {
                return(HttpNotFound());
            }

            //// Cach 1:
            ////goi ra dropdown list voi gia tri duoc chon biLL.CUSTOMER_ID
            //ViewBag.CUSTOMER_ID = new SelectList(db.CUSTOMERS, "ID", "NAME", bILL.CUSTOMER_ID);
            //return View(bILL);

            // Cach 2: Thong Qua ViewModel
            var viewModel = new BillFormViewModel
            {
                BILL      = bILL,
                CUSTOMERs = db.CUSTOMERS.ToList()
            };

            return(View(viewModel));
        }
Example #3
0
        private void loadDetailRevenue(string idBanAn)
        {
            bill = new BILL(idBanAn);
            openChildFormInPanel(bill);
            DataTable rs = BLL.MONAN.Ins.getListMonTheoId(idBanAn);

            dataGridView2.DataSource = rs;
        }
Example #4
0
        public ActionResult DeleteConfirmed(decimal id)
        {
            BILL bILL = db.BILLS.Find(id);

            db.BILLS.Remove(bILL);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #5
0
        public static string GetFullMonthName(BILL b)
        {
            DateTime billPeriod    = new DateTime();
            string   fullMonthName = "";

            billPeriod    = Convert.ToDateTime(b.PERIOD);
            fullMonthName = billPeriod.ToString("MMMM yyyy");
            return(fullMonthName);
        }
Example #6
0
        private void btnAdd_Click_1(object sender, RoutedEventArgs e)
        {
            int tableID = (dtgvBill.Tag as TABLELIST).tableID;
            //Lay du lieu tu combobox

            int foodID = (cbFood.SelectedItem as FOOD).foodID;
            int count  = int.Parse(cbSoLuong.Text);

            //MessageBox.Show(count+"");


            //Kiem tra ban da thanh toan chua neu chua thi them vao bill hien tai neu roi thi tao bill moi

            if (DataProvider.Ins.DB.BILLs.Where(x => x.tableID == tableID && x.billStatus == 0).Count() > 0)
            {
                var bill = DataProvider.Ins.DB.BILLs.Where(x => x.tableID == tableID && x.billStatus == 0).ToList();
                //Lay Bill cua ban hien tai
                var b = bill.First();
                //them billInfo moi
                BILLINFO billInfo = new BILLINFO();
                billInfo.billID = b.billID;
                billInfo.foodID = foodID;
                billInfo.count  = count;
                DataProvider.Ins.DB.BILLINFOes.Add(billInfo);
                DataProvider.Ins.DB.SaveChanges();
                ShowBill(tableID);
            }
            else
            {
                //Tao bill moi
                BILL bill = new BILL();
                bill.tableID    = tableID;
                bill.billStatus = 0;
                bill.username   = AccountLogin.userName;
                bill.checkIn    = DateTime.Now; //
                DataProvider.Ins.DB.BILLs.Add(bill);
                DataProvider.Ins.DB.SaveChanges();
                //Them billInfo moi
                BILLINFO billInfo = new BILLINFO();
                billInfo.billID = bill.billID;
                billInfo.foodID = foodID;
                billInfo.count  = count;
                DataProvider.Ins.DB.BILLINFOes.Add(billInfo);
                DataProvider.Ins.DB.SaveChanges();
                //Cap nhat lai thanh ban da co nguoi
                var table = DataProvider.Ins.DB.TABLELISTs.Where(x => x.tableID == tableID).ToList();
                var tb    = table.First();
                if (tb != null)
                {
                    tb.tableStatus = "Có người";
                }
                DataProvider.Ins.DB.SaveChanges();
                ShowBill(tableID);
                stacklist.Children.Clear();
                LoadTable();
            }
        }
Example #7
0
        public ActionResult Edit(BILL bill)
        {
            //Tim bill trong database
            BILL billInDB = db.BILLS.Find(bill.ID);

            //Update
            billInDB.CUSTOMER_ID = bill.CUSTOMER_ID;
            billInDB.TOTAL       = bill.TOTAL;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public static Bill Get(BILL bill)
 {
     return(new Bill
     {
         Id = bill.ID,
         Number = bill.NUMBER,
         Date = bill.DATE,
         Period = HelperMethod.GetFullMonthName(bill.PERIOD),
         Sum = bill.SUM,
         Paid = bill.PAID
     });
 }
Example #9
0
        private void btnXemThongtinHoadon_Click_1(object sender, RoutedEventArgs e)
        {
            rtxtShowBill.Document.Blocks.Clear();
            int  id    = int.Parse(txtID.Text);
            BILL Bill  = DataProvider.Ins.DB.BILLs.Where(x => x.billID == id).First();
            var  model = from bi in DataProvider.Ins.DB.BILLINFOes
                         join f in DataProvider.Ins.DB.FOODs
                         on bi.foodID equals f.foodID
                         where bi.billID == id
                         select new ShowBillByTable
            {
                foodName = f.foodName,
                soLuong  = bi.count,
                giaTien  = (float)f.foodPrice
            };
            float tongtien = 0;

            foreach (var item in model)
            {
                tongtien = tongtien + item.soLuong * item.giaTien;
            }

            CultureInfo culture = new CultureInfo("vi-VN");

            string Tongtien = tongtien.ToString("c", culture);

            using (StreamWriter sw = new StreamWriter(@"D:\Thực tập chuyên môn\CafeShop\CafeShop\BillInfo\thongtinhoadon.txt"))
            {
                sw.WriteLine("Hóa đơn bàn :" + Bill.tableID);
                foreach (var item in model)
                {
                    string giatien = item.giaTien.ToString("c", culture);
                    sw.WriteLine(item.foodName + " --- SL: " + item.soLuong + " --- Giá: " + giatien + "/SP");
                }
                sw.WriteLine("Check in: " + Bill.checkIn);

                sw.WriteLine("Check out: " + Bill.checkOut);
                sw.WriteLine("Tổng tiền: " + Tongtien);
            }

            string line = "";

            using (StreamReader sr = new StreamReader(@"D:\Thực tập chuyên môn\CafeShop\CafeShop\BillInfo\thongtinhoadon.txt"))
            {
                while ((line = sr.ReadLine()) != null)
                {
                    Paragraph p = new Paragraph();
                    p.Inlines.Add(line);
                    rtxtShowBill.Document.Blocks.Add(p);
                }
            }
        }
Example #10
0
        private void btnTamThanhToan_Click_1(object sender, EventArgs e)
        {
            if (ban != null && BLL.HOA_DON_BLL.Instance.checkHoaDon(ban.ID_BAN))
            {
                BILL bill = new BILL(BLL.HOA_DON_BLL.Instance.GetIdByTable(ban.ID_BAN), 0, txtPhoneCustomer.Text);

                bill.ShowDialog();
            }
            else
            {
                MessageBox.Show("Chua chon ban can thanh toan hoac ban khong co du lieu!!!");
            }
        }
Example #11
0
 public ActionResult Edit([Bind(Include = "Bill_id,Total,BillPay_id,Rent_id,Booking_id")] BILL bILL)
 {
     if (ModelState.IsValid)
     {
         db.Entry(bILL).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BillPay_id = new SelectList(db.BILLPAYs, "BillPay_id", "PayType_id", bILL.BillPay_id);
     ViewBag.Booking_id = new SelectList(db.BOOKINGs, "Booking_id", "Customer_id", bILL.Booking_id);
     ViewBag.Rent_id    = new SelectList(db.RENTs, "Rent_id", "RoomType_id", bILL.Rent_id);
     return(View(bILL));
 }
        //chỉnh sửa hóa đơn + ch tiết hóa đơn
        //public static CommandResult Edit1(HOADON c, int userId, int flag, long? warehousePlace, List<string> fileList, string[] listProductId, string[] listQuantity, string[] listQuantityApprove, string[] listPrice)
        public static CommandResult Edit1(BILL c, int userId, string[] listSanphamID, string[] listSoluong, string[] listGia)
        {
            using (var context = new GST_MockProjectEntities())
            {
                using (System.Data.Entity.DbContextTransaction dbTran = context.Database.BeginTransaction())
                {
                    decimal?Tongtien = 0;

                    var HoaDon =
                        context.BILLs.Include(x => x.BILL_DETAIL).First(x => x.ID == c.ID);



                    //xóa danh sách sản phẩm cũ
                    var listwtdOld = HoaDon.BILL_DETAIL;
                    context.BILL_DETAIL.RemoveRange(listwtdOld);

                    //thêm danh sách sản phẩm mới
                    var listwtd = new List <BILL_DETAIL>();
                    for (int i = 0; i < listSanphamID.Length; i++)
                    {
                        var     SanphamID = int.Parse(listSanphamID[i]);
                        var     Soluong   = int.Parse(listSoluong[i]);
                        decimal?Giaban    = null;
                        if (listGia[i] != "")
                        {
                            Giaban   = decimal.Parse(listGia[i]);
                            Tongtien = Tongtien + Giaban;
                        }
                        var cthd = new BILL_DETAIL()
                        {
                            Product_ID = SanphamID,
                            Quantity   = Soluong,
                            Bill_ID    = c.ID,
                            Amount     = Giaban
                        };
                        listwtd.Add(cthd);
                    }
                    context.BILL_DETAIL.AddRange(listwtd);
                    //Chỉnh sửa lại thông tin hóa đơn khi sửa
                    HoaDon.UpdateBy   = userId;
                    HoaDon.UpdateDate = DateTime.Now;
                    HoaDon.Amount     = Tongtien;

                    context.SaveChanges();
                    dbTran.Commit();

                    return(new CommandResult(ResultCode.Success, "Sửa thành công"));
                }
            }
        }
Example #13
0
        // GET: BILLs/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BILL bILL = db.BILLs.Find(id);

            if (bILL == null)
            {
                return(HttpNotFound());
            }
            return(View(bILL));
        }
Example #14
0
        // GET: BILLs/Details/5
        public ActionResult Details(decimal id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BILL bILL = db.BILLS.Find(id);

            if (bILL == null)
            {
                return(HttpNotFound());
            }
            return(View(bILL));
        }
        //hàm tạo mới 1 hóa đơn sẽ tự tạo các chi tiết hóa đơn
        public static CommandResult Create1(BILL c, int userId, string[] listSanphamID, string[] listSoluong, string[] listGia)

        {
            using (var context = new GST_MockProjectEntities())
            {
                using (System.Data.Entity.DbContextTransaction dbTran = context.Database.BeginTransaction())
                {
                    decimal?Tongtien = 0;

                    c.CreateBy   = userId;
                    c.Amount     = 0;
                    c.CreateDate = DateTime.Now;

                    context.BILLs.Add(c);
                    context.SaveChanges();



                    //luu chi tiet san pham
                    var listwtd = new List <BILL_DETAIL>();
                    for (var i = 0; i < listSanphamID.Length; i++)
                    {
                        decimal?price = null;
                        if (listGia[i] != "")
                        {
                            price    = decimal.Parse(listGia[i]);
                            Tongtien = Tongtien + price;
                        }

                        var wtd = new BILL_DETAIL()
                        {
                            Bill_ID    = c.ID,
                            Product_ID = int.Parse(listSanphamID[i]),
                            Quantity   = int.Parse(listSoluong[i]),
                            Amount     = price
                        };
                        listwtd.Add(wtd);
                    }

                    context.BILL_DETAIL.AddRange(listwtd);
                    c.Amount = Tongtien;
                    context.SaveChanges();
                    dbTran.Commit();
                    return(new CommandResult());
                }
            }
        }
Example #16
0
        // GET: BILLs/Edit/5
        public ActionResult Edit(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            BILL bILL = db.BILLs.Find(id);

            if (bILL == null)
            {
                return(HttpNotFound());
            }
            ViewBag.BillPay_id = new SelectList(db.BILLPAYs, "BillPay_id", "PayType_id", bILL.BillPay_id);
            ViewBag.Booking_id = new SelectList(db.BOOKINGs, "Booking_id", "Customer_id", bILL.Booking_id);
            ViewBag.Rent_id    = new SelectList(db.RENTs, "Rent_id", "RoomType_id", bILL.Rent_id);
            return(View(bILL));
        }
Example #17
0
        public ActionResult Create(BILL insertBILL)
        {
            HttpClient hc = new HttpClient();

            hc.BaseAddress = new Uri("https://localhost:44372/api/BILLCrud");

            var insertrecord = hc.PostAsJsonAsync <BILL>("BILLCrud", insertBILL);

            insertrecord.Wait();

            var saveData = insertrecord.Result;

            if (saveData.IsSuccessStatusCode)
            {
                return(RedirectToAction("Index"));
            }
            return(View("Create"));
        }
        private void btnPay_Click(object sender, EventArgs e)
        {
            addHoaDonBan();
            Form_Alert.Alert("Thanh toán thành công!", Form_Alert.enmType.Success);
            BILL bill = new BILL(idBanAn);

            bill.printBill();
            BANAN.Ins.setTableStatus(this.selectedTable.tableId, "0");
            if (this.ParentForm != null)
            {
                this.ParentForm.selectedTable = null;
            }
            // khách
            ParentForm.CustomerInTalbe.Remove(selectedTable.tableId);
            ParentForm.selectedCustomer = null;
            ParentForm.btnTable.Text    = "Chọn bàn";
            ParentForm.btnCustomer.Text = "Chọn khách hàng";
            ParentForm.btnPrice.Text    = "0";
            this.Close();
        }
        public JsonResult <List <BILL> > Bill()
        {
            List <BILL> result = new List <BILL>();

            using (BDSEntities db = new BDSEntities())
            {
                var lshopdong = db.BILLs.ToList();
                foreach (var hopdong in lshopdong)
                {
                    BILL bill = new BILL();
                    bill.idBill     = hopdong.idBill;
                    bill.kyten      = hopdong.kyten;
                    bill.totalPrice = hopdong.totalPrice;
                    bill.ngayKyTen  = hopdong.ngayKyTen;
                    bill.idCustom   = hopdong.idCustom;
                    bill.idUserNV   = hopdong.idUserNV;

                    result.Add(bill);
                }
            }
            return(Json(result));
        }
Example #20
0
        internal void GetBillData(string billNumber)
        {
            using (var context = new TownUtilityBillSystemV2Entities())
            {
                BILL    billDB  = context.BILLs.Where(b => b.NUMBER == billNumber).FirstOrDefault();
                Account account = context.ACCOUNTs.Where(a => a.ID == billDB.ACCOUNT_ID).Select(Account.Get).FirstOrDefault();

                if (billDB != null)
                {
                    Bill         = Bill.Get(billDB);
                    Bill.Account = account;

                    var customerDB = context.CUSTOMERs.Where(c => c.ACCOUNT_ID == billDB.ACCOUNT_ID).FirstOrDefault();

                    if (customerDB != null)
                    {
                        CustomerModel.Customer.Surname = customerDB.SURNAME;
                        CustomerModel.Customer.Name    = customerDB.NAME;
                    }
                }
            }
        }
        public static CommandResult Create(BILL c)
        {
            using (var context = new GST_MockProjectEntities())
            {
                c.CreateBy   = UserService.GetUserInfo().ID;;
                c.CreateDate = DateTime.Now;
                context.BILLs.Add(c);
                context.SaveChanges();
                //TODO
                //context.Log(c, LogType.BankBranch_Create, userId, "", HttpContext.Current.Request.Form);
                return(new CommandResult());
            }
            //using (var context = new GST_MockProjectEntities())
            //{
            //    c.NhanVienID = 1;
            //    c.NgayLap = DateTime.Now;
            //    context.HOADONs.Add(c);
            //    context.SaveChanges();

            //    return new CommandResult();
            //}
        }
Example #22
0
        public ActionResult CreateEdit1(BILL model)
        {
            if (Request["txtProductIdRow"] == null)
            {
                return(Json(new CommandResult()
                {
                    Code = ResultCode.Fail, Message = "Xin vui lòng thêm sản phẩm "
                }, JsonRequestBehavior.AllowGet));
            }
            var listSanPhamID = Request.Form.GetValues("txtProductIdRow");
            var listSoLuong   = Request.Form.GetValues("txtQuantityRow");
            var listGia       = Request.Form.GetValues("txtPriceRow");

            if (model.ID == 0)
            {
                var user   = UserService.GetUserInfo();
                var result = HoaDonService.Create1(model, user.ID, listSanPhamID, listSoLuong, listGia);
                return
                    (Json(
                         new RedirectCommand()
                {
                    Code = result.Code, Message = result.Message, Url = Url.Action("Index", new { id = model.ID })
                },
                         JsonRequestBehavior.AllowGet));
            }
            else
            {
                var user   = UserService.GetUserInfo();
                var result = HoaDonService.Edit1(model, user.ID, listSanPhamID, listSoLuong, listGia);
                return
                    (Json(
                         new RedirectCommand()
                {
                    Code = result.Code, Message = result.Message, Url = Url.Action("Index", new { id = model.ID })
                },
                         JsonRequestBehavior.AllowGet));
            }
        }
Example #23
0
 [ValidateAntiForgeryToken] // ngan chan gia mao
 public ActionResult Create(BILL bill)
 {
     //Check value of a attribute
     if (!ModelState.IsValid)
     {
         var viewModel = new BillFormViewModel
         {
             BILL      = bill,
             CUSTOMERs = db.CUSTOMERS.ToList()
         };
         return(View(viewModel));
     }
     if (bill.ID == 0 | bill.ID == null)
     {
         return(View("This bill is not created!"));
     }
     else
     {
         db.BILLS.Add(bill);
     }
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
        public static bool UpdateBill(int orderId, int state, int paymethod)
        {
            _db = new FoodStoreEntities();
            bool flag = true;
            bool checkBill = true;
            ORDER order = OrderController.GetById(orderId, _db);
            if (order.BILLs.Count == 0)
            {
                checkBill = false;
            }

            if (checkBill)
            {
                BILL bill = _db.BILLs.Single(p => p.ORDER.ID == orderId);
                if (state != (int)ProjectEnum.OrderState.Finish)
                {
                    _db.BILLs.DeleteObject(bill);
                }
                else
                {
                    bill.PaymentMethor = paymethod;
                }
            }
            else
            {
                if (state == (int)ProjectEnum.OrderState.Finish)
                {
                    BILL bill = new BILL();
                    bill.ID = GetMaxId();
                    bill.IDOrder = orderId;
                    bill.Date = DateTime.Now;
                    bill.TotalPayment = order.TotalPayment;
                    bill.PaymentMethor = paymethod;
                    _db.BILLs.AddObject(bill);
                }
            }
            try
            {
                _db.SaveChanges();
            }
            catch (Exception)
            {
                flag = false;
                throw;
            }
            return flag;
        }
Example #25
0
        public ActionResult ConfirmBillPay(string id)
        {
            BILL mBill = db.BILLs.Find(id);

            return(View(mBill));
        }
Example #26
0
        private void button13_Click(object sender, EventArgs e)
        {
            BILL B1 = new BILL();

            B1.Show();
        }
 public IHttpActionResult BILLinsert(BILL BILLinsert)
 {
     bill.BILLs.Add(BILLinsert);
     bill.SaveChanges();
     return(Ok());
 }
Example #28
0
        public ActionResult Confirm(string check_in_date_input, string check_out_date_input, string roomtype_input)
        {
            ViewBag.roomtypeData = db.ROOMTYPEs.ToList();
            ViewBag.paytypeData  = db.PAYTYPEs.ToList();

            string customerLastName  = Request["customerLastName"];
            string customerFirstName = Request["customerFirstName"];
            string tel     = Request["tel"];
            string email   = Request["email"];
            string paytype = Request["paytype"];


            // -------------check user input-------------
            if (isCorrectFormat(check_in_date_input) == false || isCorrectFormat(check_out_date_input) == false)
            {
                return(RedirectToAction("Index"));
            }
            else if (NumberOfDays(check_in_date_input, check_out_date_input) < 0)
            {
                return(RedirectToAction("Index"));
            }


            // -------price and total for booking form----------
            int numberOfDays = NumberOfDays(check_in_date_input, check_out_date_input);

            String queryRent =
                "SELECT r.Rent_id, r.Price, r.IsActive, r.From_Date, r.To_Date, r.RoomType_id "
                + "FROM(SELECT * FROM ROOMTYPE rt WHERE(rt.RoomType_id = '" + roomtype_input + "')) rt, RENT r "
                + "WHERE(r.RoomType_id = rt.RoomType_id) and r.IsActive = 'True' ";

            var rent  = db.Database.SqlQuery <RENT>(queryRent);
            int price = rent.ToList()[0].Price;
            int total = numberOfDays * price;


            // ---------------check room availability--------------

            string check_in_date_format  = FormatDate(check_in_date_input);
            string check_out_date_format = FormatDate(check_out_date_input);

            String query =
                "DECLARE @S DATE; "
                + " SET @S = '" + check_in_date_format + "' "
                + " DECLARE @E DATE; "
                + " SET @E = '" + check_out_date_format + "' "
                + " DECLARE @RT varchar(20); "
                + " SET @RT = '" + roomtype_input + "' "

                + " SELECT r.Room_id, r.RoomType_id"
                + " FROM (SELECT * FROM ROOM WHERE ROOM.RoomType_id = @RT) r "
                + " EXCEPT "
                + " SELECT Distinct c.Room_id, c.RoomType_id "
                + " FROM( "
                + "   SELECT a.Room_id, a.RoomType_id, b.Booking_id, b.Check_in_date, b.Check_out_date, b.Customer_id "
                + "    FROM(SELECT * FROM ROOM WHERE ROOM.RoomType_id = @RT) a, BOOKING b "
                + "    WHERE a.Room_id = b.Room_id "
                + " ) c "
                + " WHERE( "
                + "      (@S <= c.Check_in_date and(@E >= c.Check_in_date and @E <= c.Check_out_date)) "
                + "        or((@S >= c.Check_in_date and @S <= c.Check_out_date) and @E >= c.Check_out_date ) "
                + "       or(@S >= c.Check_in_date and @E <= c.Check_out_date) "
                + "       or(@S <= c.Check_in_date and @E >= c.Check_out_date) "
                + ")";


            var         data  = db.Database.SqlQuery <ROOM>(query);
            List <ROOM> data1 = data.ToList();

            // not availability
            if (data1.Count <= 0)
            {
                System.Diagnostics.Debug.WriteLine("Khong co phong");
                ViewBag.isExist   = false;
                ViewBag.showAlert = true;
                return(RedirectToAction("Index"));
            }
            else
            {
                // flag for create booking form
                ViewBag.isExist = true;
            }


            // create customer
            CUSTOMER mCustomer = new CUSTOMER();

            mCustomer.Customer_id       = createCustomerId();
            mCustomer.CustomerFirstName = customerFirstName;
            mCustomer.CustomerLastName  = customerLastName;
            mCustomer.CustomerTel       = tel;
            mCustomer.CustomerEmail     = email;
            db.CUSTOMERs.Add(mCustomer);

            // create booking
            BOOKING mBooking = new BOOKING();

            mBooking.Booking_id     = createBookingId();
            mBooking.Check_in_date  = Convert.ToDateTime(check_in_date_input);
            mBooking.Check_out_date = Convert.ToDateTime(check_out_date_input);
            mBooking.Customer_id    = mCustomer.Customer_id;
            mBooking.Room_id        = data1[0].Room_id;
            db.BOOKINGs.Add(mBooking);

            // create billpay
            BILLPAY mBillPay = new BILLPAY();

            mBillPay.BillPay_id  = createBillPayId();
            mBillPay.Date        = DateTime.Now;
            mBillPay.PayType_id  = paytype;
            mBillPay.Customer_id = mCustomer.Customer_id;
            db.BILLPAYs.Add(mBillPay);

            // create bill
            BILL mBill = new BILL();

            mBill.Bill_id    = createBillId();
            mBill.Total      = total;
            mBill.BillPay_id = mBillPay.BillPay_id;
            mBill.Rent_id    = rent.ToList()[0].Rent_id; // ...
            mBill.Booking_id = mBooking.Booking_id;
            db.BILLs.Add(mBill);

            db.SaveChanges();

            SendEmail(mCustomer.CustomerLastName + " " + mCustomer.CustomerFirstName, mCustomer.CustomerTel, mCustomer.CustomerEmail, htmlMail(mBill, db.ROOMTYPEs.Find(roomtype_input).RType, price));

            return(RedirectToAction("ConfirmBillPay", new { id = mBill.Bill_id }));
        }
Example #29
0
        private void updateBills(RootObjectBill billsInOknesset)
        {
            using (AgendaEntities db = new AgendaEntities())
            {
                var context = System.Web.HttpContext.Current;
                //ErrorLog.GetDefault(context).Log(new Error(new Exception("updateBills-billsInOknesset.results.collection1.Where")));
                //foreach (CollectionBill e in billsInOknesset.results.collection1.Where(en => (en.oknessetBill != null && !string.IsNullOrEmpty(en.oknessetBill.text))).ToList())
                foreach (CollectionBill e in billsInOknesset.results.collection1.Where(en => (!string.IsNullOrEmpty(en.billName))).ToList())
                {
                    //ErrorLog.GetDefault(context).Log(new Error(new Exception("updateBills-BILL.Where")));
                    //BILL bill = db.BILL.Where(b => (e.oknessetBill.text == b.oknesset_url)).FirstOrDefault();
                    BILL bill = db.BILL.Where(b => (e.billName == b.name)).FirstOrDefault();

                    //ErrorLog.GetDefault(context).Log(new Error(new Exception("after-BILL.Where")));

                    if (bill == null || bill.Id == 0)
                    {
                        //ErrorLog.GetDefault(context).Log(new Error(new Exception("BILL add")));
                        bill = new BILL();
                        bill.oknesset_url = e.oknessetBill.text;
                        bill.name         = e.billName;
                        string voteDate = e.voteDate;
                        //ErrorLog.GetDefault(context).Log(new Error(new Exception("before bill.date, voteDate:" + voteDate)));
                        if (!string.IsNullOrEmpty(voteDate) && voteDate.Length > 6 && voteDate.Contains('/'))
                        {
                            voteDate = voteDate.Split('/')[0].Length == 1 ? "0" + voteDate : voteDate;
                            //ErrorLog.GetDefault(context).Log(new Error(new Exception("before ParseExact, voteDate:" + voteDate)));
                            voteDate = voteDate.Split('/')[1].Length == 1 ? voteDate.Split('/')[0] + "/0" + voteDate.Split('/')[1] + "/" + voteDate.Split('/')[2] : voteDate;
                            //ErrorLog.GetDefault(context).Log(new Error(new Exception("before ParseExact, voteDate:" + voteDate)));
                            bill.date = DateTime.ParseExact(voteDate, "d", CultureInfo.InvariantCulture);
                        }
                        else
                        {
                            continue;
                        }
                        //ErrorLog.GetDefault(context).Log(new Error(new Exception("before bill.committee_vote")));

                        if (e.passed == "בעד" || e.passed == "׳‘׳¢׳“" || e.passed == "בעד")
                        {
                            bill.committee_vote = 1;
                        }
                        else if (e.passed == "נגד" || e.passed == "׳ ׳’׳“" || e.passed == "× ×ž× ×¢")
                        {
                            bill.committee_vote = 2;
                        }
                        else // נמנע
                        {
                            bill.committee_vote = 3;
                        }

                        ErrorLog.GetDefault(context).Log(new Error(new Exception("e.passed:" + e.passed)));
                        ErrorLog.GetDefault(context).Log(new Error(new Exception("bill.committee_vote:" + bill.committee_vote)));
                        db.BILL.Add(bill);
                        db.SaveChanges();
                        //db.Database.Connection.
                        //bill = db.BILL.Where(b => (b.oknesset_url == vote_item.oknessetBill.text)).FirstOrDefault();
                    }
                    else
                    {
                        //ErrorLog.GetDefault(context).Log(new Error(new Exception("bill != null")));
                        bill.name = e.billName;
                        //ErrorLog.GetDefault(context).Log(new Error(new Exception("before bill.committee_vote")));
                        if (e.passed == "בעד" || e.passed == "׳‘׳¢׳“" || e.passed == "בעד")
                        {
                            bill.committee_vote = 1;
                        }
                        else if (e.passed == "נגד" || e.passed == "׳ ׳’׳“" || e.passed == "× ×ž× ×¢")
                        {
                            bill.committee_vote = 2;
                        }
                        else // נמנע
                        {
                            bill.committee_vote = 3;
                        }

                        ErrorLog.GetDefault(context).Log(new Error(new Exception("2-e.passed:" + e.passed)));
                        ErrorLog.GetDefault(context).Log(new Error(new Exception("2-bill.committee_vote:" + bill.committee_vote)));

                        db.SaveChanges();
                    }
                }
            }
        }
Example #30
0
        String htmlMail(BILL mBill, string RType, int Price)
        {
            /*
             * don't khow why mbill contain null RENT, ROOM connect, can't using mbill to shows price, Rtype of bill
             */

            String a =

                "   <div class='container'>  " +
                "       <div class='row'>  " +
                "           <div class='col-xs-12'>  " +
                "               <div class='invoice-title'>  " +
                "                   <h2>Hóa đơn</h2><h3 class='pull-right'>" + mBill.Bill_id + "</h3>  " +
                "               </div>  " +
                "               <hr>  " +
                "               <div class='row'>  " +
                "                   <div class='col-xs-6'>  " +
                "                       <address>  " +
                "                           <strong>Hóa đơn tới:</strong><br>  " +
                "                           " + mBill.BOOKING.CUSTOMER.CustomerLastName + " " + mBill.BOOKING.CUSTOMER.CustomerFirstName + "< br>  " +
                "                           " + mBill.BOOKING.CUSTOMER.CustomerTel + "<br>  " +
                "                           " + mBill.BOOKING.CUSTOMER.CustomerEmail + "<br>  " +
                "                       </address>  " +
                "                   </div>  " +
                "                     " +
                "               </div>  " +
                "               <div class='row'>  " +
                "                   <div class='col-xs-6' > " +
                "                       <address>  " +
                "                           <strong>Phương thức thanh toán:</strong><br>  " +
                "                           " + mBill.BILLPAY.PAYTYPE.PType + "<br>  " +
                "                           Thời gian thanh toán: " + mBill.BILLPAY.Date.ToString("dd/MM/yyyy") + "<br>  " +
                "                       </address>  " +
                "                   </div>                 " +
                "               </div>  " +
                "           </div>  " +
                "       </div>  " +
                "     " +
                "       <div class='row'>  " +
                "           <div class='col-md-12'>  " +
                "               <div class='panel panel-default'>  " +
                "                   <div class='panel-heading'>  " +
                "                       <h3 class='panel-title'><strong>Chi tiết Book:</strong></h3>  " +
                "                   </div>  " +
                "                   <div class='panel-body'>  " +
                "                       <div class='table-responsive'>  " +
                "                           <table class='table table-condensed'>  " +
                "                               <thead>  " +
                "                                   <tr>  " +
                "                                       <td><strong>Số phòng</strong></td>  " +
                "                                       <td class='text-center'><strong>Loại phòng</strong></td>  " +
                "                                       <td class='text-center'><strong>Ngày nhận phòng</strong></td>  " +
                "                                       <td class='text-center'><strong>Ngày trả phòng</strong></td>  " +
                "                                       <td class='text-right'><strong>Giá 1 đêm</strong></td>  " +
                "                                   </tr>  " +
                "                               </thead>  " +
                "                               <tbody>  " +
                "     " +
                "                                   <tr>  " +
                "                                       <td>" + mBill.BOOKING.Room_id + "</td>  " +
                "                                       <td class='text-center'>" + RType + "</td>  " +
                "                                       <td class='text-center'>" + mBill.BOOKING.Check_in_date.ToString("dd/MM/yyyy") + "</td>  " +
                "                                       <td class='text-center'>" + mBill.BOOKING.Check_out_date.ToString("dd/MM/yyyy") + "</td>  " +
                "                                       <td class='text-right'>" + Price + "</td>  " +
                "                                   </tr>                                  " +
                "                                    " +
                "                                   <tr>  " +
                "                                       <td class='no-line'></td>  " +
                "                                       <td class='no-line'></td>  " +
                "                                       <td class='no-line'></td>  " +
                "                                       <td class='no-line text-center'><strong>Tổng cộng</strong></td>  " +
                "                                       <td class='no-line text-right'>" + mBill.Total + "</td>  " +
                "                                   </tr>  " +
                "                               </tbody>  " +
                "                           </table>  " +
                "                       </div>  " +
                "                   </div>  " +
                "               </div>  " +
                "           </div>  " +
                "       </div>  " +
                "  </div>  ";

            return(a);
        }
Example #31
0
        private void updateVotes(IEnumerable <Collection1> v)
        {
            using (AgendaEntities db = new AgendaEntities())
            {
                var context = System.Web.HttpContext.Current;
                //ErrorLog.GetDefault(context).Log(new Error(new Exception("updateVotes-before Collection1 vote_item")));
                foreach (Collection1 vote_item in v)
                {
                    if (string.IsNullOrEmpty(vote_item.oknessetBill.text))
                    {
                        throw new ArgumentNullException();
                    }
                    // find if bill exist, if so find it and get the id, else create it
                    //int billOknessetId = int.Parse(vote_item.oknessetBill.text.Replace("https://oknesset.org/bill/","").Replace("/",""));
                    BILL     bill     = db.BILL.Where(b => (b.oknesset_url == vote_item.oknessetBill.text)).FirstOrDefault();
                    int      billId   = (bill != null?bill.Id : 0);
                    DateTime voteDate = DateTime.ParseExact(vote_item.voteDate, "MM/dd/yyyy", CultureInfo.InvariantCulture);
                    VOTE     vote     = db.VOTE.Where(b => (b.bill.Value == billId && b.meeting == voteDate)).FirstOrDefault();

                    if (bill == null || bill.Id == 0)
                    {
                        bill              = new BILL();
                        bill.name         = vote_item.billName;
                        bill.date         = voteDate;
                        bill.oknesset_url = vote_item.oknessetBill.text;
                        //ErrorLog.GetDefault(context).Log(new Error(new Exception("updateVotes-before BILL.Add")));
                        db.BILL.Add(bill);
                        db.SaveChanges();
                        //db.Database.Connection.
                        //bill = db.BILL.Where(b => (b.oknesset_url == vote_item.oknessetBill.text)).FirstOrDefault();
                    }

                    if (vote == null)
                    {
                        VOTE newVote = new VOTE();
                        //newVote.meeting = DateTime.Parse(vote_item.voteDate);// 06/07/2015
                        newVote.meeting = voteDate;
                        newVote.bill    = bill.Id;
                        newVote.mk      = int.Parse(vote_item.minister_id);
                        newVote.source  = 1; // from public vote
                        //
                        if (vote_item.ministerVote == "בעד" || vote_item.ministerVote == "׳‘׳¢׳“" || vote_item.ministerVote == "בעד")
                        {
                            newVote.vote1 = 1;
                        }
                        else if (vote_item.ministerVote == "נגד" || vote_item.ministerVote == "׳ ׳’׳“" || vote_item.ministerVote == "× ×ž× ×¢")
                        {
                            newVote.vote1 = 2;
                        }
                        else
                        {
                            // we will take the vote from the commitie vote if the minister didn't publish it
                            if (vote_item.passed == "בעד" || vote_item.passed == "׳‘׳¢׳“" || vote_item.passed == "בעד")
                            {
                                newVote.vote1 = 1;
                            }
                            else if (vote_item.passed == "נגד" || vote_item.ministerVote == "׳ ׳’׳“" || vote_item.passed == "× ×ž× ×¢")
                            {
                                newVote.vote1 = 2;
                            }
                            else
                            {
                                ErrorLog.GetDefault(context).Log(new Error(new Exception("vote_item.ministerVote:" + vote_item.ministerVote)));
                                ErrorLog.GetDefault(context).Log(new Error(new Exception("vote_item.passed:" + vote_item.passed)));
                                newVote.vote1 = 0;
                            }
                        }
                        ErrorLog.GetDefault(context).Log(new Error(new Exception("updateVotes-before VOTE.Add")));
                        db.VOTE.Add(newVote);
                        db.SaveChanges();
                    }
                    else
                    {
                        // vote.
                    }
                    //ViewBag.mk = new SelectList(db.MK, "Id", "mk_name", mK_SCORE.mk);
                    //ViewBag.agendaId = new SelectList(db.AGENDA, "Id", "name", mK_SCORE.agendaId);
                    //return View(mK_SCORE);
                }
            }
        }