public frmIns_BookingHalls_Services(frmTsk_Payment_Step2 afrmTsk_Payment_Step2 ,int IDBookingHall,NewPaymentEN aNewPayment)
 {
     InitializeComponent();
     this.afrmTsk_Payment_Step2 = afrmTsk_Payment_Step2;
     this.IDBookingHall = IDBookingHall;
     this.aNewPayment = aNewPayment;
 }
        private void btnPrintByCustomer_Click(object sender, EventArgs e)
        {
            CustomersBO aCustomersBO = new CustomersBO();
            Customers aCustomer = new Customers();
            aCustomer = aCustomersBO.Select_ByID(int.Parse(loeListCustomer.EditValue.ToString()));
            this.aNewPaymentEN = this.aNewPaymentEN.SlipPaymentByCustomer(aCustomer);

            try
            {
                if (this.aNewPaymentEN.Status_BookingR == 8 || this.aNewPaymentEN.Status_BookingR == 7)
                {

                    frmRpt_Payment_BookingRs afrmRpt_Payment_BookingRs = new frmRpt_Payment_BookingRs(this.aNewPaymentEN);
                    ReportPrintTool tool = new ReportPrintTool(afrmRpt_Payment_BookingRs);
                    tool.ShowPreview();
                }
                else
                {
                    frmRpt_Payment_BookingRsUnPay afrmRpt_Payment_BookingRs = new frmRpt_Payment_BookingRsUnPay(this.aNewPaymentEN);
                    ReportPrintTool tool = new ReportPrintTool(afrmRpt_Payment_BookingRs);
                    tool.ShowPreview();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_ChoosePrintType.btnPrint_Click\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 // Truyền thêm đối số NewPayment để khi thêm dịch vụ từ form Payment sẽ load lại số dịch vụ đã thêm, các thông số còn lại vẫn để nguyên vì chưa chỉnh sửa hết được)
 public frmTsk_UseServices(frmTsk_Payment_Step2 afrmTsk_Payment_Step2, string CodeRoom, int IDBookingRs, int IDBookingRoom, NewPaymentEN aNewPayment)
 {
     InitializeComponent();
     this.afrmTsk_Payment_Step2 = afrmTsk_Payment_Step2;
     this.CodeCurrentRoom = CodeRoom;
     this.IDBookingRs = IDBookingRs;
     this.IDBookingRoom = IDBookingRoom;
     this.aNewPayment = aNewPayment;
 }
 //Hiennv
 public void LoadListServicesH_ByIndexSubPayment(NewPaymentEN aNewPaymentEN, int IndexSubPayment)
 {
     try
     {
         this.aListServicesH.Clear();
         this.aListServicesH = aNewPaymentEN.GetAllServiceUsedInHall().Where(r => r.IndexSubPayment == IndexSubPayment).OrderBy(r => r.Sku).ToList();
         dgvServicesHall.DataSource = this.aListServicesH;
         dgvServicesHall.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_SplitBill_Step2.LoadListServices_ByIndexSubServices\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 //Hiennv
 public void LoadListRooms_ByIndexSubPayment(NewPaymentEN aNewPaymentEN, int IndexSubPayment)
 {
     try
     {
         this.aListRooms.Clear();
         this.aListRooms = aNewPaymentEN.aListBookingRoomUsed.Where(r => r.IndexSubPayment == IndexSubPayment).OrderBy(r => r.RoomSku).ToList();
         dgvRooms.DataSource = this.aListRooms;
         dgvRooms.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_SplitBill_Step2.LoadListRooms_ByIndexSubRooms\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 public frmTsk_SplitBill_Step2(frmTsk_SplitBill_Step1 afrmTsk_SplitBill_Step1, NewPaymentEN aNewPaymentEN)
 {
     InitializeComponent();
     this.afrmTsk_SplitBill_Step1 = afrmTsk_SplitBill_Step1;
     this.aNewPaymentEN = aNewPaymentEN;
 }
        public frmRpt_Payment_BookingRsAndBookingHs(NewPaymentEN aNewPaymentEN)
        {
            InitializeComponent();
            this.aNewPaymentEN = aNewPaymentEN;
            try
            {

                lblNumberVote.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblIIDBookingR.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblNameCustomer.Text = this.aNewPaymentEN.NameCustomer;
                lblGroup.Text = this.aNewPaymentEN.NameCustomerGroup;
                lblCompany.Text = this.aNewPaymentEN.NameCompany;
                lblTaxNumberCode.Text = this.aNewPaymentEN.TaxNumberCodeCompany;

                int day = DateTime.Now.Day;
                int month = DateTime.Now.Month;
                int year = DateTime.Now.Year;
                lblDayMonthYear.Text = "Hà nội , ngày " + day.ToString() + " tháng " + month.ToString() + " năm " + year.ToString();

                #region Phòng

                aListServiceUsedRoom = this.aNewPaymentEN.GetAllServiceUsedInRoom();
                //Lấy List< IDServiceGroup>
                List<int> aTemp = new List<int>();
                int IDServiceGroup;
                foreach (ServiceUsedEN item in aListServiceUsedRoom)
                {
                    IDServiceGroup = new int();
                    IDServiceGroup = item.IDServiceGroup;
                    aTemp.Add(IDServiceGroup);
                }
                aListIDServicesGroupRoom = aTemp.Distinct().ToList();

                ServiceGroupEN aServicesGroupEN;
                ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();

                foreach (int item in aListIDServicesGroupRoom)
                {
                    aServicesGroupEN = new ServiceGroupEN();
                    aServicesGroupEN.IDServiceGroup = item;
                    aServicesGroupEN.TotalMoneyBeforeTax = this.GetTotalMoneyServiceGroupRoomBeforeTax(item);
                    aServicesGroupEN.TotalMoneyAfterTax = this.GetTotalMoneyServiceGroupRoomAfterTax(item);
                    aServicesGroupEN.DisplayMoneyTax = aNewPaymentEN.GetMoneyTax(this.GetTotalMoneyServiceGroupRoomBeforeTax(item), 10);
                    aServicesGroupEN.ServiceGroupName = aServiceGroupsBO.Sel_ByID(item).Name;
                    aListServicesGroupRoomEN.Add(aServicesGroupEN);
                }

                //danh sach phong
                this.DetailReport.DataSource = aNewPaymentEN.aListBookingRoomUsed;

                colSkuRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "RoomSku");
                colCheckIn.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckInActual", "{0:dd-MM-yyyy HH:mm}");
                colCheckOut.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckOutActual", "{0:dd-MM-yyyy HH:mm}");
                colBookingRoomCost.DataBindings.Add("Text", this.DetailReport.DataSource, "Cost", "{0:0,0}");
                colDateInUse.DataBindings.Add("Text", this.DetailReport.DataSource, "DateUsed", "{0:0,0}");
                colMoneyRoomBeforeTax.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoomBeforeTax", "{0:0,0}");
                colPercentTaxRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "DisplayMoneyTaxRoom", "{0:0,0}");
                colPaymentMoneyRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoom", "{0:0,0}");

                XRSummary aXRSummaryMoneyRoomBeforeTax = new XRSummary();
                aXRSummaryMoneyRoomBeforeTax.Func = SummaryFunc.Sum;
                aXRSummaryMoneyRoomBeforeTax.Running = SummaryRunning.Group;
                aXRSummaryMoneyRoomBeforeTax.IgnoreNullValues = true;
                aXRSummaryMoneyRoomBeforeTax.FormatString = "{0:0,0}";
                XRBinding aXRBindingMoneyRoomBeforeTax = new XRBinding("Text", this.DetailReport.DataSource, "MoneyRoomBeforeTax", "{0:0,0}");
                XRBinding[] listXRBindingMoneyRoomBeforeTax = new XRBinding[] { aXRBindingMoneyRoomBeforeTax };
                lblSumMoneyRoomsBeforeTax.DataBindings.AddRange(listXRBindingMoneyRoomBeforeTax);
                lblSumMoneyRoomsBeforeTax.Summary = aXRSummaryMoneyRoomBeforeTax;

                XRSummary aXRSummaryDisplayMoneyTaxRoom = new XRSummary();
                aXRSummaryDisplayMoneyTaxRoom.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyTaxRoom.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyTaxRoom.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyTaxRoom.FormatString = "{0:0,0}";
                XRBinding aXRBindingDisplayMoneyTaxRoom = new XRBinding("Text", this.DetailReport.DataSource, "DisplayMoneyTaxRoom", "{0:0,0})");
                XRBinding[] listXRBindingDisplayMoneyTaxRoom = new XRBinding[] { aXRBindingDisplayMoneyTaxRoom };
                lblSumMoneyRoomTax.DataBindings.AddRange(listXRBindingDisplayMoneyTaxRoom);
                lblSumMoneyRoomTax.Summary = aXRSummaryDisplayMoneyTaxRoom;

                XRSummary aXRSummaryMoneyRoom = new XRSummary();
                aXRSummaryMoneyRoom.Func = SummaryFunc.Sum;
                aXRSummaryMoneyRoom.Running = SummaryRunning.Group;
                aXRSummaryMoneyRoom.IgnoreNullValues = true;
                aXRSummaryMoneyRoom.FormatString = "{0:0,0}";
                XRBinding aXRBindingMoneyRoom = new XRBinding("Text", this.DetailReport.DataSource, "MoneyRoom", "{0:0,0}");
                XRBinding[] listXRBindingMoneyRoom = new XRBinding[] { aXRBindingMoneyRoom };
                lblSumMoneyRoomsAfterTax.DataBindings.AddRange(listXRBindingMoneyRoom);
                lblSumMoneyRoomsAfterTax.Summary = aXRSummaryMoneyRoom;

                //danh sach dich vu
                this.DetailReport2.DataSource = aListServicesGroupRoomEN;
                colNamServiceRoom.DataBindings.Add("Text", this.DetailReport2.DataSource, "ServiceGroupName");
                colTotalMoneyServiceRoomBeforeTax.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoneyBeforeTax", "{0:0,0}");
                colPercentTaxServiceRoom.DataBindings.Add("Text", this.DetailReport2.DataSource, "DisplayMoneyTax", "{0:0,0}");
                colTotalMoneyServiceRoomAfterTax.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoneyAfterTax", "{0:0,0}");

                XRSummary aXRSummaryTotalMoneyBeforeTax = new XRSummary();
                aXRSummaryTotalMoneyBeforeTax.Func = SummaryFunc.Sum;
                aXRSummaryTotalMoneyBeforeTax.Running = SummaryRunning.Group;
                aXRSummaryTotalMoneyBeforeTax.IgnoreNullValues = true;
                aXRSummaryTotalMoneyBeforeTax.FormatString = "{0:0,0}";
                lblSumMoneyServiceRoomsBeforeTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReport2.DataSource, "TotalMoneyBeforeTax", "{0:0,0}") });
                lblSumMoneyServiceRoomsBeforeTax.Summary = aXRSummaryTotalMoneyBeforeTax;

                XRSummary aXRSummaryDisplayMoneyTax = new XRSummary();
                aXRSummaryDisplayMoneyTax.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyTax.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyTax.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyTax.FormatString = "{0:0,0}";
                lblSumMoneyServiceRoomsTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReport2.DataSource, "DisplayMoneyTax", "{0:0,0}") });
                lblSumMoneyServiceRoomsTax.Summary = aXRSummaryDisplayMoneyTax;

                XRSummary aXRSummaryTotalMoneyAfterTax = new XRSummary();
                aXRSummaryTotalMoneyAfterTax.Func = SummaryFunc.Sum;
                aXRSummaryTotalMoneyAfterTax.Running = SummaryRunning.Group;
                aXRSummaryTotalMoneyAfterTax.IgnoreNullValues = true;
                aXRSummaryTotalMoneyAfterTax.FormatString = "{0:0,0}";
                lblSumMoneyServiceRoomsAfterTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReport2.DataSource, "TotalMoneyAfterTax", "{0:0,0}") });
                lblSumMoneyServiceRoomsAfterTax.Summary = aXRSummaryTotalMoneyAfterTax;

                #endregion
                #region Hội trường
                aListServiceUsedHall = this.aNewPaymentEN.GetAllServiceUsedInHall();
                //Lấy List< IDServiceGroup>
                List<int> aTemp1 = new List<int>();
                int IDServiceGroupHall;
                foreach (ServiceUsedEN item in aListServiceUsedHall)
                {
                    IDServiceGroupHall = new int();
                    IDServiceGroupHall = item.IDServiceGroup;
                    aTemp1.Add(IDServiceGroupHall);
                }
                aListIDServicesGroupHall = aTemp1.Distinct().ToList();

                ServiceGroupEN aServicesGroupHallEN;
                foreach (int item in aListIDServicesGroupHall)
                {
                    aServicesGroupHallEN = new ServiceGroupEN();
                    aServicesGroupHallEN.IDServiceGroup = item;
                    aServicesGroupHallEN.TotalMoneyBeforeTax = this.GetTotalMoneyServiceGroupHallBeforeTax(item);
                    aServicesGroupHallEN.TotalMoneyAfterTax = this.GetTotalMoneyServiceGroupHallAfterTax(item);
                    aServicesGroupHallEN.DisplayMoneyTax = aNewPaymentEN.GetMoneyTax(this.GetTotalMoneyServiceGroupHallBeforeTax(item), 10);
                    aServicesGroupHallEN.ServiceGroupName = aServiceGroupsBO.Sel_ByID(item).Name;
                    aListServicesGroupHallEN.Add(aServicesGroupHallEN);
                }

                //danh sach hoi truong
                this.DetailReportHall.DataSource = aNewPaymentEN.aListBookingHallUsed;
                colSkuHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "HallSku");
                colCreateDate.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Date", "{0:dd/MM/yyyy}");
                colBookingHallCost.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Cost", "{0:0,0}");
                colPercentTax.DataBindings.Add("Text", this.DetailReportHall.DataSource, "DisplayMoneyTaxHall", "{0:0,0}");
                colPaymentMoneyHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "MoneyHall", "{0:0,0}");

                XRSummary aXRSummaryDisplayMoneyTaxHall = new XRSummary();
                aXRSummaryDisplayMoneyTaxHall.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyTaxHall.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyTaxHall.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyTaxHall.FormatString = "{0:0,0}";
                XRBinding aXRBindingDisplayMoneyTaxHall = new XRBinding("Text", this.DetailReportHall.DataSource, "DisplayMoneyTaxHall", "{0:0,0}");
                XRBinding[] listXRBindingDisplayMoneyTaxHall = new XRBinding[] { aXRBindingDisplayMoneyTaxHall };
                lblSumMoneyHallsTax.DataBindings.AddRange(listXRBindingDisplayMoneyTaxHall);
                lblSumMoneyHallsTax.Summary = aXRSummaryDisplayMoneyTaxHall;

                //danh sach dich vu su dung
                this.DetailReportService.DataSource = aListServicesGroupHallEN;
                colNamServiceHall.DataBindings.Add("Text", this.DetailReportService.DataSource, "ServiceGroupName");
                colTotalMoneyServiceHallBeforeTax.DataBindings.Add("Text", this.DetailReportService.DataSource, "TotalMoneyBeforeTax", "{0:0,0}");
                colPercentTaxServiceHall.DataBindings.Add("Text", this.DetailReportService.DataSource, "DisplayMoneyTax", "{0:0,0}");

                colTotalMoneyServiceHallAfterTax.DataBindings.Add("Text", this.DetailReportService.DataSource, "TotalMoneyAfterTax", "{0:0,0}");

                XRSummary aXRSummaryDisplayMoneyServiceHallTax = new XRSummary();
                aXRSummaryDisplayMoneyServiceHallTax.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyServiceHallTax.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyServiceHallTax.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyServiceHallTax.FormatString = "{0:0,0}";
                lblSumMoneyServiceHallsTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReportService.DataSource, "DisplayMoneyTax", "{0:0,0}") });
                lblSumMoneyServiceHallsTax.Summary = aXRSummaryDisplayMoneyServiceHallTax;

                //tong tien hoi truong truoc thue
                lblSumMoneyHallsBeforeTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetOnlyMoneyHallsBeforeTax()));
                //tong tien hoi truong sau thue
                lblSumMoneyHallsAfterTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetOnlyMoneyHalls()));

                //tong tien dich vu hoi truong truoc thue
                lblSumMoneyServiceHallsBeforeTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyServiceUsedInHallsBeforeTax()));
                //tong tien dich vu hoi truong sau thue
                lblSumMoneyServiceHallsAfterTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyServiceUsedInHalls()));

                //Tong tien hoa don can thanh toan
                decimal? beforTax = Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyBeforeTax());
                decimal? afterTax = Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoney());
                decimal? bookingMoney = Convert.ToDecimal(this.aNewPaymentEN.BookingHMoney) + Convert.ToDecimal(this.aNewPaymentEN.BookingRMoney);

                //tong tien thanh toan truoc thue
                lblTotalMoneyBeforeTax.Text = String.Format("{0:0,0}", beforTax);
                //tien thue
                lblTotalMoneyTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetMoneyTax(beforTax, 10)));
                //tong tien thanh toan sau thue
                lblTotalMoneyAfterTax.Text = String.Format("{0:0,0}", afterTax);
                //So tien ung truoc
                lblBookingMoney.Text = String.Format("{0:0,0}", bookingMoney);
                //so tien con lai can thanh toan
                lblTotalMoney.Text = String.Format("{0:0,0}", afterTax - bookingMoney);
                string TotalMoney_BookingRString = UppercaseFirst(StringUtility.ConvertDecimalToString(Convert.ToDecimal(afterTax - bookingMoney)));

                lblTotalMoneyString.Text = "(" + TotalMoney_BookingRString + ")";
                #endregion
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public NewPaymentEN Clone(NewPaymentEN aNewPaymentEN)
        {
            this.aListBookingHallUsed.Clear();
               this.aListBookingHallUsed.InsertRange(0,aNewPaymentEN.aListBookingHallUsed);

               this.aListBookingRoomUsed.Clear();
               for (int i = 0; i < aNewPaymentEN.aListBookingRoomUsed.Count; i++)
               {
               this.aListBookingRoomUsed.Add((new BookingRoomUsedEN()).Clone(aNewPaymentEN.aListBookingRoomUsed[i]));
               }

               this.IDBookingH = aNewPaymentEN.IDBookingH;
               this.IDBookingR = aNewPaymentEN.IDBookingR;
               this.CreatedDate_BookingH = aNewPaymentEN.CreatedDate_BookingH;
               this.CreatedDate_BookingR = aNewPaymentEN.CreatedDate_BookingR;
               this.CustomerType = aNewPaymentEN.CustomerType;
               this.PayMenthodR = aNewPaymentEN.PayMenthodR;
               this.PayMenthodH = aNewPaymentEN.PayMenthodH;
               this.StatusPay = aNewPaymentEN.StatusPay;
               this.BookingHMoney = aNewPaymentEN.BookingHMoney;
               this.BookingRMoney = aNewPaymentEN.BookingRMoney;
               this.Status_BookingR = aNewPaymentEN.Status_BookingR;
               this.Status_BookingH = aNewPaymentEN.Status_BookingH;
               this.IDCustomer = aNewPaymentEN.IDCustomer;
               this.NameCustomer = aNewPaymentEN.NameCustomer;
               this.IDSystemUser = aNewPaymentEN.IDSystemUser;
               this.NameSystemUser = aNewPaymentEN.NameSystemUser;
               this.IDCustomerGroup = aNewPaymentEN.IDCustomerGroup;
               this.NameCustomerGroup = aNewPaymentEN.NameCustomerGroup;
               this.IDCompany = aNewPaymentEN.IDCompany;
               this.NameCompany = aNewPaymentEN.NameCompany;
               this.TaxNumberCodeCompany = aNewPaymentEN.TaxNumberCodeCompany;
               this.AddressCompany = aNewPaymentEN.AddressCompany;
               this.InvoiceNumber = aNewPaymentEN.InvoiceNumber;
               this.AcceptDate = aNewPaymentEN.AcceptDate;

               return this;
        }
        public NewPaymentEN SlipPaymentByCustomer(Customers aCustomers)
        {
            NewPaymentEN aNewPaymentEN = new NewPaymentEN();
               aNewPaymentEN = this;

               List<BookingRoomUsedEN> aList = new List<BookingRoomUsedEN>();
               for (int a = 0; a < this.aListBookingRoomUsed.Count; a++)
               {

               int Count  = this.aListBookingRoomUsed[a].ListCustomer.Where(p=>p.ID == aCustomers.ID).ToList().Count;
               if (Count > 0)
               {
                   aList.Add(this.aListBookingRoomUsed[a]);
               }
               }

               int NumberCustomerInRoom = 0;
               List<ServiceUsedEN> aListService = new List<ServiceUsedEN>();
               for (int i = 0; i < aList.Count; i++)
               {
               NumberCustomerInRoom = aList[i].ListCustomer.Count ;
               aList[i].Cost = aList[i].Cost / NumberCustomerInRoom;
               aList[i].CostPendingRoom = aList[i].CostPendingRoom / NumberCustomerInRoom;
               aList[i].CostRef_Rooms = aList[i].CostRef_Rooms / NumberCustomerInRoom;
               aListService = new List<ServiceUsedEN>();
               aListService = aList[i].ListServiceUsed.Where(p => p.Tag != aCustomers.ID.ToString()).ToList();
               for (int ii = 0; ii < aListService.Count; ii++)
               {
                   aList[i].ListServiceUsed.Remove(aListService[ii]);
               }

               }
               aNewPaymentEN.aListBookingRoomUsed.Clear();
               aNewPaymentEN.aListBookingRoomUsed.AddRange (aList);
               return aNewPaymentEN;
        }
        //Hiennv        31/08/2014           Thanh toan le cho hoi truong
        public void SplitPaymentForBookingH(NewPaymentEN aNewPaymentEN, List<BookingHallUsedEN> aListHalls, List<ServiceUsedEN> aListServicesH)
        {
            try
            {
                foreach (ServiceUsedEN aServicesEN in aListServicesH)
                {

                    aServicesEN.StatusPay = 8;
                    aServicesEN.Save(2);
                }

                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                foreach (BookingHallUsedEN aHallsEN in aListHalls)
                {
                    aHallsEN.Status = 8;
                    aHallsEN.Save();
                }
                BookingHsBO aBookingHsBO = new BookingHsBO();
                BookingHs aBookingHs = aBookingHsBO.Select_ByID(Convert.ToInt32(aNewPaymentEN.IDBookingH));
                List<BookingHalls> aListBookingHalls = aBookingHallsBO.Select_ByIDBookingH_ByStatus(Convert.ToInt32(aNewPaymentEN.IDBookingH), 8);
                if (aListBookingHalls.Count < 1)
                {
                    aBookingHs.ID = Convert.ToInt32(aNewPaymentEN.IDBookingH);
                    aBookingHs.PayMenthod = aNewPaymentEN.PayMenthodH;
                    aBookingHs.StatusPay = 3;
                    aBookingHs.Status = 8;
                    aBookingHs.DatePay = DateTime.Now;
                }
                aBookingHs.BookingMoney = aNewPaymentEN.BookingHMoney;
                aBookingHsBO.Update(aBookingHs);
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.SplitPaymentForBookingH \n" + ex.ToString());
            }
        }
        //Hiennv        31/08/2014           Thanh toan le cho phong
        public void SplitPaymentForBookingR(NewPaymentEN aNewPaymentEN, List<BookingRoomUsedEN> aListRooms, List<ServiceUsedEN> aListServicesR)
        {
            try
            {

                foreach (ServiceUsedEN aServicesEN in aListServicesR)
                {

                    aServicesEN.StatusPay = 8;
                    aServicesEN.Save(1);
                }
                BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();
                foreach (BookingRoomUsedEN aBookingRoomUsedEN in aListRooms)
                {

                    aBookingRoomUsedEN.Status = 8;//da thanh toan
                    aBookingRoomUsedEN.CheckOutActual = DateTime.Now;
                    aBookingRoomUsedEN.Save();
                }
                BookingRsBO aBookingRsBO = new BookingRsBO();
                BookingRs aBookingRs = aBookingRsBO.Select_ByID(Convert.ToInt32(aNewPaymentEN.IDBookingR));
                List<BookingRooms> aListBookingRooms = aBookingRoomsBO.Select_ByIDBookingR_ByStatus(Convert.ToInt32(aNewPaymentEN.IDBookingR), 8);
                if (aListBookingRooms.Count < 1)
                {
                    aBookingRs.ID = Convert.ToInt32(aNewPaymentEN.IDBookingR);
                    aBookingRs.PayMenthod = aNewPaymentEN.PayMenthodR;
                    aBookingRs.StatusPay = 3;
                    aBookingRs.Status = 8;
                    aBookingRs.DatePay = DateTime.Now;
                }
                aBookingRs.BookingMoney = aNewPaymentEN.BookingRMoney;
                aBookingRsBO.Update(aBookingRs);
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.SplitPaymentForBookingR \n" + ex.ToString());
            }
        }
        public void SplitPaymentService(NewPaymentEN aNewPaymentEN, List<ServiceUsedEN> aListServices, int Status)
        {
            try
            {
                if (Status == 1)
                {
                    foreach (ServiceUsedEN aServicesEN in aListServices)
                    {

                        aServicesEN.StatusPay = 8;
                        aServicesEN.Save(1);
                    }
                }
                else if (Status == 2)
                {
                    foreach (ServiceUsedEN aServicesEN in aListServices)
                    {

                        aServicesEN.StatusPay = 8;
                        aServicesEN.Save(2);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.SplitPaymentService \n" + ex.ToString());
            }
        }
        private void loeListCustomer_EditValueChanging(object sender, DevExpress.XtraEditors.Controls.ChangingEventArgs e)
        {
            CustomersBO aCustomersBO = new CustomersBO();
            Customers aCustomer = new Customers();

            if (loeListCustomer.OldEditValue != null || int.Parse(e.NewValue.ToString()) != 0 )  // Để khi fill dữ liệu vào lần đầu không xóa mất aNewPaymentEN
            {
                if (int.Parse(e.OldValue.ToString()) == 0)
                {
                    this.aNewPaymentEN_Backup.Clone(this.aNewPaymentEN);
                    aCustomer = aCustomersBO.Select_ByID(int.Parse(e.NewValue.ToString()));
                    this.aNewPaymentEN = this.aNewPaymentEN.SlipPaymentByCustomer(aCustomer);
                    if (this.aNewPaymentEN.aListBookingRoomUsed.Count > 0)
                    {
                        this.CurrentIDBookingRoom = this.aNewPaymentEN.aListBookingRoomUsed[0].ID;
                    }
                    else
                    {
                        MessageBox.Show("Có thể có lỗi dữ liệu vì người dùng này đang không tồn tại trong phòng nào");
                    }

                    this.LoadDataCurrentHallForControl();
                    this.LoadDataCurrentRoomForControl();
                }
                else if (int.Parse(e.OldValue.ToString()) != 0)
                {

                    if (int.Parse(e.NewValue.ToString()) != 0) // Khi chọn hiển thị dữ liệu cho một người khác
                    {
                        this.aNewPaymentEN.Clone(this.aNewPaymentEN_Backup);

                        aCustomer = aCustomersBO.Select_ByID(int.Parse(e.NewValue.ToString()));
                        this.aNewPaymentEN = this.aNewPaymentEN.SlipPaymentByCustomer(aCustomer);

                        if (this.aNewPaymentEN.aListBookingRoomUsed.Count > 0)
                        {
                            this.CurrentIDBookingRoom = this.aNewPaymentEN.aListBookingRoomUsed[0].ID;
                        }
                        else
                        {
                            MessageBox.Show("Có thể có lỗi dữ liệu vì người dùng này đang không tồn tại trong phòng nào");
                        }

                        this.LoadDataCurrentHallForControl();
                        this.LoadDataCurrentRoomForControl();
                    }
                    else //khi chọn hiển thị dữ liệu cho tất cả
                    {
                        this.aNewPaymentEN.Clone(this.aNewPaymentEN_Backup);
                        if (this.aNewPaymentEN.aListBookingRoomUsed.Count > 0)
                        {
                            this.CurrentIDBookingRoom = this.aNewPaymentEN.aListBookingRoomUsed[0].ID;
                        }
                        else
                        {
                            MessageBox.Show("Có thể có lỗi dữ liệu vì người dùng này đang không tồn tại trong phòng nào");
                        }

                        this.LoadDataCurrentHallForControl();
                        this.LoadDataCurrentRoomForControl();
                    }
                }
            }
        }
        public void SplitPaymentHall(NewPaymentEN aNewPaymentEN, List<BookingHallUsedEN> aListHalls)
        {
            try
            {
                foreach (BookingHallUsedEN aBookingHallUsedEN in aListHalls)
                {

                    aBookingHallUsedEN.Status = 8;//da thanh toan
                    aBookingHallUsedEN.Save();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.SplitPaymentHall \n" + ex.ToString());
            }
        }
 public void Reload(int IDBookingH)
 {
     this.aNewPaymentEN = new NewPaymentEN();
     this.IDBookingH = IDBookingH;
     this.InitData(this.IDBookingR, this.IDBookingH);
     //this.LoadData();
 }
 public void Reload(NewPaymentEN aNewPayment)
 {
     this.aNewPaymentEN = aNewPayment;
     //this.LoadData();
 }
        public frmRpt_SplitPayment_BookingRs(NewPaymentEN aNewPaymentEN,int IndexSub)
        {
            InitializeComponent();
            this.aNewPaymentEN = aNewPaymentEN;
            this.IndexSub = IndexSub;
            try
            {
                lblNumberVote.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblIIDBookingR.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblNameCustomer.Text = aNewPaymentEN.NameCustomer;
                lblGroup.Text = aNewPaymentEN.NameCustomerGroup;
                lblCompany.Text =aNewPaymentEN.NameCompany;
                lblTaxNumberCode.Text =aNewPaymentEN.TaxNumberCodeCompany;

                int day = DateTime.Now.Day;
                int month = DateTime.Now.Month;
                int year = DateTime.Now.Year;
                lblDayMonthYear.Text = "Hà Nội, ngày " + day.ToString() + " tháng " + month.ToString() + " năm " + year.ToString();

                //------------- Phong ------------------------
                List<BookingRoomUsedEN> aListBookingRoomUsedEN = new List<BookingRoomUsedEN>();
                aListBookingRoomUsedEN = aNewPaymentEN.aListBookingRoomUsed.Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.RoomSku).ToList();

                aListServiceUsed = aNewPaymentEN.GetAllServiceUsedInRoom().Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.Sku).ToList();
                //Lấy List< IDServiceGroup>
                List<int> aTemp = new List<int>();
                int IDServiceGroup;
                foreach (ServiceUsedEN item in aListServiceUsed)
                {
                    IDServiceGroup = new int();

                    IDServiceGroup = item.IDServiceGroup;
                    aTemp.Add(IDServiceGroup);
                }
                aListIDServicesGroup = aTemp.Distinct().ToList();

                ServiceGroupEN aServicesGroupEN;
                ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();

                foreach (int item in aListIDServicesGroup)
                {
                    aServicesGroupEN = new ServiceGroupEN();
                    aServicesGroupEN.IDServiceGroup = item;
                    aServicesGroupEN.TotalMoneyBeforeTax = this.GetTotalMoneyServiceGroupBeforeTax(item);
                    aServicesGroupEN.DisplayMoneyTax = aNewPaymentEN.GetMoneyTax(this.GetTotalMoneyServiceGroupBeforeTax(item), 10);
                    aServicesGroupEN.TotalMoneyAfterTax = this.GetTotalMoneyServiceGroupAfterTax(item);
                    aServicesGroupEN.ServiceGroupName = aServiceGroupsBO.Sel_ByID(item).Name;
                    aListServicesGroupEN.Add(aServicesGroupEN);
                }

                decimal? sumMoneyRoomBeforeTax = aListBookingRoomUsedEN.Sum(r => r.GetOnlyMoneyRoomBeforeTax());
                decimal? SumMoneyTaxRoom = aListBookingRoomUsedEN.Sum(r => r.GetOnlyMoneyRoom());
                decimal? sumMoneyRoomAfterTax = aListBookingRoomUsedEN.Sum(r => r.GetOnlyMoneyRoom());

                decimal? sumMoneyServiceRoomBeforeTax = aListServicesGroupEN.Sum(s => s.TotalMoneyBeforeTax);
                decimal? sumMoneyTaxServices = aListServicesGroupEN.Sum(s => s.DisplayMoneyTax);
                decimal? sumMoneyServiceRoomAfterTax = aListServicesGroupEN.Sum(s => s.TotalMoneyAfterTax);

                decimal? BookingMoneyR = 0;

                //danh sach phong
                this.DetailReport.DataSource = aListBookingRoomUsedEN;
                colSkuRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "RoomSku");
                colCheckIn.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckInActual", "{0:dd-MM-yyyy HH:mm}");
                colCheckOut.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckOutActual", "{0:dd-MM-yyyy HH:mm}");
                colBookingRoomCost.DataBindings.Add("Text", this.DetailReport.DataSource, "Cost", "{0:0,0.##}");
                colDateInUse.DataBindings.Add("Text", this.DetailReport.DataSource, "DateUsed", "{0:0,0.##}");
                colMoneyRoomBeforeTax.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoomBeforeTax", "{0:0,0}");
                colPercentTaxRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "DisplayMoneyTaxRoom", "{0:0,0}");
                colPaymentMoneyaRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoom", "{0:0,0}");

                //tong tien phong truoc thue
                lblSumMoneyRoomsBeforeTax.Text = String.Format("{0:0,0}", sumMoneyRoomBeforeTax);
                //Tien thue phong
                lblSumMoneyRoomTax.Text = String.Format("{0:0,0}", SumMoneyTaxRoom);
                //tong tien phong sau thue
                lblSumMoneyRoomsAfterTax.Text = String.Format("{0:0,0}", sumMoneyRoomAfterTax);

                //danh sach dich vu
                this.DetailReport2.DataSource = aListServicesGroupEN;
                colNamService.DataBindings.Add("Text", this.DetailReport2.DataSource, "ServiceGroupName");
                colTotalMoneyBeforeTax.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoneyBeforeTax", "{0:0,0}");
                colPercentTaxService.DataBindings.Add("Text", this.DetailReport2.DataSource, "DisplayMoneyTax", "{0:0,0}");
                colTotalMoneyServiceAfterTax.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoneyAfterTax", "{0:0,0}");

                //tong tien dich vu truoc thue
                lblSumMoneyService_BookingRBeforeTax.Text = String.Format("{0:0,0}", sumMoneyServiceRoomBeforeTax);
                //Tien thue dich vu
                lblSumMoneyServiceTax.Text = String.Format("{0:0,0}", sumMoneyTaxServices);
                //tong tien dich vu sau thue
                lblSumMoneyService_BookingRAfterTax.Text = String.Format("{0:0,0}", sumMoneyServiceRoomAfterTax);

                //tong tien thanh toan truoc thue
                lblTotalMoneyBookingRBeforeTax.Text = String.Format("{0:0,0}", (sumMoneyRoomBeforeTax + sumMoneyServiceRoomBeforeTax));
                //Tong tien thue
                lblTotalMoneyTax.Text = String.Format("{0:0,0}", (SumMoneyTaxRoom + sumMoneyTaxServices));
                //tong tien thanh toan sau thue
                lblTotalMoneyBookingRAfterTax.Text = String.Format("{0:0,0}", (sumMoneyRoomAfterTax + sumMoneyServiceRoomAfterTax));
                //So tien ung truoc
                lblBookingMoney_BookingR.Text = String.Format("{0:0,0}", BookingMoneyR);
                //so tien con lai can thanh toan
                lblTotalMoney_BookingR.Text = String.Format("{0:0,0}", ((sumMoneyRoomAfterTax + sumMoneyServiceRoomAfterTax) - BookingMoneyR));

                string TotalMoney_BookingRString = UppercaseFirst(StringUtility.ConvertDecimalToString(Convert.ToDecimal((sumMoneyRoomAfterTax + sumMoneyServiceRoomAfterTax) - BookingMoneyR)));
                lblTotalMoney_BookingRString.Text = "(" + TotalMoney_BookingRString + ")";

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public frmRpt_SplitPayment_BookingRsAndBookingHs(NewPaymentEN aNewPaymentEN,int IndexSub)
        {
            InitializeComponent();
            this.aNewPaymentEN = aNewPaymentEN;
            this.IndexSub = IndexSub;
            try
            {

                lblNumberVote.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblIIDBookingR.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblNameCustomer.Text = this.aNewPaymentEN.NameCustomer;
                lblGroup.Text = this.aNewPaymentEN.NameCustomerGroup;
                lblCompany.Text = this.aNewPaymentEN.NameCompany;
                lblTaxNumberCode.Text = this.aNewPaymentEN.TaxNumberCodeCompany;

                int day = DateTime.Now.Day;
                int month = DateTime.Now.Month;
                int year = DateTime.Now.Year;
                lblDayMonthYear.Text = "Hà Nội, ngày " + day.ToString() + " tháng " + month.ToString() + " năm " + year.ToString();

                //------------- Phong ------------------------

                List<BookingRoomUsedEN> aListBookingRoomUsedEN = new List<BookingRoomUsedEN>();
                aListBookingRoomUsedEN = this.aNewPaymentEN.aListBookingRoomUsed.Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.RoomSku).ToList();
                aListBookingRoomUsedEN.Count();
                List<ServiceUsedEN> aListServicesEN = new List<ServiceUsedEN>();
                aListServicesEN = this.aNewPaymentEN.GetAllServiceUsedInRoom().Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.Sku).ToList();

                decimal? sumMoneyRoomBeforeTax = aListBookingRoomUsedEN.Sum(r => r.GetOnlyMoneyRoomBeforeTax());

                decimal? sumMoneyRoomAfterTax = aListBookingRoomUsedEN.Sum(r => r.GetOnlyMoneyRoom());
                decimal? sumMoneyServiceRoomAfterTax = aListServicesEN.Sum(s => s.GetMoneyService());
                decimal? sumMoneyServiceRoomBeforeTax = aListServicesEN.Sum(s => s.GetMoneyServiceBeforeTax());

                decimal? BookingMoneyR = 0;

                //danh sach phong
                this.DetailReport.DataSource = aListBookingRoomUsedEN;
                colSkuRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "RoomSku");
                colCheckIn.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckInActual", "{0:dd-MM-yyyy HH:mm}");
                colCheckOut.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckOutActual", "{0:dd-MM-yyyy HH:mm}");
                colBookingRoomCost.DataBindings.Add("Text", this.DetailReport.DataSource, "Cost", "{0:0,0.##}");
                colDateInUse.DataBindings.Add("Text", this.DetailReport.DataSource, "DateUsed", "{0:0,0.##}");
                colPercentTaxRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "PercentTax");
                colPaymentMoneyaRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoom", "{0:0,0}");
                colMoneyRoomBeforeTax.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoomBeforeTax", "{0:0,0}");

                //tong tien phong truoc thue
                lblSumMoneyRoomsBeforeTax.Text = String.Format("{0:0,0} (VND)", sumMoneyRoomBeforeTax);
                //tong tien phong sau thue
                lblSumMoneyRoomsAfterTax.Text = String.Format("{0:0,0} (VND)", sumMoneyRoomAfterTax);

                //danh sach dich vu
                this.DetailReport2.DataSource = aListServicesEN;
                colNameSku.DataBindings.Add("Text", this.DetailReport2.DataSource, "Sku");
                colNamService.DataBindings.Add("Text", this.DetailReport2.DataSource, "NameService");
                colDateUse.DataBindings.Add("Text", this.DetailReport2.DataSource, "DateUsed", "{0:dd-MM-yyyy}");
                colQuantity.DataBindings.Add("Text", this.DetailReport2.DataSource, "Quantity");
                colBookingRooms_ServicesCost.DataBindings.Add("Text", this.DetailReport2.DataSource, "Cost", "{0:0,0}");
                colPercentTaxService.DataBindings.Add("Text", this.DetailReport2.DataSource, "Tax");
                colPaymentMoneyService.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoney", "{0:0,0}");

                //tong tien dich vu truoc thue
                lblSumMoneyService_BookingRBeforeTax.Text = String.Format("{0:0,0} (VND)", sumMoneyServiceRoomBeforeTax);

                //tong tien dich vu sau thue
                lblSumMoneyService_BookingRAfterTax.Text = String.Format("{0:0,0} (VND)", sumMoneyServiceRoomAfterTax);

                //tong tien thanh toan truoc thue
                lblTotalMoneyBookingRBeforeTax.Text = String.Format("{0:0,0} (VND)",(sumMoneyRoomBeforeTax + sumMoneyServiceRoomBeforeTax));
                //tong tien thanh toan sau thue
                lblTotalMoneyBookingRAfterTax.Text = String.Format("{0:0,0} (VND)",(sumMoneyRoomAfterTax + sumMoneyServiceRoomAfterTax));
                //So tien ung truoc
                lblBookingMoney_BookingR.Text = String.Format("{0:0,0} (VND)", BookingMoneyR);
                //so tien con lai can thanh toan
                lblTotalMoney_BookingR.Text = String.Format("{0:0,0} (VND)", ((sumMoneyRoomAfterTax + sumMoneyServiceRoomAfterTax) - BookingMoneyR));

                //------------------------------- Hoi truong ---------------------

                List<BookingHallUsedEN> aListBookingHallUsedEN = new List<BookingHallUsedEN>();
                aListBookingHallUsedEN = this.aNewPaymentEN.aListBookingHallUsed.Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.HallSku).ToList();
                aListBookingHallUsedEN.Count();
                List<ServiceUsedEN> aListServicesHallEN = new List<ServiceUsedEN>();
                aListServicesHallEN = this.aNewPaymentEN.GetAllServiceUsedInHall().Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.Sku).ToList();

                decimal? sumMoneyHallBeforeTax = aListBookingHallUsedEN.Sum(r => r.GetMoneyHallBeforeTax());

                decimal? sumMoneyHallAfterTax = aListBookingHallUsedEN.Sum(r => r.GetTotalMoneyHall());
                decimal? sumMoneyServiceHallAfterTax = aListServicesHallEN.Sum(s => s.GetMoneyService());
                decimal? sumMoneyServiceHallBeforeTax = aListServicesHallEN.Sum(s => s.GetMoneyServiceBeforeTax());

                decimal? bookingMoneyH = 0;

                //danh sach hoi truong
                this.DetailReportHall.DataSource = aListBookingHallUsedEN;
                colSkuHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "HallSku");
                colCreateDate.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Date", "{0:dd/MM/yyyy}");
                colBookingHallCost.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Cost", "{0:0,0}");
                colPercentTax.DataBindings.Add("Text", this.DetailReportHall.DataSource, "PercentTax");
                colPaymentMoneyHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "MoneyHall", "{0:0,0}");
                colMoneyHallBeforeTax.DataBindings.Add("Text", this.DetailReportHall.DataSource, "MoneyHallBeforeTax", "{0:0,0}");

                //danh sach dich vu su dung
                this.DetailReportService.DataSource = aListServicesHallEN;
                colService_Sku.DataBindings.Add("Text", this.DetailReportService.DataSource, "Sku");
                colService_Name.DataBindings.Add("Text", this.DetailReportService.DataSource, "NameService");
                colService_Date.DataBindings.Add("Text", this.DetailReportService.DataSource, "DateUsed", "{0:dd/MM/yyyy}");
                colService_Quantity.DataBindings.Add("Text", this.DetailReportService.DataSource, "Quantity", "{0:0,0}");
                colService_Cost.DataBindings.Add("Text", this.DetailReportService.DataSource, "Cost", "{0:0,0}");
                colService_PercentTax.DataBindings.Add("Text", this.DetailReportService.DataSource, "Tax");
                colService_Money.DataBindings.Add("Text", this.DetailReportService.DataSource, "TotalMoney", "{0:0,0}");

                //tong tien hoi truong truoc thue
                lblTotalMoneyHallBeforeTax.Text = String.Format("{0:0,0} (VND)", sumMoneyHallBeforeTax);
                //tong tien hoi truong sau thue
                lblTotalMoneyHallAfterTax.Text = String.Format("{0:0,0} (VND)", sumMoneyHallAfterTax);

                //tong tien dich vu hoi truong truoc thue
                lblTotalMoneyService_BookingHBeforeTax.Text = String.Format("{0:0,0} (VND)", sumMoneyServiceHallBeforeTax);
                //tong tien dich vu hoi truong sau thue
                lblTotalMoneyServices_BookingHAfterTax.Text = String.Format("{0:0,0} (VND)", sumMoneyServiceHallAfterTax);

                //tong tien bookingh
                lblTotalMoneyBookingHBeforeTax.Text = String.Format("{0:0,0} (VND)", (sumMoneyHallBeforeTax + sumMoneyServiceHallBeforeTax));
                lblTotalMoneyBookingHAfterTax.Text = String.Format("{0:0,0} (VND)", (sumMoneyHallAfterTax + sumMoneyServiceHallAfterTax));
                lblBookingMoney_BookingH.Text = String.Format("{0:0,0} (VND)", bookingMoneyH);
                lblTotalBookingH.Text = String.Format("{0:0,0} (VND)", ((sumMoneyHallAfterTax + sumMoneyServiceHallAfterTax) - bookingMoneyH));

                //Tong tien hoa don can thanh toan
                decimal? beforTax =sumMoneyRoomBeforeTax + sumMoneyServiceRoomBeforeTax + sumMoneyHallBeforeTax + sumMoneyServiceHallBeforeTax ;
                decimal? AfterTax = sumMoneyRoomAfterTax + sumMoneyServiceRoomAfterTax + sumMoneyHallAfterTax + sumMoneyServiceHallAfterTax;
                decimal? bookingMoney = BookingMoneyR + bookingMoneyH;

                lblMoneyBookingRAndBookingHBeforeTax.Text = String.Format("{0:0,0} (VND)", beforTax);
                lblMoneyBookingRAndBookingHAfterTax.Text = String.Format("{0:0,0} (VND)", AfterTax);
                lblBookingmoney_BookingRAndBookingH.Text = String.Format("{0:0,0} (VND)", bookingMoney);
                lblTotalMoneyBookigRAndBookingH.Text = String.Format("{0:0,0} (VND)", (AfterTax - bookingMoney));

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public frmRpt_SplitPayment_BookingHs(NewPaymentEN aNewPaymentEN, int IndexSub)
        {
            InitializeComponent();
            this.aNewPaymentEN = aNewPaymentEN;
            this.IndexSub = IndexSub;
            try
            {

                lblNumberVote.Text = Convert.ToString(this.aNewPaymentEN.IDBookingH);
                lblIDBookingH.Text = Convert.ToString(this.aNewPaymentEN.IDBookingH);
                lblNameCustomer.Text = this.aNewPaymentEN.NameCustomer;
                lblGroup.Text = this.aNewPaymentEN.NameCustomerGroup;
                lblCompany.Text = this.aNewPaymentEN.NameCompany;
                lblTaxNumberCode.Text = this.aNewPaymentEN.TaxNumberCodeCompany;

                int day = DateTime.Now.Day;
                int month = DateTime.Now.Month;
                int year = DateTime.Now.Year;
                lblDayMonthYear.Text = "Hà Nội, ngày " + day.ToString() + " tháng " + month.ToString() + " năm " + year.ToString();

               //Lấy dữ liệu

                List<BookingHallUsedEN> aListBookingHallUsedEN = new List<BookingHallUsedEN>();
                aListBookingHallUsedEN = this.aNewPaymentEN.aListBookingHallUsed.Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.HallSku).ToList();
                aListBookingHallUsedEN.Count();

                aListServiceUsedHall = this.aNewPaymentEN.GetAllServiceUsedInHall().Where(r => r.IndexSubPayment == this.IndexSub).OrderBy(r => r.Sku).ToList();
                //Lấy List< IDServiceGroup>
                List<int> aTemp1 = new List<int>();
                int IDServiceGroupHall;
                foreach (ServiceUsedEN item in aListServiceUsedHall)
                {
                    IDServiceGroupHall = new int();
                    IDServiceGroupHall = item.IDServiceGroup;
                    aTemp1.Add(IDServiceGroupHall);
                }
                aListIDServicesGroupHall = aTemp1.Distinct().ToList();
                ServiceGroupEN aServicesGroupHallEN;
                foreach (int item in aListIDServicesGroupHall)
                {
                    aServicesGroupHallEN = new ServiceGroupEN();
                    aServicesGroupHallEN.IDServiceGroup = item;
                    aServicesGroupHallEN.TotalMoneyBeforeTax = this.GetTotalMoneyServiceGroupHallBeforeTax(item);
                    aServicesGroupHallEN.TotalMoneyAfterTax = this.GetTotalMoneyServiceGroupHallAfterTax(item);
                    aServicesGroupHallEN.DisplayMoneyTax = aNewPaymentEN.GetMoneyTax(this.GetTotalMoneyServiceGroupHallBeforeTax(item), 10);
                    aServicesGroupHallEN.ServiceGroupName = aServiceGroupsBO.Sel_ByID(item).Name;
                    aListServicesGroupHallEN.Add(aServicesGroupHallEN);
                }
                decimal? sumMoneyHallBeforeTax = aListBookingHallUsedEN.Sum(r => r.GetMoneyHallBeforeTax());
                decimal? SumMoneyTaxHall = aListBookingHallUsedEN.Sum(r => r.GetTotalMoneyHall());
                decimal? sumMoneyHallAfterTax = aListBookingHallUsedEN.Sum(r => r.GetTotalMoneyHall());

                decimal? sumMoneyServiceHallBeforeTax = aListServicesGroupHallEN.Sum(s => s.TotalMoneyBeforeTax);
                decimal? sumMoneyTaxServices = aListServicesGroupHallEN.Sum(s => s.DisplayMoneyTax);
                decimal? sumMoneyServiceHallAfterTax = aListServicesGroupHallEN.Sum(s => s.TotalMoneyAfterTax);

                //Tong tien hoa don can thanh toan
                decimal? beforTax = sumMoneyHallBeforeTax + sumMoneyServiceHallBeforeTax;
                decimal? afterTax = sumMoneyHallAfterTax + sumMoneyServiceHallAfterTax;
                decimal? bookingMoney = Convert.ToDecimal(this.aNewPaymentEN.BookingHMoney);

                                //danh sach hoi truong
                this.DetailReportHall.DataSource = aNewPaymentEN.aListBookingHallUsed;
                colSkuHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "HallSku");
                colCreateDate.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Date", "{0:dd/MM/yyyy}");
                colBookingHallCost.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Cost", "{0:0,0}");
                colPercentTax.DataBindings.Add("Text", this.DetailReportHall.DataSource, "DisplayMoneyTaxHall", "{0:0,0}");
                colPaymentMoneyHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "MoneyHall", "{0:0,0}");

                XRSummary aXRSummaryDisplayMoneyTaxHall = new XRSummary();
                aXRSummaryDisplayMoneyTaxHall.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyTaxHall.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyTaxHall.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyTaxHall.FormatString = "{0:0,0}";
                XRBinding aXRBindingDisplayMoneyTaxHall = new XRBinding("Text", this.DetailReportHall.DataSource, "DisplayMoneyTaxHall", "{0:0,0}");
                XRBinding[] listXRBindingDisplayMoneyTaxHall = new XRBinding[] { aXRBindingDisplayMoneyTaxHall };
                lblSumMoneyHallsTax.DataBindings.AddRange(listXRBindingDisplayMoneyTaxHall);
                lblSumMoneyHallsTax.Summary = aXRSummaryDisplayMoneyTaxHall;

                //danh sach dich vu su dung
                this.DetailReportService.DataSource = aListServicesGroupHallEN;
                colNamServiceHall.DataBindings.Add("Text", this.DetailReportService.DataSource, "ServiceGroupName");
                colTotalMoneyServiceHallBeforeTax.DataBindings.Add("Text", this.DetailReportService.DataSource, "TotalMoneyBeforeTax", "{0:0,0}");
                colPercentTaxServiceHall.DataBindings.Add("Text", this.DetailReportService.DataSource, "DisplayMoneyTax", "{0:0,0}");

                colTotalMoneyServiceHallAfterTax.DataBindings.Add("Text", this.DetailReportService.DataSource, "TotalMoneyAfterTax", "{0:0,0}");

                XRSummary aXRSummaryDisplayMoneyServiceHallTax = new XRSummary();
                aXRSummaryDisplayMoneyServiceHallTax.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyServiceHallTax.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyServiceHallTax.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyServiceHallTax.FormatString = "{0:0,0}";
                lblSumMoneyServiceHallsTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReportService.DataSource, "DisplayMoneyTax", "{0:0,0}") });
                lblSumMoneyServiceHallsTax.Summary = aXRSummaryDisplayMoneyServiceHallTax;

                //tong tien hoi truong truoc thue
                lblSumMoneyHallsBeforeTax.Text = String.Format("{0:0,0}",sumMoneyHallBeforeTax);
                //tong tien hoi truong sau thue
                lblSumMoneyHallsAfterTax.Text = String.Format("{0:0,0}", sumMoneyHallAfterTax);

                //tong tien dich vu hoi truong truoc thue
                lblSumMoneyServiceHallsBeforeTax.Text = String.Format("{0:0,0}", sumMoneyServiceHallBeforeTax);
                //tong tien dich vu hoi truong sau thue
                lblSumMoneyServiceHallsAfterTax.Text = String.Format("{0:0,0}", sumMoneyServiceHallAfterTax);

                //tong tien thanh toan truoc thue
                lblTotalMoneyBeforeTax.Text = String.Format("{0:0,0}", beforTax);
                //tien thue
                lblTotalMoneyTax.Text = String.Format("{0:0,0}", sumMoneyTaxServices+SumMoneyTaxHall);
                //tong tien thanh toan sau thue
                lblTotalMoneyAfterTax.Text = String.Format("{0:0,0}", afterTax);
                //So tien ung truoc
                lblBookingMoney.Text = String.Format("{0:0,0}", bookingMoney);
                //so tien con lai can thanh toan
                lblTotalMoney.Text = String.Format("{0:0,0}", afterTax - bookingMoney);
                string TotalMoney_BookingHString = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(Library.StringUtility.ConvertDecimalToString(Convert.ToDecimal(afterTax - bookingMoney)));

                lblTotalMoneyString.Text = "(" + TotalMoney_BookingHString + ")";
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public void PaymentHall(NewPaymentEN aNewPaymentEN)
        {
            DatabaseDA aDatabaseDA = new DatabaseDA();
            if (aDatabaseDA.BookingHs.Where(a => a.ID == aNewPaymentEN.IDBookingH).ToList().Count > 0)
            {
                BookingHs aTemp = aDatabaseDA.BookingHs.Where(a => a.ID == aNewPaymentEN.IDBookingH).ToList()[0];
                aTemp.CreatedDate = aNewPaymentEN.CreatedDate_BookingH;
                aTemp.Status = 8;
                aTemp.BookingMoney = aNewPaymentEN.BookingHMoney;
                aTemp.InvoiceDate = aNewPaymentEN.InvoiceDate;
                aTemp.InvoiceNumber = aNewPaymentEN.InvoiceNumber;
                aTemp.DatePay = DateTime.Now;
                aTemp.AcceptDate = aNewPaymentEN.AcceptDate;

                aDatabaseDA.BookingHs.AddOrUpdate(aTemp);
                aDatabaseDA.SaveChanges();
                foreach (BookingHallUsedEN item in aNewPaymentEN.aListBookingHallUsed)
                {

                    foreach (ServiceUsedEN item1 in item.aListServiceUsed)
                    {
                        item1.StatusPay = 8;
                    }
                    item.Status = 8;
                    this.SaveBookingHall(item);
                }
            }
        }
        //Linhting : Thanh toán lẻ phòng + tiệc + dịch vụ
        public void SplitPaymentRoom(NewPaymentEN aNewPaymentEN, List<BookingRoomUsedEN> aListRooms)
        {
            try
            {
                foreach (BookingRoomUsedEN aBookingRoomUsedEN in aListRooms)
                {

                    aBookingRoomUsedEN.Status = 8;//da thanh toan
                    aBookingRoomUsedEN.CheckOutActual = DateTime.Now;
                    aBookingRoomUsedEN.Save();
                }
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.SplitPaymentRoom \n" + ex.ToString());
            }
        }
 public void Reload()
 {
     this.aNewPaymentEN = new NewPaymentEN();
     this.InitData(this.IDBookingR, this.IDBookingH);
     this.LoadDataCurrentHallForControl();
     this.LoadDataCurrentRoomForControl();
 }
        public void PaymentTotal(NewPaymentEN aNewPaymentEN)
        {
            if (aNewPaymentEN.aListBookingHallUsed.Count > 0)
            {
                this.PaymentHall(aNewPaymentEN);
                DatabaseDA aDatabaseDA = new DatabaseDA();
                if (aDatabaseDA.BookingRs.Where(a => a.ID == aNewPaymentEN.IDBookingR).ToList().Count > 0)
                {
                    BookingRs aTemp = aDatabaseDA.BookingRs.Where(a => a.ID == aNewPaymentEN.IDBookingR).ToList()[0];
                    aTemp.DatePay = DateTime.Now;
                    aTemp.Status = 8;
                    aTemp.InvoiceDate = aNewPaymentEN.InvoiceDate;
                    aTemp.InvoiceNumber = aNewPaymentEN.InvoiceNumber;
                    aTemp.BookingMoney = aNewPaymentEN.BookingRMoney;
                    aTemp.AcceptDate = aNewPaymentEN.AcceptDate;

                    aDatabaseDA.BookingRs.AddOrUpdate(aTemp);
                    aDatabaseDA.SaveChanges();
                    foreach (BookingRoomUsedEN item in aNewPaymentEN.aListBookingRoomUsed)
                    {

                        foreach (ServiceUsedEN item1 in item.ListServiceUsed)
                        {
                            item1.StatusPay = 8;
                        }
                        item.Status = 8;
                        item.CheckOutActual = DateTime.Now;
                        this.SaveBookingRoom(item);
                    }
                }
            }
            else
            {
                DatabaseDA aDatabaseDA = new DatabaseDA();
                if (aDatabaseDA.BookingRs.Where(a => a.ID == aNewPaymentEN.IDBookingR).ToList().Count > 0)
                {
                    BookingRs aTemp = aDatabaseDA.BookingRs.Where(a => a.ID == aNewPaymentEN.IDBookingR).ToList()[0];
                    aTemp.DatePay = DateTime.Now;
                    aTemp.Status = 8;
                    aTemp.InvoiceDate = aNewPaymentEN.InvoiceDate;
                    aTemp.InvoiceNumber = aNewPaymentEN.InvoiceNumber;
                    aTemp.BookingMoney = aNewPaymentEN.BookingRMoney;
                    aDatabaseDA.BookingRs.AddOrUpdate(aTemp);
                    aDatabaseDA.SaveChanges();
                    foreach (BookingRoomUsedEN item in aNewPaymentEN.aListBookingRoomUsed)
                    {

                        foreach (ServiceUsedEN item1 in item.ListServiceUsed)
                        {
                            item1.StatusPay = 8;
                        }
                        item.Status = 8;
                        item.CheckOutActual = DateTime.Now;
                        this.SaveBookingRoom(item);
                    }
                }
            }
        }
 private void btnSave_Click(object sender, EventArgs e)
 {
     aAccountancyBO.Save(this.aNewPaymentEN);
     this.aNewPaymentEN = new NewPaymentEN();
     this.InitData(this.IDBookingR, this.IDBookingH);
     //this.LoadData();
     MessageBox.Show("Lưu thông tin hóa đơn thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
     if (this.afrmMain != null)
     {
         this.afrmMain.ReloadData();
     }
 }
        public void Save(NewPaymentEN aNewPaymentEN)
        {
            try
            {
                DatabaseDA aDatabaseDA = new DatabaseDA();
                if (aNewPaymentEN.IDBookingR != null)
                {
                    BookingRs aTemp = aDatabaseDA.BookingRs.Where(a => a.ID == aNewPaymentEN.IDBookingR).ToList()[0];
                    if (aTemp != null)
                    {
                        aTemp.CreatedDate = aNewPaymentEN.CreatedDate_BookingR;
                        aTemp.ID = Convert.ToInt32(aNewPaymentEN.IDBookingR);
                        aTemp.Status = aNewPaymentEN.Status_BookingR;
                        aTemp.InvoiceNumber = aNewPaymentEN.InvoiceNumber;
                        aTemp.AcceptDate = aNewPaymentEN.AcceptDate.GetValueOrDefault(Convert.ToDateTime("01/01/1900"));
                        aTemp.InvoiceDate = aNewPaymentEN.InvoiceDate.GetValueOrDefault(Convert.ToDateTime("01/01/1900"));
                        aTemp.BookingMoney = aNewPaymentEN.BookingRMoney;
                        aTemp.PayMenthod = aNewPaymentEN.PayMenthodR;

                        aDatabaseDA.BookingRs.AddOrUpdate(aTemp);
                        aDatabaseDA.SaveChanges();
                    }
                    foreach (BookingRoomUsedEN item in aNewPaymentEN.aListBookingRoomUsed)
                    {
                        int a = this.SaveBookingRoom(item);
                    }
                }
                if (aNewPaymentEN.IDBookingH >0)
                {

                    BookingHs aTemp = aDatabaseDA.BookingHs.Where(a => a.ID == aNewPaymentEN.IDBookingH).ToList()[0];
                    if (aTemp != null)
                    {
                        aTemp.CreatedDate = aNewPaymentEN.CreatedDate_BookingH;
                        aTemp.ID = Convert.ToInt32(aNewPaymentEN.IDBookingH);
                        aTemp.Status = aNewPaymentEN.Status_BookingH;
                        aTemp.BookingMoney = aNewPaymentEN.BookingHMoney;
                        aTemp.InvoiceNumber = aNewPaymentEN.InvoiceNumber;
                        aTemp.AcceptDate = aNewPaymentEN.AcceptDate;
                        aTemp.InvoiceDate = aNewPaymentEN.InvoiceDate;
                        aTemp.PayMenthod = aNewPaymentEN.PayMenthodH;
                        aDatabaseDA.BookingHs.AddOrUpdate(aTemp);
                        aDatabaseDA.SaveChanges();
                    }
                    foreach (BookingHallUsedEN item in aNewPaymentEN.aListBookingHallUsed)
                    {
                        this.SaveBookingHall(item);
                    }
                }
                // Luu thong tin cong ty
                Companies aCompany = aDatabaseDA.Companies.Where(a => a.ID == aNewPaymentEN.IDCompany).ToList()[0];
                aCompany.TaxNumberCode = aNewPaymentEN.TaxNumberCodeCompany;
                aCompany.Address = aNewPaymentEN.AddressCompany;
                aCompany.ID = Convert.ToInt32(aNewPaymentEN.IDCompany);
                aDatabaseDA.Companies.AddOrUpdate(aCompany);
                aDatabaseDA.SaveChanges();

            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("AccountancyBO.Save :" + ex.Message.ToString()));
            }
        }
 public frmTsk_SplitBill_Step1(frmTsk_Payment_Step2 afrmTsk_Payment_Step2, NewPaymentEN aNewPaymentEN)
 {
     InitializeComponent();
     this.afrmTsk_Payment_Step2 = afrmTsk_Payment_Step2;
     this.aNewPaymentEN = aNewPaymentEN;
 }
 public frmTsk_ChoosePrintType(NewPaymentEN aNewPaymentEN)
 {
     this.aNewPaymentEN = aNewPaymentEN;
     InitializeComponent();
 }
        public frmRpt_Payment_BookingRsUnPay(NewPaymentEN aNewPaymentEN)
        {
            InitializeComponent();
            this.aNewPaymentEN = aNewPaymentEN;

            try
            {
                //------------- Phong ------------------------

                lblNumberVote.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblIDBookingR.Text = Convert.ToString(this.aNewPaymentEN.IDBookingR);
                lblNameCustomer.Text = this.aNewPaymentEN.NameCustomer;
                lblGroup.Text = this.aNewPaymentEN.NameCustomerGroup;
                lblCompany.Text = this.aNewPaymentEN.NameCompany;
                lblTaxNumberCode.Text = this.aNewPaymentEN.TaxNumberCodeCompany;

                int day = DateTime.Now.Day;
                int month = DateTime.Now.Month;
                int year = DateTime.Now.Year;
                lblDayMonthYear.Text = "Hà Nội, ngày " + day.ToString() + " tháng " + month.ToString() + " năm " + year.ToString();

                aListServiceUsed = this.aNewPaymentEN.GetAllServiceUsedInRoom();
                //Lấy List< IDServiceGroup>
                List<int> aTemp = new List<int>();
                int IDServiceGroup;
                foreach (ServiceUsedEN item in aListServiceUsed)
                {
                    IDServiceGroup = new int();

                    IDServiceGroup = item.IDServiceGroup;
                    aTemp.Add(IDServiceGroup);
                }
                aListIDServicesGroup = aTemp.Distinct().ToList();

                ServiceGroupEN aServicesGroupEN;
                ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();

                foreach (int item in aListIDServicesGroup)
                {
                    aServicesGroupEN = new ServiceGroupEN();
                    aServicesGroupEN.IDServiceGroup = item;

                    aServicesGroupEN.TotalMoneyBeforeTax = this.GetTotalMoneyServiceGroupBeforeTax(item);
                    aServicesGroupEN.DisplayMoneyTax = aNewPaymentEN.GetMoneyTax(this.GetTotalMoneyServiceGroupBeforeTax(item), 10);
                    aServicesGroupEN.TotalMoneyAfterTax = this.GetTotalMoneyServiceGroupAfterTax(item);
                    aServicesGroupEN.ServiceGroupName = aServiceGroupsBO.Sel_ByID(item).Name;

                    aListServicesGroupEN.Add(aServicesGroupEN);
                }

                //danh sach phong
                this.DetailReport.DataSource = aNewPaymentEN.aListBookingRoomUsed;

                colSkuRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "RoomSku");
                colCheckIn.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckInActual", "{0:dd-MM-yyyy HH:mm}");
                if (aNewPaymentEN.Status_BookingR == 8 || aNewPaymentEN.Status_BookingR == 7)
                {
                    colCheckOut.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckOutActual", "{0:dd-MM-yyyy HH:mm}");
                }
                else
                {
                    colCheckOut.DataBindings.Add("Text", this.DetailReport.DataSource, "CheckOutPlan", "{0:dd-MM-yyyy HH:mm}");

                }
                colBookingRoomCost.DataBindings.Add("Text", this.DetailReport.DataSource, "Cost", "{0:0,0.##}");
                colDateInUse.DataBindings.Add("Text", this.DetailReport.DataSource, "DateUsed", "{0:0,0.##}");
                colMoneyRoomBeforeTax.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoomBeforeTax", "{0:0,0}");
                colPercentTaxRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "DisplayMoneyTaxRoom", "{0:0,0}");
                colPaymentMoneyaRoom.DataBindings.Add("Text", this.DetailReport.DataSource, "MoneyRoom", "{0:0,0}");

                ////tong tien phong truoc thue
                //lblSumMoneyRoomsBeforeTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetMoneyRoomsBeforeTax()));
                ////Tong tien thue
                //lblSumMoneyRoomTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetMoneyTax(this.aNewPaymentEN.GetMoneyRoomsBeforeTax(), 10)));
                ////tong tien phong sau thue
                //lblSumMoneyRoomsAfterTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetMoneyRooms()));

                XRSummary aXRSummaryMoneyRoomBeforeTax = new XRSummary();
                aXRSummaryMoneyRoomBeforeTax.Func = SummaryFunc.Sum;
                aXRSummaryMoneyRoomBeforeTax.Running = SummaryRunning.Group;
                aXRSummaryMoneyRoomBeforeTax.IgnoreNullValues = true;
                aXRSummaryMoneyRoomBeforeTax.FormatString = "{0:0,0}";
                XRBinding aXRBindingMoneyRoomBeforeTax = new XRBinding("Text", this.DetailReport.DataSource, "MoneyRoomBeforeTax", "{0:0,0}");
                XRBinding[] listXRBindingMoneyRoomBeforeTax = new XRBinding[] { aXRBindingMoneyRoomBeforeTax };
                lblSumMoneyRoomsBeforeTax.DataBindings.AddRange(listXRBindingMoneyRoomBeforeTax);
                lblSumMoneyRoomsBeforeTax.Summary = aXRSummaryMoneyRoomBeforeTax;

                XRSummary aXRSummaryDisplayMoneyTaxRoom = new XRSummary();
                aXRSummaryDisplayMoneyTaxRoom.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyTaxRoom.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyTaxRoom.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyTaxRoom.FormatString = "{0:0,0}";
                XRBinding aXRBindingDisplayMoneyTaxRoom = new XRBinding("Text", this.DetailReport.DataSource, "DisplayMoneyTaxRoom", "{0:0,0}");
                XRBinding[] listXRBindingDisplayMoneyTaxRoom = new XRBinding[] { aXRBindingDisplayMoneyTaxRoom };
                lblSumMoneyRoomTax.DataBindings.AddRange(listXRBindingDisplayMoneyTaxRoom);
                lblSumMoneyRoomTax.Summary = aXRSummaryDisplayMoneyTaxRoom;

                XRSummary aXRSummaryMoneyRoom = new XRSummary();
                aXRSummaryMoneyRoom.Func = SummaryFunc.Sum;
                aXRSummaryMoneyRoom.Running = SummaryRunning.Group;
                aXRSummaryMoneyRoom.IgnoreNullValues = true;
                aXRSummaryMoneyRoom.FormatString = "{0:0,0}";
                XRBinding aXRBindingMoneyRoom = new XRBinding("Text", this.DetailReport.DataSource, "MoneyRoom", "{0:0,0}");
                XRBinding[] listXRBindingMoneyRoom = new XRBinding[] { aXRBindingMoneyRoom };
                lblSumMoneyRoomsAfterTax.DataBindings.AddRange(listXRBindingMoneyRoom);
                lblSumMoneyRoomsAfterTax.Summary = aXRSummaryMoneyRoom;

                //danh sach dich vu
                this.DetailReport2.DataSource = aListServicesGroupEN;
                colNamService.DataBindings.Add("Text", this.DetailReport2.DataSource, "ServiceGroupName");
                colTotalMoneyBeforeTax.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoneyBeforeTax", "{0:0,0}");
                colPercentTaxService.DataBindings.Add("Text", this.DetailReport2.DataSource, "DisplayMoneyTax", "{0:0,0}");
                colTotalMoneyServiceAfterTax.DataBindings.Add("Text", this.DetailReport2.DataSource, "TotalMoneyAfterTax", "{0:0,0}");

                ////tong tien dich vu truoc thue
                //lblSumMoneyService_BookingRBeforeTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyServiceUsedInRoomsBeforeTax()));
                ////Tong so tien thue
                //lblSumMoneyServiceTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetMoneyTax(this.aNewPaymentEN.GetTotalMoneyServiceUsedInRoomsBeforeTax(), 10)));
                ////tong tien dich vu sau thue
                //lblSumMoneyService_BookingRAfterTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyServiceUsedInRooms()));

                XRSummary aXRSummaryTotalMoneyBeforeTax = new XRSummary();
                aXRSummaryTotalMoneyBeforeTax.Func = SummaryFunc.Sum;
                aXRSummaryTotalMoneyBeforeTax.Running = SummaryRunning.Group;
                aXRSummaryTotalMoneyBeforeTax.IgnoreNullValues = true;
                aXRSummaryTotalMoneyBeforeTax.FormatString = "{0:0,0}";
                lblSumMoneyService_BookingRBeforeTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReport2.DataSource, "TotalMoneyBeforeTax", "{0:0,0}") });
                lblSumMoneyService_BookingRBeforeTax.Summary = aXRSummaryTotalMoneyBeforeTax;

                XRSummary aXRSummaryDisplayMoneyTax = new XRSummary();
                aXRSummaryDisplayMoneyTax.Func = SummaryFunc.Sum;
                aXRSummaryDisplayMoneyTax.Running = SummaryRunning.Group;
                aXRSummaryDisplayMoneyTax.IgnoreNullValues = true;
                aXRSummaryDisplayMoneyTax.FormatString = "{0:0,0}";
                lblSumMoneyServiceTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReport2.DataSource, "DisplayMoneyTax", "{0:0,0}") });
                lblSumMoneyServiceTax.Summary = aXRSummaryDisplayMoneyTax;

                XRSummary aXRSummaryTotalMoneyAfterTax = new XRSummary();
                aXRSummaryTotalMoneyAfterTax.Func = SummaryFunc.Sum;
                aXRSummaryTotalMoneyAfterTax.Running = SummaryRunning.Group;
                aXRSummaryTotalMoneyAfterTax.IgnoreNullValues = true;
                aXRSummaryTotalMoneyAfterTax.FormatString = "{0:0,0}";
                lblSumMoneyService_BookingRAfterTax.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", this.DetailReport2.DataSource, "TotalMoneyAfterTax", "{0:0,0}") });
                lblSumMoneyService_BookingRAfterTax.Summary = aXRSummaryTotalMoneyAfterTax;

                //tong tien thanh toan truoc thue
                lblTotalMoneyBookingRBeforeTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyBeforeTax()));
                //tien thue
                lblTotalMoneyTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetMoneyTax(Convert.ToDecimal(this.aNewPaymentEN.GetMoneyRoomsBeforeTax()) + Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoneyServiceUsedInRoomsBeforeTax()), 10)));
                //tong tien thanh toan sau thue
                lblTotalMoneyBookingRAfterTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoney()));
                //So tien ung truoc
                lblBookingMoney_BookingR.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentEN.BookingRMoney));
                //so tien con lai can thanh toan
                lblTotalMoney_BookingR.Text = String.Format("{0:0,0}", (Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoney()) - Convert.ToDecimal(this.aNewPaymentEN.BookingRMoney)));
                string TotalMoney_BookingRString = UppercaseFirst(StringUtility.ConvertDecimalToString((Convert.ToDecimal(this.aNewPaymentEN.GetTotalMoney()) - Convert.ToDecimal(this.aNewPaymentEN.BookingRMoney))));

                lblTotalMoney_BookingRString.Text = "(" + TotalMoney_BookingRString + ")";

            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public double CaculateBooking(NewPaymentEN aNewPayment, int IDBookingRoom, DateTime StartTime, DateTime EndTime)
        {
            try
            {
                if (aNewPayment.aListBookingRoomUsed.Where(a => a.ID == IDBookingRoom).ToList().Count > 0)
                {
                    TimeSpan dis = EndTime.Subtract(StartTime);
                    double a = (dis.TotalHours) / 24;
                    double a1 = 0;
                    if (a < 1)
                    {
                        a1 = Math.Floor(a);
                    }
                    else
                    {
                        a1 = Math.Round(a);
                    }

                    double addtimeStart = 0;
                    double addtimeEnd = 0;
                    DateTime CheckIn = DateTime.Parse(StartTime.ToString("HH:mm"));
                    DateTime CheckOut = DateTime.Parse(EndTime.ToString("HH:mm"));

                    if (aNewPayment.aListBookingRoomUsed.Where(b => b.ID == IDBookingRoom).ToList()[0].Type == 3)//Tính checkin sớm và Checkout muộn
                    {
                        CheckPointBO aCheckPointBO = new CheckPointBO();
                        List<CheckPoints> aListCheckPoint = aCheckPointBO.Select_All();
                        for (int i = 0; i < aListCheckPoint.Count; i++)
                        {
                            if (aListCheckPoint[i].Type == 1) // checkIn som
                            {
                                if (aListCheckPoint[i].From <= CheckIn.TimeOfDay && CheckIn.TimeOfDay <= aListCheckPoint[i].To)
                                {
                                    addtimeStart = aListCheckPoint[i].AddTime;
                                }
                            }

                            else if (aListCheckPoint[i].Type == 2) // CheckOut muon
                            {
                                if (aListCheckPoint[i].From <= CheckOut.TimeOfDay && CheckOut.TimeOfDay <= aListCheckPoint[i].To)
                                {
                                    addtimeEnd = aListCheckPoint[i].AddTime;
                                }
                            }

                        }

                        double result = a1 + addtimeEnd + addtimeStart;
                        if (result < 1)
                        {
                            return 1;
                        }
                        else
                        {
                            return result;
                        }
                    }
                    else if (aNewPayment.aListBookingRoomUsed.Where(b => b.ID == IDBookingRoom).ToList()[0].Type == 0) //Không tính checkIn sớm và checkout muộn.
                    {

                        return a1;
                    }
                    else if (aNewPayment.aListBookingRoomUsed.Where(b => b.ID == IDBookingRoom).ToList()[0].Type == 2) //Tính checkin sớm ,không tính checkout muộn.
                    {
                        CheckPointBO aCheckPointBO = new CheckPointBO();
                        List<CheckPoints> aListCheckPoint = aCheckPointBO.Select_All();
                        for (int i = 0; i < aListCheckPoint.Count; i++)
                        {
                            if (aListCheckPoint[i].Type == 1) // checkIn som
                            {
                                if (aListCheckPoint[i].From <= CheckIn.TimeOfDay && CheckIn.TimeOfDay <= aListCheckPoint[i].To)
                                {
                                    addtimeStart = aListCheckPoint[i].AddTime;
                                }
                            }
                        }
                        return a1 + addtimeStart;

                    }
                    else if (aNewPayment.aListBookingRoomUsed.Where(b => b.ID == IDBookingRoom).ToList()[0].Type == 1) //Không tính checkin sớm ,tính checkout muộn
                    {
                        CheckPointBO aCheckPointBO = new CheckPointBO();
                        List<CheckPoints> aListCheckPoint = aCheckPointBO.Select_All();
                        for (int i = 0; i < aListCheckPoint.Count; i++)
                        {
                            if (aListCheckPoint[i].Type == 2) // CheckOut muon
                            {
                                if (aListCheckPoint[i].From <= CheckOut.TimeOfDay && CheckOut.TimeOfDay <= aListCheckPoint[i].To)
                                {
                                    addtimeEnd = aListCheckPoint[i].AddTime;
                                }
                            }

                        }

                        return a1 + addtimeEnd;
                    }

                }
                return 0;
            }
            catch (Exception ex)
            {
                throw new Exception("ReceptionTaskBO.CaculateBooking \n" + ex.ToString());
            }
        }