public frmRpt_SplitPayment_BookingHs(PaymentHallsEN aPaymentHallsEN, int indexSub)
        {
            InitializeComponent();
            this.aPaymentHallsEN = aPaymentHallsEN;
            this.indexSub = indexSub;
            try
            {
                ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                HallsBO aHallsBO = new HallsBO();
                ServicesBO aServicesBO = new ServicesBO();
                List<HallsEN> aListHallsEN = new List<HallsEN>();
                aListHallsEN=this.aPaymentHallsEN.GetListHallsEN().Where(r => r.IndexSubHalls == this.indexSub).OrderBy(r => r.Sku).ToList();
                totalMoneyHall = aListHallsEN.Sum(s => s.TotalCost);

                List<ServicesHallsEN> aListServicesHallsEN = new List<ServicesHallsEN>();
                aListServicesHallsEN=this.aPaymentHallsEN.GetListServicesHallsEN().Where(r => r.IndexSubServices == this.indexSub).OrderBy(r => r.SkuHall).ToList();
                totalMoneyService = aListServicesHallsEN.Sum(s => s.Total);

                lblCompany.Text = this.aPaymentHallsEN.NameCompany;
                lblGroup.Text =this.aPaymentHallsEN.NameCustomerGroup;
                lblNameCustomer.Text =this.aPaymentHallsEN.NameCustomer;
                lblIDBookingH.Text = Convert.ToString(this.aPaymentHallsEN.IDBookingH);

                //danh sach hoi truong
                this.DetailReportHall.DataSource = aListHallsEN;
                colSkuHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Sku");
                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, "TotalMoney", "{0:0,0}");

                //danh sach dich vu su dung
                this.DetailReportService.DataSource = aListServicesHallsEN;
                colService_Sku.DataBindings.Add("Text", this.DetailReportService.DataSource, "SkuHall");
                colService_Name.DataBindings.Add("Text", this.DetailReportService.DataSource, "NameService");
                colService_Date.DataBindings.Add("Text", this.DetailReportService.DataSource, "Date", "{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, "PercentTax");
                colService_Money.DataBindings.Add("Text", this.DetailReportService.DataSource, "Total", "{0:0,0}");

                //tong tien dich vu
                lblTotalMoneyServices.Text = String.Format("{0:0,0} (VND)",this.totalMoneyService);
                //tong tien hoi truong
                lblTotalMoneyHall.Text = String.Format("{0:0,0} (VND)",this.totalMoneyHall);

                //tong tien
                lblTotalMoney.Text = String.Format("{0:0,0}",aPaymentHallsEN.GetTotalMoneyBookingHBehindTax());
                lblBookingMoney.Text = String.Format("{0:0,0}",this.aPaymentHallsEN.GetBookingMoney());
                lblMoney.Text = String.Format("{0:0,0}", (aPaymentHallsEN.GetTotalMoneyBookingHBehindTax() - this.aPaymentHallsEN.GetBookingMoney()));

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmRpt_PaymentBookingHs.frmRpt_PaymentBookingHs\n" + ex.ToString());
            }
        }
 //Hiennv
 public void LoadListServices_ByIndexSubServices(PaymentHallsEN aPaymentHallsEN, int IndexSubServices)
 {
     try
     {
         this.aListServices.Clear();
         this.aListServices = aPaymentHallsEN.GetListServicesHallsEN().Where(r => r.IndexSubServices == IndexSubServices).OrderBy(r => r.SkuHall).ToList();
         dgvServices.DataSource = this.aListServices;
         dgvServices.RefreshDataSource();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_SplitBillHalls_Step2.LoadListServices_ByIndexSubServices\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        //hiennv
        public void InitData(PaymentHallsEN aPaymentHallsEN, int IDBookingH)
        {
            try
            {
                HallsBO aHallsBO = new HallsBO();
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                FoodsBO aFoodsBO = new FoodsBO();
                ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                CustomersBO aCustomersBO = new CustomersBO();
                BookingHsBO aBookingHsBO = new BookingHsBO();
                CompaniesBO aCompaniesBO = new CompaniesBO();
                SystemUsersBO aSystemUsersBO = new SystemUsersBO();

                BookingHs aBookingHs = aBookingHsBO.Select_ByID(IDBookingH);
                if (aBookingHs != null)
                {
                    aPaymentHallsEN.IDBookingH = aBookingHs.ID;
                    aPaymentHallsEN.IDCustomerGroup = aBookingHs.IDCustomerGroup;
                    CustomerGroups aCustomerGroups = aCustomerGroupsBO.Select_ByID(aBookingHs.IDCustomerGroup);
                    if (aCustomerGroups != null)
                    {
                        aPaymentHallsEN.NameCustomerGroup = aCustomerGroups.Name;
                        aPaymentHallsEN.IDCompany = aCustomerGroups.IDCompany;
                        Companies aCompanies = aCompaniesBO.Select_ByID(aCustomerGroups.IDCompany);
                        if (aCompanies != null)
                        {
                            aPaymentHallsEN.NameCompany = aCompanies.Name;
                            aPaymentHallsEN.TaxNumberCodeCompany = aCompanies.TaxNumberCode;
                        }
                    }
                    aPaymentHallsEN.IDCustomer = aBookingHs.IDCustomer;
                    Customers aCustomers = aCustomersBO.Select_ByID(aBookingHs.IDCustomer);
                    if (aCustomers != null)
                    {
                        aPaymentHallsEN.NameCustomer = aCustomers.Name;

                    }
                    aPaymentHallsEN.IDSystemUser = aBookingHs.IDSystemUser;
                    SystemUsers aSystemUsers = aSystemUsersBO.Select_ByID(aBookingHs.IDSystemUser);
                    if (aSystemUsers != null)
                    {
                        aPaymentHallsEN.NameSystemUser = aSystemUsers.Name;
                    }
                    aPaymentHallsEN.CreatedDate_BookingH = aBookingHs.CreatedDate;
                    aPaymentHallsEN.CustomerType = aBookingHs.CustomerType;
                    aPaymentHallsEN.BookingType = aBookingHs.BookingType;
                    aPaymentHallsEN.PayMenthod = aBookingHs.PayMenthod;
                    aPaymentHallsEN.StatusPay = aBookingHs.StatusPay;
                    aPaymentHallsEN.Status_BookingH = aBookingHs.Status;
                    aPaymentHallsEN.ExchangeRate = aBookingHs.ExchangeRate;
                    aPaymentHallsEN.Level = aBookingHs.Level;
                    aPaymentHallsEN.BookingMoney = aBookingHs.BookingMoney;
                }

                List<BookingHalls> aListBookingHalls = new List<BookingHalls>();
                aListBookingHalls = aBookingHallsBO.Select_ByIDBookigH(IDBookingH);
                InfoDetailPaymentHallsEN aInfoDetailPaymentHallsEN;
                for (int i = 0; i < aListBookingHalls.Count; i++)
                {
                    aInfoDetailPaymentHallsEN = new InfoDetailPaymentHallsEN();
                    Halls aHalls = aHallsBO.Select_ByCodeHall(aListBookingHalls[i].CodeHall, 1);
                    if (aHalls != null)
                    {
                        aInfoDetailPaymentHallsEN.Sku = aHalls.Sku;
                    }
                    else
                    {
                        aInfoDetailPaymentHallsEN.Sku = string.Empty;
                    }
                    aInfoDetailPaymentHallsEN.aBookingHalls = aListBookingHalls[i];
                    aInfoDetailPaymentHallsEN.aMenusEN = aReceptionTaskBO.GetDetailMenu_ByIDBookingHall(aListBookingHalls[i].ID);
                    aInfoDetailPaymentHallsEN.aListServicesHallsEN = aReceptionTaskBO.GetListServicesHallsEN_ByIDBookingHall(aListBookingHalls[i].ID);

                    aPaymentHallsEN.aListInfoDetailPaymentHallsEN.Insert(i, aInfoDetailPaymentHallsEN);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_PaymentHall.InitData\n" + ex.ToString());
            }
        }
 public frmTsk_SplitBillHalls_Step2(frmTsk_SplitBillHalls_Step1 afrmTsk_SplitBillHalls_Step1, PaymentHallsEN aPaymentHallsEN)
 {
     InitializeComponent();
     this.afrmTsk_SplitBillHalls_Step1 = afrmTsk_SplitBillHalls_Step1;
     this.aPaymentHallsEN = aPaymentHallsEN;
 }
        public frmRpt_PaymentBookingHs(PaymentHallsEN aPaymentHallsEN)
        {
            InitializeComponent();
            this.aPaymentHallsEN = aPaymentHallsEN;
            try
            {
                //------------------------------- Hoi truong ---------------------

                lblNumberVote.Text = Convert.ToString(this.aPaymentHallsEN.IDBookingH);
                lblIDBookingH.Text = Convert.ToString(this.aPaymentHallsEN.IDBookingH);
                lblNameCustomer.Text = this.aPaymentHallsEN.NameCustomer;
                lblGroup.Text = this.aPaymentHallsEN.NameCustomerGroup;
                lblCompany.Text = this.aPaymentHallsEN.NameCompany;
                lblTaxNumberCode.Text = this.aPaymentHallsEN.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();

                List<HallsEN> aListHallsEN = new List<HallsEN>();
                HallsEN aHallsEN;
                List<ServicesHallsEN> aListServicesHallsEN = new List<ServicesHallsEN>();
                ServicesHallsEN aServicesHallsEN;

                foreach (InfoDetailPaymentHallsEN aInfoDetailPaymentHallsEN in this.aPaymentHallsEN.aListInfoDetailPaymentHallsEN)
                {

                    aHallsEN = new HallsEN();
                    aHallsEN.IDBookingHall = aInfoDetailPaymentHallsEN.aBookingHalls.ID;
                    aHallsEN.IDBookingH = aInfoDetailPaymentHallsEN.aBookingHalls.IDBookingH;
                    aHallsEN.CodeHall = aInfoDetailPaymentHallsEN.aBookingHalls.CodeHall;
                    aHallsEN.Sku = aInfoDetailPaymentHallsEN.Sku;
                    aHallsEN.Date = aInfoDetailPaymentHallsEN.aBookingHalls.Date;
                    aHallsEN.Cost = aInfoDetailPaymentHallsEN.aBookingHalls.Cost;
                    aHallsEN.PercentTax = aInfoDetailPaymentHallsEN.aBookingHalls.PercentTax;
                    aHallsEN.CostRef_Halls = aInfoDetailPaymentHallsEN.aBookingHalls.CostRef_Halls;
                    aHallsEN.TotalMoney = aPaymentHallsEN.GetMoneyHall(aInfoDetailPaymentHallsEN.aBookingHalls.ID);
                    aListHallsEN.Add(aHallsEN);

                    foreach (ServicesHallsEN items in aInfoDetailPaymentHallsEN.aListServicesHallsEN)
                    {
                        aServicesHallsEN = new ServicesHallsEN();
                        aServicesHallsEN.SkuHall = aHallsEN.Sku;
                        aServicesHallsEN.NameService = items.NameService;
                        aServicesHallsEN.Date = items.Date;
                        aServicesHallsEN.Quantity = items.Quantity;
                        aServicesHallsEN.Cost = items.Cost;
                        aServicesHallsEN.PercentTax = items.PercentTax;
                        aListServicesHallsEN.Add(aServicesHallsEN);
                    }

                }

                //danh sach hoi truong
                this.DetailReportHall.DataSource = aListHallsEN;
                colSkuHall.DataBindings.Add("Text", this.DetailReportHall.DataSource, "Sku");
                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, "TotalMoney", "{0:0,0}");

                //danh sach dich vu su dung
                this.DetailReportService.DataSource = aListServicesHallsEN;
                colService_Sku.DataBindings.Add("Text", this.DetailReportService.DataSource, "SkuHall");
                colService_Name.DataBindings.Add("Text", this.DetailReportService.DataSource, "NameService");
                colService_Date.DataBindings.Add("Text", this.DetailReportService.DataSource, "Date", "{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, "PercentTax");
                colService_Money.DataBindings.Add("Text", this.DetailReportService.DataSource, "Total", "{0:0,0}");

                //tong tien hoi truong truoc thue
                lblTotalMoneyHallBeforeTax.Text = String.Format("{0:0,0} (VND)", Convert.ToDecimal(this.aPaymentHallsEN.GetTotalMoneyHallBeforeTax()));
                //tong tien hoi truong sau thue
                lblTotalMoneyHallBehindTax.Text = String.Format("{0:0,0} (VND)", Convert.ToDecimal(this.aPaymentHallsEN.GetTotalMoneyHallBehindTax()));

                //tong tien dich vu hoi truong truoc thue
                lblTotalMoneyService_BookingHBeforeTax.Text = String.Format("{0:0,0} (VND)", Convert.ToDecimal(this.aPaymentHallsEN.GetTotalMoneyServiceHallBeforeTax()));
                //tong tien dich vu hoi truong sau thue
                lblTotalMoneyServices_BookingHBehindTax.Text = String.Format("{0:0,0} (VND)", Convert.ToDecimal(this.aPaymentHallsEN.GetTotalMoneyServiceHallBehindTax()));

                //tong tien bookingh

                decimal? moneyBookingHBeforeTax = Convert.ToDecimal(this.aPaymentHallsEN.GetTotalMoneyBookingHBeforeTax());
                decimal? moneyBookingHBehindTax = Convert.ToDecimal(this.aPaymentHallsEN.GetTotalMoneyBookingHBehindTax());
                lblTotalMoneyBookingHBeforeTax.Text = String.Format("{0:0,0} (VND)", moneyBookingHBeforeTax);
                lblTotalMoneyBookingHBehindTax.Text = String.Format("{0:0,0} (VND)", moneyBookingHBehindTax);
                lblBookingMoney_BookingH.Text = String.Format("{0:0,0} (VND)", Convert.ToDecimal(this.aPaymentHallsEN.GetBookingMoney()));
                lblTotalBookingH.Text = String.Format("{0:0,0} (VND)", (moneyBookingHBehindTax - Convert.ToDecimal(this.aPaymentHallsEN.GetBookingMoney())));

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmRpt_PaymentBookingHs.frmRpt_PaymentBookingHs\n" + ex.ToString());
            }
        }
        //hiennv
        public bool PaymentHall(PaymentHallsEN aPaymentHallsEN)
        {
            try
            {
                BookingHsBO aBookingHsBO = new BookingHsBO();
                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();
                BookingHs aBookingHs = aBookingHsBO.Select_ByID(aPaymentHallsEN.IDBookingH);
                aBookingHs.PayMenthod = aPaymentHallsEN.PayMenthod;
                aBookingHs.DatePay = DateTime.Now;
                aBookingHs.StatusPay = 3;//da thanh toan
                aBookingHs.Status = 8;//da thanh toan toan bo
                aBookingHs.BookingMoney = 0;

                aBookingHsBO.Update(aBookingHs);
                foreach (InfoDetailPaymentHallsEN aInfoDetailPaymentHallsEN in aPaymentHallsEN.aListInfoDetailPaymentHallsEN)
                {
                    if (aInfoDetailPaymentHallsEN.aBookingHalls.IDBookingH == aPaymentHallsEN.IDBookingH)
                    {
                        BookingHalls aBookingHalls = aBookingHallsBO.Select_ByID(aInfoDetailPaymentHallsEN.aBookingHalls.ID);
                        aBookingHalls.Cost = aInfoDetailPaymentHallsEN.aBookingHalls.Cost;
                        aBookingHalls.PercentTax = aInfoDetailPaymentHallsEN.aBookingHalls.PercentTax;
                        aBookingHalls.Status = 8;// da thanh toan

                        aBookingHallsBO.Update(aBookingHalls);
                        foreach (ServicesHallsEN aServicesHallsEN in aInfoDetailPaymentHallsEN.aListServicesHallsEN)
                        {
                            if (aServicesHallsEN.IDBookingHall == aInfoDetailPaymentHallsEN.aBookingHalls.ID)
                            {
                                BookingHalls_Services aBookingHalls_Services = aBookingHalls_ServicesBO.Select_ByIDService_ByIDBookingHall(aServicesHallsEN.IDService, aInfoDetailPaymentHallsEN.aBookingHalls.ID);
                                aBookingHalls_Services.Cost = aServicesHallsEN.Cost;
                                aBookingHalls_Services.Quantity = aServicesHallsEN.Quantity;
                                aBookingHalls_Services.PercentTax = aServicesHallsEN.PercentTax;
                                aBookingHalls_Services.Status = 8;//da thanh toan
                                aBookingHalls_ServicesBO.Update(aBookingHalls_Services);
                            }

                        }

                    }
                }
                return true;

            }
            catch (Exception ex)
            {
                return false;
                throw new Exception(string.Format("ReceptionTaskBO.PaymentHall\n" + ex.Message));
            }
        }
 public frmTsk_SplitBillHalls_Step1(frmTsk_PaymentHall afrmTsk_PaymentHall, PaymentHallsEN aPaymentHallsEN)
 {
     InitializeComponent();
     this.afrmTsk_PaymentHall = afrmTsk_PaymentHall;
     this.aPaymentHallsEN = aPaymentHallsEN;
 }