예제 #1
0
        public int SaveBooking(string bookingXml, BookingReceipt receipt, int BranchID)
        {
            int retVal = 0;

            try
            {
                //Receipt Header
                int temp = SaveReceiptHeader(bookingXml, receipt.ReceiptHeader);
                if (receipt.ReceiptHeader.BookingID == 0 && temp > 0)
                {
                    receipt.ReceiptHeader.BookingID = temp;
                }
                //Insert LineItems
                SaveLineItems(receipt.LineItems, receipt.ReceiptHeader.BookingID);
                //Update Identity values in Xml
                bookingXml = UpdateIdentityValuesInXml(bookingXml, receipt);
                SaveBookingXml(bookingXml, receipt.ReceiptHeader.BookingID);
                //Manoj to add Old booking structure code

                retVal = InitializeNewBooking();
            }
            catch (Exception e)
            {
                retVal = -1;
            }
            return(retVal);
        }
예제 #2
0
        public BookingsRecordJsonModel(BookingReceipt receipt)
        {
            ID             = receipt.ID;
            CustomerName   = receipt.AspNetUser.FullName;
            CustomertEmail = receipt.AspNetUser.Email;
            CustomerPhone  = receipt.AspNetUser.PhoneNumber;
            VehicleID      = receipt.VehicleID;
            VehicleName    = receipt.VehicleName;
            LicenseNumber  = receipt.LicenseNumber;
            RentalPrice    = receipt.RentalPrice;
            Deposit        = receipt.Deposit;
            StartTime      = receipt.StartTime;
            EndTime        = receipt.EndTime;
            Star           = receipt.Star;
            Comment        = receipt.Comment != null?Regex.Replace(receipt.Comment, @"\r\n?|\n", "<br>") : null;

            DateTime now = DateTime.Now;

            if (receipt.StartTime < now)
            {
                IsInThePast = true;
            }
            else
            {
                IsInThePast = false;
            }

            IsCanceled    = receipt.IsCanceled;
            IsSelfBooking = receipt.Garage.OwnerID == receipt.CustomerID;
        }
예제 #3
0
        private void BookingReceiptForm_Load(object sender, EventArgs e)
        {
            ReceiptQuery  db            = new ReceiptQuery();
            BookingDetail bookingDetail = new BookingDetail();
            DataSet       ds            = db.Booking_Receipt(transID);

            // Get values from query result
            bookingDetail.TransactionID   = Convert.ToInt16(ds.Tables[0].Rows[0]["TransactionID"]);
            bookingDetail.FacilityName    = ds.Tables[0].Rows[0]["FacilityName"].ToString();
            bookingDetail.MemberName      = ds.Tables[0].Rows[0]["MemberName"].ToString();
            bookingDetail.TransactionDate = Convert.ToDateTime(ds.Tables[0].Rows[0]["TransDate"]);
            bookingDetail.StartTime       = Convert.ToInt16(ds.Tables[0].Rows[0]["StartTime"]);
            bookingDetail.EndTime         = Convert.ToInt16(ds.Tables[0].Rows[0]["EndTime"]);

            // Fill receipt with values
            BookingReceipt br = new BookingReceipt();

            br.SetParameterValue("pTransactionID", bookingDetail.TransactionID);
            br.SetParameterValue("pMemberID", bookingDetail.MemberName);
            br.SetParameterValue("pFacilityID", bookingDetail.FacilityName);
            br.SetParameterValue("pTransactionDate", bookingDetail.TransactionDate);
            br.SetParameterValue("pStartTime", bookingDetail.StartTime);
            br.SetParameterValue("pEndTime", bookingDetail.EndTime);

            br.SetParameterValue("pTransactionID", bookingDetail.TransactionID);
            br.SetParameterValue("pMemberID", bookingDetail.MemberName);
            br.SetParameterValue("pFacilityID", bookingDetail.FacilityName);
            br.SetParameterValue("pTransactionDate", bookingDetail.TransactionDate);
            br.SetParameterValue("pStartTime", bookingDetail.StartTime);
            br.SetParameterValue("pEndTime", bookingDetail.EndTime);

            crystalReportViewer1.ReportSource = br;
        }
예제 #4
0
 public BookingHistoryDataTablesRecordModel(BookingReceipt br)
 {
     ID                 = br.ID;
     RentalPrice        = br.RentalPrice;
     Deposit            = br.Deposit;
     BookingFee         = br.BookingFee;
     Distance           = br.Distance;
     HasStar            = br.Star.HasValue;
     StartTime          = br.StartTime.ToUniversalTime().ToString("o");
     EndTime            = br.EndTime.ToUniversalTime().ToString("o");
     IsCanceled         = br.IsCanceled;
     GarageName         = br.GarageName;
     GarageAddress      = br.GarageAddress;
     GaragePhone        = br.GaragePhone;
     GarageEmail        = br.GarageEmail;
     VehicleID          = br.VehicleID;
     VehicleName        = br.VehicleName;
     Year               = br.Vehicle.Year;
     NumOfSeat          = br.Vehicle.VehicleModel.NumOfSeat;
     NumOfDoor          = br.Vehicle.VehicleModel.NumOfDoor;
     TransmissionType   = Constants.TRANSMISSION_TYPE[br.Vehicle.TransmissionType];
     TransmissionDetail = br.TransmissionDetail;
     FuelType           = br.Vehicle.FuelType == null ? null : Constants.FUEL_TYPE[br.Vehicle.FuelType.Value];
     Engine             = Engine;
     Color              = Constants.COLOR[br.Color];
 }
예제 #5
0
        private string UpdateIdentityValuesInXml(string bookingXml, BookingReceipt receipt)
        {
            string retVal = bookingXml;

            XmlDocument xml = new XmlDocument();

            xml.LoadXml(bookingXml);
            //BookingID
            SetIdentityValue(xml, "//receiptheader", receipt.ReceiptHeader.BookingID);
            //xml.SelectSingleNode("//receiptheader").Attributes["identity"].Value = receipt.ReceiptHeader.BookingID.ToString();
            //LineItems
            foreach (BookingLineItem lineItem in receipt.LineItems)
            {
                //BookingItemID
                string lineItemPath = "//lineitems/lineItem[@sequence='" + lineItem.ItemDetails.Sequence.ToString() + "']";
                //Item
                string tempPath = "/item[@id='" + lineItem.ItemDetails.ItemID.ToString() + "']";
                SetIdentityValue(xml, lineItemPath + tempPath, lineItem.ItemDetails.BookingItemID);

                //Patterns
                foreach (Booking_Items_Patterns pattern in lineItem.Patterns)
                {
                    tempPath = "/patterns/pattern[@id='" + pattern.PatternID.ToString() + "']";
                    SetIdentityValue(xml, lineItemPath + tempPath, pattern.Booking_ItemPatternID);
                }
                //Colors
                foreach (Booking_Items_Colors color in lineItem.Colors)
                {
                    tempPath = "/colors/color[@id='" + color.ColorID.ToString() + "']";
                    SetIdentityValue(xml, lineItemPath + tempPath, color.Booking_ItemColorID);
                }
                //SubItems
                foreach (Booking_Items_SubItems subItem in lineItem.SubItems)
                {
                    tempPath = "/subItems/subItem[@id='" + subItem.SubItemID.ToString() + "']";
                    SetIdentityValue(xml, lineItemPath + tempPath, subItem.Booking_ItemSubItemID);
                }
                //Brands
                foreach (Booking_Items_Brands brand in lineItem.Brands)
                {
                    tempPath = "/brands/brand[@id='" + brand.BrandID.ToString() + "']";
                    SetIdentityValue(xml, lineItemPath + tempPath, brand.Booking_ItemBrandID);
                }
                //Comments
                foreach (Booking_Items_Comments comment in lineItem.Comments)
                {
                    tempPath = "/comments/comment[@id='" + comment.CommentID.ToString() + "']";
                    SetIdentityValue(xml, lineItemPath + tempPath, comment.Booking_ItemCommentID);
                }
                //Processes
                foreach (Booking_Items_Processes process in lineItem.Processes)
                {
                    tempPath = "/processes/process[@id='" + process.ProcessID.ToString() + "']";
                    SetIdentityValue(xml, lineItemPath + tempPath, process.Booking_ItemProcessID);
                }
            }
            retVal = xml.OuterXml;
            return(retVal);
        }
예제 #6
0
        public int SaveBooking(string bookingXml, int BranchID)
        {
            //Transform Xml into DTO
            BookingReceiptTransformer trans      = new BookingReceiptTransformer(bookingXml, BranchID);
            BookingReceipt            objReceipt = trans.Transform();

            return(DALFactory.Instance.BookingDAO.SaveBooking(bookingXml, objReceipt, BranchID));
        }
예제 #7
0
        public BookingReceipt Transform()
        {
            BookingReceipt _objReceipt = new BookingReceipt();

            _objReceipt.ReceiptHeader = PopulateReceiptHeader();
            _objReceipt.LineItems     = PopulateLineItems();
            return(_objReceipt);
        }
예제 #8
0
        // Calc the attribute vectors of an user's booking
        private static List <double> GenerateAttributeVectorsOfBooking(BookingReceipt booking,
                                                                       IEnumerable <string> neighborIdList,
                                                                       IEnumerable <int> numOfSeatList,
                                                                       IEnumerable <int> numOfDoorList,
                                                                       IEnumerable <VehicleBrand> brandList,
                                                                       IEnumerable <Category> categoryList,
                                                                       int numOfAttribute)
        {
            var vectorList = new List <double>();

            // Apply user's interest
            double interestPoint;

            if (booking.Star == null || booking.Star == 3)
            {
                // All attribute equal 0 now
                for (var i = 0; i < numOfAttribute; i++)
                {
                    vectorList.Add(0);
                }
                return(vectorList);
            }
            else if (booking.Star > 3)
            {
                interestPoint = 1;                 // star > 3
            }
            else
            {
                interestPoint = -1;                 // star < 3
            }

            // TranmissionType Attributes
            vectorList.AddRange(Constants.TRANSMISSION_TYPE.Select(attribute => booking.Vehicle.TransmissionType == attribute.Key ? interestPoint : 0).ToList());

            // FuelType Attributes
            vectorList.AddRange(Constants.FUEL_TYPE.Select(attribute => booking.Vehicle.FuelType == attribute.Key ? interestPoint : 0));

            // Color Attributes
            vectorList.AddRange(Constants.COLOR.Select(attribute => booking.Vehicle.Color == attribute.Key ? interestPoint : 0));

            // NumOfSeat Attributes
            vectorList.AddRange(numOfSeatList.Select(attribute => booking.Vehicle.VehicleModel.NumOfSeat == attribute ? interestPoint : 0));

            // NumOfDoor Attributes
            vectorList.AddRange(numOfDoorList.Select(attribute => booking.Vehicle.VehicleModel.NumOfDoor == attribute ? interestPoint : 0));

            // Brand Attributes
            vectorList.AddRange(brandList.Select(attribute => booking.Vehicle.VehicleModel.BrandID == attribute.ID ? interestPoint : 0));

            // Category Attributes
            vectorList.AddRange(categoryList.Select(attribute => booking.Vehicle.VehicleModel.Categories.Contains(attribute) ? interestPoint : 0));

            // Similar user attributes.
            vectorList.AddRange(neighborIdList.Select(attribute => booking.Vehicle.BookingReceipts.Any(b => b.CustomerID == attribute) ? interestPoint : 0));

            return(vectorList);
        }
예제 #9
0
        // Mail on canceling booking to provider
        public async Task SendBookingCanceledAlertEmailToProvider(BookingReceipt booking)
        {
            var mailMessage = new MailMessage("*****@*****.**", booking.Garage.Email)
            {
                Subject = "Giao dịch đặt xe mới trên hệ thống CRP",
                Body    = "Lịch đặt xe từ " + booking.StartTime.ToString(@"dd\/MM\/yyyy HH:mm") + " đến " + booking.EndTime.ToString(@"dd\/MM\/yyyy HH:mm") + " bởi khách hàng " + booking.AspNetUser.FullName + " cho xe " + booking.VehicleName + " của bạn vừa được hủy."
            };

            await SendEmail(mailMessage);
        }
예제 #10
0
        // Mail on canceling booking to customer
        public async Task SendBookingCanceledAlertEmailToCustomer(BookingReceipt booking)
        {
            var mailMessage = new MailMessage("*****@*****.**", booking.AspNetUser.Email)
            {
                Subject = "Hủy đặt xe trên hệ thống CRP",
                Body    = "Bạn vừa tiến hành hủy đặt xe " + booking.VehicleName + " thành công trên hệ thống của chúng tôi.\n Xin cảm ơn."
            };

            await SendEmail(mailMessage);
        }
예제 #11
0
        //gui mail thong bao ve Booking moi
        public async Task SendBookingAlertEmailToCustomer(BookingReceipt booking)
        {
            var mailMessage = new MailMessage("*****@*****.**", booking.AspNetUser.Email)
            {
                Subject = "Giao dịch đặt xe mới trên hệ thống CRP",
                Body    = "Bạn vừa tiến hành đặt xe " + booking.VehicleName + " thành công trên hệ thống của chúng tôi.\nChúc bạn có một chuyến đi vui vẻ."
            };

            await SendEmail(mailMessage);
        }
예제 #12
0
        //gui mail thong bao ve Booking moi
        public async Task SendBookingAlertEmailToProvider(BookingReceipt booking)
        {
            var mailMessage = new MailMessage("*****@*****.**", booking.Garage.Email)
            {
                Subject = "Giao dịch đặt xe mới trên hệ thống CRP",
                Body    = "Xe " + booking.VehicleName + " của bạn vừa được đặt từ " + booking.StartTime.ToString(@"dd\/MM\/yyyy HH:mm") + " đến " + booking.EndTime.ToString(@"dd\/MM\/yyyy HH:mm") + " bởi khách hàng " + booking.AspNetUser.FullName + ".\n"
                          + "Bạn có thể liên hệ với khách hàng qua email <a href=\"mailto:" + booking.AspNetUser.Email + "\">" + booking.AspNetUser.Email + "</a> hoặc qua số điện thoại <a href=\"tel:" + booking.AspNetUser.PhoneNumber + "\">" + booking.AspNetUser.PhoneNumber + "</a>."
            };

            await SendEmail(mailMessage);
        }
예제 #13
0
 public void GetCommentData(BookingReceipt booking)
 {
     if (booking.Comment != null || booking.Star != null)
     {
         var data = new CommentModel
         {
             VehicleID     = booking.VehicleID,
             VehicleName   = booking.VehicleName,
             UserName      = booking.AspNetUser.UserName,
             UserAvatarUrl = booking.AspNetUser.AvatarURL,
             Star          = booking.Star
         };
         Comment.Add(data);
     }
 }
        private void printButton_Click(object sender, EventArgs e)
        {
            BookingReceipt br = new BookingReceipt(bookID); // TODO: to provide arguments

            br.ShowDialog();
        }
예제 #15
0
        public async Task <ActionResult> CreateOwnBookingAPI(DateTime startTime, DateTime endTime, int vehicleID)
        {
            var bookingService = this.Service <IBookingReceiptService>();
            var vehicleService = this.Service <IVehicleService>();

            var currentUserID = User.Identity.GetUserId();

            var vehicle = vehicleService.Get(v => v.ID == vehicleID && v.Garage.OwnerID == currentUserID).FirstOrDefault();

            // Check if vehicle exists
            if (vehicle == null)
            {
                return(new HttpStatusCodeResult(400, "Not found."));
            }

            // Check if startTime is after now
            if (startTime < DateTime.Now)
            {
                return(Json(new {
                    isSuccess = false,
                    errorMessage = "Thời gian bắt đầu phải nằm sau thời gian hiện tại."
                }, JsonRequestBehavior.AllowGet));
            }

            // Check if endTime is after now
            if (endTime < startTime)
            {
                return(Json(new {
                    isSuccess = false,
                    errorMessage = "Thời gian kết thúc phải nằm sau thời gian bắt đầu."
                }, JsonRequestBehavior.AllowGet));
            }

            // Check if this vehicle has any other bookings in the timespan of this booking
            var needCheckingStartTime = startTime.AddHours(-Constants.IN_BETWEEN_BOOKING_REST_TIME_IN_HOUR);
            var needCheckingEndTime   = endTime.AddHours(Constants.IN_BETWEEN_BOOKING_REST_TIME_IN_HOUR);

            if (vehicle.BookingReceipts.Any(br => !br.IsCanceled && (
                                                (needCheckingStartTime > br.StartTime &&
                                                 needCheckingStartTime < br.EndTime) ||
                                                (needCheckingEndTime > br.StartTime &&
                                                 needCheckingEndTime < br.EndTime) ||
                                                (needCheckingStartTime <= br.StartTime &&
                                                 needCheckingEndTime >= br.EndTime)
                                                )))
            {
                return(Json(new
                {
                    isSuccess = false,
                    errorMessage = "Xe đã được đặt trong khoảng thời gian này."
                }, JsonRequestBehavior.AllowGet));
            }

            // Checked OK. Create new booking.
            var newBooking = new BookingReceipt()
            {
                CustomerID         = currentUserID,
                BookingTime        = DateTime.Now,
                StartTime          = startTime,
                EndTime            = endTime,
                GarageID           = vehicle.GarageID,
                VehicleID          = vehicleID,
                RentalPrice        = 0,
                Deposit            = 0,
                BookingFee         = 0,
                GarageName         = vehicle.Garage.Name,
                GarageAddress      = vehicle.Garage.Address + ", " + vehicle.Garage.Location.Name,
                GaragePhone        = vehicle.Garage.Phone1,
                GarageEmail        = vehicle.Garage.Email,
                LicenseNumber      = vehicle.LicenseNumber,
                VehicleName        = vehicle.Name,
                TransmissionDetail = vehicle.TransmissionDetail,
                Engine             = vehicle.Engine,
                Color = vehicle.Color
            };

            await bookingService.CreateAsync(newBooking);

            return(Json(new { isSuccess = true }));
        }
        private void Okbtn_Click_1(object sender, EventArgs e)
        {
            BookingFromTime.MinDate = BookingDateDtTimePckr.Value.Date + fromts;
            BookingToTime.MaxDate   = BookingDateDtTimePckr.Value.Date + tots;

            // convert booking date from
            int      BookingTimeFrom = BookingFromTime.Value.Hour;
            int      BookingTimeTo   = BookingToTime.Value.Hour;
            DateTime bkgdt           = BookingFromTime.Value.Date;
            bool     value;

            TimeSpan s = new TimeSpan(BookingTimeTo, 0, 0);
            TimeSpan t = new TimeSpan(BookingTimeFrom, 0, 0);

            BookingToTime.Value   = BookingDateDtTimePckr.Value.Date + s;
            BookingFromTime.Value = BookingDateDtTimePckr.Value.Date + t;


            //assign f according to facility booked.
            f = ctx.Facilities.Where(x => x.FacilityName == facilityList.Text).First();

            b = new Booking();
            // table values

            try
            {
                b.BookingID       = bList[bList.Count - 1].BookingID + 1;
                b.BookingDateFrom = BookingFromTime.Value;
                b.BookingDateTo   = BookingToTime.Value;
                b.FacilitiesID    = f.FacilityID;
                b.MemberID        = Int32.Parse(txtMemberID.Text);
                b.IssueDate       = DateTime.Today;
                b.NumberofPax     = Int32.Parse(txtNoOfPax.Text);
            }
            catch
            {
                MessageBox.Show("Please ensure all fields are filled.");
                return;
            }



            // check if
            value = Program.ValidateBooking(bkgdt, f.FacilityName, BookingTimeFrom, BookingTimeTo);

            if (value)
            {
                ctx.Bookings.Add(b);
                ctx.SaveChanges();
                MessageBox.Show("Booking Successfully Saved");
                FunctionRefresh();
                DialogResult res = MessageBox.Show("Do you want to print a receipt?", "Confirmation", MessageBoxButtons.OKCancel, MessageBoxIcon.Information);
                if (res == DialogResult.OK)
                {
                    BookingReceipt br = new BookingReceipt(b.BookingID);
                    br.ShowDialog();
                    Close();
                }
                else
                {
                    Close();
                }
                if (refToAvailabiltyForm != null)
                {
                    refToAvailabiltyForm.RenderDataGrid();
                }
            }
            else
            {
                MessageBox.Show("Slot is not available");
            }
        }