public frmIns_BookingHalls_Services(frmTsk_UpdBookingHall afrmTsk_UpdBookingHall, int IDBookingHall, NewPaymentHEN aNewPaymentH)
 {
     InitializeComponent();
     this.afrmTsk_UpdBookingHall = afrmTsk_UpdBookingHall;
     this.IDBookingHall = IDBookingHall;
     this.aNewPaymentH = aNewPaymentH;
 }
 private void btnSave_Click(object sender, System.EventArgs e)
 {
     aAccountancyBO.Save(this.aNewPaymentHEN);
     this.aNewPaymentHEN = new NewPaymentHEN();
     this.InitData( 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);
 }
 public void Reload()
 {
     this.aNewPaymentHEN = new NewPaymentHEN();
     this.InitData(this.IDBookingH);
     this.LoadData();
 }
 public void Reload(NewPaymentHEN aNewPaymentH)
 {
     this.aNewPaymentHEN = aNewPaymentH;
     this.LoadData();
 }
        public frmRpt_PaymentBookingHs(NewPaymentHEN aNewPaymentHEN)
        {
            InitializeComponent();
            this.aNewPaymentHEN = aNewPaymentHEN;
            try
            {
                //------------------------------- Hoi truong ---------------------

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

                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 Truyền thông tin hội trường
                aListServiceUsedHall = this.aNewPaymentHEN.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 = aNewPaymentHEN.GetMoneyTax(this.GetTotalMoneyServiceGroupHallBeforeTax(item), 10);
                    aServicesGroupHallEN.ServiceGroupName = aServiceGroupsBO.Sel_ByID(item).Name;
                    aListServicesGroupHallEN.Add(aServicesGroupHallEN);
                }

                //danh sach hoi truong
                this.DetailReportHall.DataSource = aNewPaymentHEN.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.aNewPaymentHEN.GetOnlyMoneyHallsBeforeTax()));
                //tong tien hoi truong sau thue
                lblSumMoneyHallsAfterTax.Text = String.Format("{0:0,0}", Convert.ToDecimal(this.aNewPaymentHEN.GetOnlyMoneyHalls()));

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

                //Tong tien hoa don can thanh toan
                decimal? beforTax = Convert.ToDecimal(this.aNewPaymentHEN.GetMoneyHallsBeforeTax());
                decimal? afterTax = Convert.ToDecimal(this.aNewPaymentHEN.GetMoneyHalls());
                decimal? bookingMoney = Convert.ToDecimal(this.aNewPaymentHEN.BookingHMoney);

                //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.aNewPaymentHEN.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_BookingHString = UppercaseFirst(Library.StringUtility.ConvertDecimalToString(Convert.ToDecimal(afterTax - bookingMoney)));

                lblTotalMoneyString.Text = "(" + TotalMoney_BookingHString + ")";
                #endregion
            }
            catch (Exception ex)
            {
                ex.ToString();
            }
        }
        public void Save(NewPaymentHEN aNewPaymentHEN)
        {
            try
            {
                DatabaseDA aDatabaseDA = new DatabaseDA();
                if (aNewPaymentHEN.IDBookingH != null)
                {

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

            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("AccountancyBO.Save :" + ex.Message.ToString()));
            }
        }
        public void PaymentHall(NewPaymentHEN aNewPaymentHEN)
        {
            DatabaseDA aDatabaseDA = new DatabaseDA();
            if (aDatabaseDA.BookingHs.Where(a => a.ID == aNewPaymentHEN.IDBookingH).ToList().Count > 0)
            {
                BookingHs aTemp = aDatabaseDA.BookingHs.Where(a => a.ID == aNewPaymentHEN.IDBookingH).ToList()[0];
                aTemp.CreatedDate = aNewPaymentHEN.CreatedDate_BookingH;
                aTemp.Status = 8;
                aTemp.BookingMoney = aNewPaymentHEN.BookingHMoney;
                aTemp.InvoiceDate = aNewPaymentHEN.InvoiceDate;
                aTemp.InvoiceNumber = aNewPaymentHEN.InvoiceNumber;
                aTemp.DatePay = DateTime.Now;
                aTemp.AcceptDate = aNewPaymentHEN.AcceptDate;

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

                    foreach (ServiceUsedEN item1 in item.aListServiceUsed)
                    {
                        item1.StatusPay = 8;
                    }
                    item.Status = 8;
                    this.SaveBookingHall(item);
                }
            }
        }