コード例 #1
0
        public JsonResult GetCheckOutInfo(int roomId)
        {
            //try
            //{
            var ios = from io in db.InOuts
                      where io.RoomId == roomId && io.Status == 0
                      select io;

            if (ios != null)
            {
                CheckOut checkout = new CheckOut();
                foreach (var io in ios)
                {
                    checkout.CheckinTime        = io.CheckinTime;
                    checkout.CheckInTimeStr     = io.CheckinTime.ToString("dd/MM/yyyy HH:mm");
                    checkout.Note               = io.Note;
                    checkout.OtherServiceAmount = io.OtherServiceAmount;
                    checkout.PersonNumber       = io.PersonNumber;
                    checkout.RoomId             = io.RoomId.Value;
                    checkout.RoomServiceType    = io.RoomServiceType;
                    checkout.TotalAmount        = io.TotalAmount;
                    checkout.OtherServices      = new List <Models.AjaxModel.OtherService>();
                    try
                    {
                        foreach (InOut_OtherServices item in io.InOut_OtherServices)
                        {
                            Models.AjaxModel.OtherService os = new Models.AjaxModel.OtherService();
                            os.OtherServiceId = item.OtherServiceId;
                            os.Quantity       = item.Quantity;
                            os.ServiceName    = item.OtherService.ServiceName;
                            os.Amount         = item.Quantity * item.OtherService.Price;
                            checkout.OtherServices.Add(os);
                        }
                    }
                    catch { }
                }
                var result = Json(new { success = true, data = checkout }, JsonRequestBehavior.AllowGet);
                return(result);
            }
            else
            {
                return(Json(new { success = false, ErrInfo = "Không tìm thấy checkin" }, JsonRequestBehavior.AllowGet));
            }
            //}
            //catch (Exception ex)
            //{
            //    return Json(new { success = false, ErrInfo = ex }, JsonRequestBehavior.DenyGet);
            //}
        }
コード例 #2
0
        public ActionResult Bill(int roomId)
        {
            BillModel billModel = new BillModel();
            var       ios       = from io in db.InOuts
                                  where io.RoomId == roomId && io.Status == 0
                                  select io;

            if (ios != null && ios.Count() > 0)
            {
                foreach (var io in ios)
                {
                    billModel.CheckInTimeStr     = io.CheckinTime.ToString("dd/MM/yyyy HH:mm");
                    billModel.CheckOutTimeStr    = io.CheckOutTime.ToString("dd/MM/yyyy HH:mm");
                    billModel.OtherServiceAmount = io.OtherServiceAmount;
                    billModel.PersonNumber       = io.PersonNumber;
                    billModel.RoomServiceType    = io.RoomServiceType;
                    billModel.TotalAmount        = io.TotalAmount;
                    billModel.RoomServiceAmout   = io.TotalAmount - io.OtherServiceAmount;
                    billModel.RoomName           = io.Room.RoomName;
                    string invoiceNum = io.InOutId.ToString().PadLeft(5, '0');
                    billModel.InvoiceNumber = invoiceNum.Substring(invoiceNum.Length - 5);
                    billModel.LengthStay    = io.LengthStay;
                    billModel.OtherServices = new List <Models.AjaxModel.OtherService>();
                    foreach (InOut_OtherServices item in io.InOut_OtherServices)
                    {
                        Models.AjaxModel.OtherService os = new Models.AjaxModel.OtherService();
                        os.OtherServiceId = item.OtherServiceId;
                        os.Quantity       = item.Quantity;
                        os.ServiceName    = item.OtherService.ServiceName;
                        os.Amount         = item.Quantity * item.OtherService.Price;
                        billModel.OtherServices.Add(os);
                    }
                }
            }
            return(View("Bill", billModel));
        }