public void ReloadData()
        {
            try
            {
                ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
                dgvSerGroup.DataSource = aServiceGroupsBO.Sel_all();
                dgvSerGroup.RefreshDataSource();

                lueType.Properties.DataSource = CORE.CONSTANTS.ListServiceTypes;
                lueType.Properties.DisplayMember = "Name";
                lueType.Properties.ValueMember = "ID";
                lueType.EditValue = CORE.CONSTANTS.SelectedServiceType(2).ID;

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_ServiceGroups.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void ReloadData()
 {
     try
     {
         ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
         List<ServiceGroups> aListServiceGroups = aServiceGroupsBO.Sel_all();
         lueIDServiceGroup.Properties.DataSource = aListServiceGroups;
         lueIDServiceGroup.Properties.DisplayMember = "Name";
         lueIDServiceGroup.Properties.ValueMember = "ID";
         if (aListServiceGroups.Count > 0)
         {
             lueIDServiceGroup.EditValue = aListServiceGroups[0].ID;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmIns_Services.ReloadData\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        private void bnAdd_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData() == true)
                {
                    ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
                    ServiceGroups aServiceGroups = new ServiceGroups();
                    aServiceGroups.Name = txtName.Text;
                    aServiceGroups.Type = Convert.ToInt32(lueType.EditValue);

                    aServiceGroups.Disable = bool.Parse(cbxDisable.SelectedItem.ToString());

                    int ret = aServiceGroupsBO.Insert(aServiceGroups);
                    if (ret == 1)
                    {
                        lblID.Text = "";
                        txtName.Text = "";
                        lueType.EditValue = 0;
                        cbxDisable.SelectedIndex = 0;
                        MessageBox.Show("Thêm mới thành công","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information);
                        this.ReloadData();
                        if (afrmIns_Services != null)
                        {
                            this.afrmIns_Services.ReloadData();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Thất mới nhóm dịch vụ thất bại.","Lỗi",MessageBoxButtons.OK,MessageBoxIcon.Error);
                    }
                }

            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_ServiceGroups.bnAdd_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void frmUpd_Services_Load(object sender, EventArgs e)
 {
     try
     {
         ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
         lueIDServiceGroup.Properties.DataSource = aServiceGroupsBO.Sel_all();
         lueIDServiceGroup.Properties.DisplayMember = "Name";
         lueIDServiceGroup.Properties.ValueMember = "ID";
         ServicesBO aServiceBO = new ServicesBO();
         Services aService = aServiceBO.Select_ByID(ID);
         lblIDService.Text = ID.ToString();
         txtName.Text = aService.Name;
         txtCost.Text = String.Format("{0:0,0}",aService.CostRef);
         cboDisable.Text = aService.Disable.ToString();
         cboStatus.SelectedIndex = Convert.ToInt32(aService.Status - 1);
         cboType.SelectedIndex = Convert.ToInt32(aService.Type - 1);
         txtUnit.Text = aService.Unit;
         lueIDServiceGroup.EditValue = aService.IDServiceGroups;
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmUpd_Services.frmUpd_Services_Load\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
        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();
            }
        }
        private void btnPrintPayment_OldStyle_Click(object sender, EventArgs e)
        {
            ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
            List<ServiceGroups> aListServiceGroups = new List<ServiceGroups>();
            aListServiceGroups = aServiceGroupsBO.Sel_all().OrderBy(p => p.Order).ToList();
            List<int> ListIDServiceGroup = new List<int>();
            ListIDServiceGroup.AddRange(aListServiceGroups.Select(p => p.ID).ToList());

            List<RptPaymentStyle1_ForDisplay> aList = this.aNewPaymentEN.ConvertDataFor_RptPaymentStyle1(ListIDServiceGroup);
            frmTsk_ReportPaymentStyle1 afrm = new frmTsk_ReportPaymentStyle1(aList.OrderBy(p => p.Date).ToList(), aListServiceGroups, this.aNewPaymentEN.NameCompany, this.aNewPaymentEN.AddressCompany, this.aNewPaymentEN.NameCustomerGroup, this.aNewPaymentEN.InvoiceNumber, this.aNewPaymentEN.GetFirstDate(), this.aNewPaymentEN.GetLastDate(), this.aNewPaymentEN.BookingHMoney, this.aNewPaymentEN.BookingRMoney, this.IDBookingR);
            afrm.ShowDialog();
        }
        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();
            }
        }
        private void frmTsk_ReportPaymentStyle1_Load(object sender, EventArgs e)
        {
            ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
            List<ServiceGroups> aList = aServiceGroupsBO.Sel_all().Where(p=>aListIDCustomerGroup.Contains(p.ID)).ToList();

            //GridColumn aCol = new GridColumn();
            //aCol.Caption = "Ngày";
            //aCol.FieldName = "Date";
            //aCol.Visible = true;
            //this.gridView1.Columns.Add(aCol);

            //aCol = new GridColumn();
            //aCol.Caption = "Ghi chú";
            //aCol.FieldName = "Note";
            //aCol.Visible = true;
            //this.gridView1.Columns.Add(aCol);

            //aCol = new GridColumn();
            //aCol.Caption = "Số người";
            //aCol.FieldName = "CountCustomerInGroup";
            //aCol.DisplayFormat.FormatType = FormatType.Numeric;
            //aCol.DisplayFormat.FormatString = "{0:0,0}";
            //aCol.Visible = true;
            //this.gridView1.Columns.Add(aCol);

            //aCol = new GridColumn();
            //aCol.Caption = "Tiền phòng";
            //aCol.FieldName = "Room_Fee";
            //aCol.DisplayFormat.FormatType = FormatType.Numeric;
            //aCol.DisplayFormat.FormatString = "{0:0,0}";
            //aCol.Visible = true;
            //this.gridView1.Columns.Add(aCol);

            //aCol = new GridColumn();
            //aCol.Caption = "Tiền hội trường";
            //aCol.FieldName = "Hall_Fee";
            //aCol.DisplayFormat.FormatType = FormatType.Numeric;
            //aCol.DisplayFormat.FormatString = "{0:0,0}";
            //aCol.Visible = true;
            //this.gridView1.Columns.Add(aCol);

            GridColumn aCol = new GridColumn();
            for (int i = 0; i < this.aListIDCustomerGroup.Count ; i++)
            {
                List<ServiceGroups> aListItem = aList.Where(p => p.ID == this.aListIDCustomerGroup[i]).ToList();
                if (aListItem.Count > 0)
                {
                    aCol = new GridColumn();
                    aCol.Caption = aListItem[0].Name;
                    int tempt =  2 + i ;
                    aCol.FieldName = "ServiceGroup"+ tempt +"_Fee";
                    aCol.DisplayFormat.FormatType = FormatType.Numeric;
                    aCol.DisplayFormat.FormatString = "{0:0,0}";
                    aCol.Visible = true;
                    this.grvReportPaymentStyle1.Columns.Add(aCol);
                }
            }

            this.dgvReportPaymentStyle1.MainView = this.grvReportPaymentStyle1;
            this.dgvReportPaymentStyle1.DataSource = this.aListRet;
        }
        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();
            }
        }
        private void bnDelete_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            try
            {
                int ID =Convert.ToInt32(gridView1.GetFocusedRowCellValue("ID"));
                DialogResult result = MessageBox.Show("Bạn có muốn xóa nhóm dịch vụ " + ID + " này không?", "Xóa", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.Yes)
                {
                    ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
                    aServiceGroupsBO.Delete_ByID(ID);
                    MessageBox.Show("Xóa thành công","Thông báo",MessageBoxButtons.OK,MessageBoxIcon.Information);
                    this.ReloadData();

                    bnAdd.Enabled = true;
                    bnEdit.Enabled = false;
                    lblID.Text = "";
                    txtName.Text = "";
                    cbxDisable.SelectedIndex = 0;
                    if (afrmIns_Services != null)
                    {
                        this.afrmIns_Services.ReloadData();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_ServiceGroups.bnDelete_ButtonClick\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 private void gridView1_RowClick(object sender, DevExpress.XtraGrid.Views.Grid.RowClickEventArgs e)
 {
     try
     {
         bnEdit.Enabled = true;
         bnAdd.Enabled = false;
         ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
         int ID = int.Parse(gridView1.GetFocusedRowCellValue("ID").ToString());
         txtName.Text = aServiceGroupsBO.Sel_ByID(ID).Name;
         lueType.EditValue = aServiceGroupsBO.Sel_ByID(ID).Type;
         cbxDisable.Text = aServiceGroupsBO.Sel_ByID(ID).Disable.ToString();
         lblID.Text = ID.ToString();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmIns_ServiceGroups.gridView1_RowClick\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
 private void bnEdit_Click(object sender, EventArgs e)
 {
     try
     {
         if (String.IsNullOrEmpty(txtName.Text) == true)
         {
             txtName.Focus();
             MessageBox.Show("Vui lòng nhập tên nhóm dịch vụ.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         else
         {
             bnAdd.Enabled = true;
             bnEdit.Enabled = false;
             ServiceGroupsBO aServiceGroupsBO = new ServiceGroupsBO();
             ServiceGroups aServiceGroups = new ServiceGroups();
             aServiceGroups.ID =Convert.ToInt32(lblID.Text);
             aServiceGroups.Name = txtName.Text;
             aServiceGroups.Type = Convert.ToInt32(lueType.EditValue);
             aServiceGroups.Disable = bool.Parse(cbxDisable.SelectedItem.ToString());
             aServiceGroupsBO.Update(aServiceGroups);
             this.ReloadData();
             if (afrmIns_Services != null)
             {
                 this.afrmIns_Services.ReloadData();
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmIns_ServiceGroups.bnEdit_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }