public void SetValue(BookingHalls aTemp)
 {
     this.ID = aTemp.ID;
     this.CodeHall = aTemp.CodeHall;
     this.Cost = aTemp.Cost;
     this.PercentTax = aTemp.PercentTax;
     this.CostRef_Halls = aTemp.CostRef_Halls;
     this.Date = aTemp.Date;
     this.LunarDate = aTemp.LunarDate;
     this.BookingStatus = aTemp.BookingStatus;
     this.Unit = aTemp.Unit;
     this.TableOrPerson = aTemp.TableOrPerson;
     this.Note = aTemp.Note;
     this.Status = aTemp.Status;
     this.Location = aTemp.Location;
     this.StartTime = aTemp.StartTime;
     this.EndTime = aTemp.EndTime;
     this.IsAllDayEvent = aTemp.IsAllDayEvent;
     this.Color = aTemp.Color;
     this.IsRecurring = aTemp.IsRecurring;
     this.IsEditable = aTemp.IsEditable;
     this.AdditionalColumn1 = aTemp.AdditionalColumn1;
     this.IDBookingH = aTemp.IDBookingH;
     this.IndexSubPayment = aTemp.IndexSubPayment;
     this.AcceptDate = aTemp.AcceptDate;
     this.InvoiceDate = aTemp.InvoiceDate;
     this.InvoiceNumber = aTemp.InvoiceNumber;
     //this.TotalMoney = this.GetTotalMoneyHall();
     //this.MoneyHallBeforeTax = this.GetOnlyMoneyHallBeforeTax();
     //this.MoneyHall = this.GetOnlyMoneyHall();
 }
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData() == true)
                {
                    ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                    //Add du lieu cho BookingH
                    BookingHs aBookingHs = new BookingHs();
                    aBookingHs.ID = IDBookingH;
                    aBookingHs.Subject = txtSubject.Text;
                    aBookingHs.CreatedDate = this.aBookingHs.CreatedDate;
                    aBookingHs.CustomerType = this.aBookingHs.CustomerType;
                    aBookingHs.BookingType = Convert.ToInt16(lueBookingType.EditValue);
                    aBookingHs.Note = txtNote.Text;
                    aBookingHs.IDGuest = Convert.ToInt16(lueGuest.EditValue);
                    if (txtBookingMoney.Text == "")
                    {
                        aBookingHs.BookingMoney = 0;
                        lueStatusPay.EditValue = CORE.CONSTANTS.SelectedStatusPay(1).ID;
                    }
                    else
                    {
                        aBookingHs.BookingMoney = Convert.ToDecimal(txtBookingMoney.Text);
                        lueStatusPay.EditValue = CORE.CONSTANTS.SelectedStatusPay(2).ID;
                    }
                    aBookingHs.StatusPay = Convert.ToInt16(lueStatusPay.EditValue);
                    aBookingHs.Status = Convert.ToInt16(lueBookingStatus.EditValue);

                    aBookingHs.PayMenthod = 1;
                    if (cbbType.Text == "Tiệc không thuộc phạm trù nhà bếp")
                    {
                        aBookingHs.Type = 1;
                    }
                    else
                    {
                        aBookingHs.Type = 2;
                    }
                    aBookingHs.Disable = false;
                    aBookingHs.Level = Convert.ToInt16(lueLevel.EditValue);
                    aBookingHs.Description = "";
                    aBookingHs.IDCustomer = Convert.ToInt16(lueCustomer.EditValue);
                    aBookingHs.IDCustomerGroup = Convert.ToInt16(lueCustomerGroup.EditValue);
                    aBookingHs.IDSystemUser = 1;// Để tạm

                    //Add du lieu cho BookingHall
                    List<BookingHalls> aListBookingHall = new List<BookingHalls>();
                    BookingHalls aTemp;
                    for (int i = 0; i < aListSelected.Count; i++)
                    {
                        aTemp = new BookingHalls();
                        aTemp.CodeHall = aListSelected[i].Code;
                        aTemp.Cost = aListSelected[i].Cost;
                        aTemp.PercentTax = 10;
                        aTemp.CostRef_Halls = aListSelected[i].CostRef;
                        aTemp.Date = dtpFrom.DateTime;
                        IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-GB", true);
                        //DateTime Lunardate = DateTime.ParseExact(LunarDateExt.ToLunarDate(dtpFrom.DateTime, 7).ToString(), "dd/MM/yyyy", theCultureInfo);
                        //aTemp.LunarDate = Lunardate;
                        aTemp.BookingStatus = null;
                        aTemp.Unit = aListSelected[i].Unit;
                        aTemp.TableOrPerson = aListSelected[i].TableOrPerson;
                        aTemp.Note = "";
                        aTemp.Status = Convert.ToInt16(lueBookingStatus.EditValue);
                        aTemp.StartTime = !string.IsNullOrEmpty(tedStart.Time.ToString()) ? tedStart.Time.TimeOfDay : TimeSpan.Zero;
                        aTemp.EndTime = !string.IsNullOrEmpty(tedEnd.Time.ToString()) ? tedEnd.Time.TimeOfDay : TimeSpan.Zero;

                        aListBookingHall.Add(aTemp);
                    }
                    aReceptionTaskBO.UpdateCheckIn(aBookingHs, aListBookingHall);
                    if (afrmTsk_ManageBookingHs != null)
                    {
                        afrmTsk_ManageBookingHs.ReloadData();
                    }
                    else if (afrmMain_Halls != null)
                    {
                        afrmMain_Halls.ReloadData();
                    }
                    MessageBox.Show("Đặt hội trường thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_UpdBooking.CheckIn\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 //Author: Linhting
 public void InsertUnSync(BookingHalls bookingHalls)
 {
     try
     {
         aDatabaseDA.BookingHalls.Add(bookingHalls);
         aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("BookingHallsBO.InsertUnSync:" + ex.ToString());
     }
 }
 //Author: Linhting
 public int Insert(BookingHalls bookingHalls)
 {
     try
     {
         BookingHsBO aBookingHsBO = new BookingHsBO();
         aDatabaseDA.BookingHalls.Add(bookingHalls);
         aBookingHsBO.AutoChangeStatusBookingH(bookingHalls.IDBookingH);
         return aDatabaseDA.SaveChanges();
     }
     catch (Exception ex)
     {
         throw new Exception("BookingHallsBO.Insert:" + ex.ToString());
     }
 }
        private void btnCheckIn_Click(object sender, System.EventArgs e)
        {
            try
            {
                if (ValidateData() == true)
                {
                    ReceptionTaskBO aReceptionTaskBO = new ReceptionTaskBO();
                    //Add du lieu cho BookingH
                    BookingHs aBookingHs = new BookingHs();
                    aBookingHs.Subject = txtSubject.Text;
                    aBookingHs.CreatedDate = DateTime.Now;
                    aBookingHs.CustomerType = 2;
                    aBookingHs.BookingType = Convert.ToInt32(lueBookingType.EditValue);
                    aBookingHs.Note = txtNote.Text;
                    aBookingHs.IDGuest = Convert.ToInt32(lueGuest.EditValue);
                    if (txtBookingMoney.Text == "")
                    {
                        aBookingHs.BookingMoney = 0;
                        lueStatusPay.EditValue = CORE.CONSTANTS.SelectedStatusPay(1).ID;
                    }
                    else
                    {
                        aBookingHs.BookingMoney = Convert.ToDecimal(txtBookingMoney.Text);
                        lueStatusPay.EditValue = CORE.CONSTANTS.SelectedStatusPay(2).ID;
                    }
                    aBookingHs.StatusPay = Convert.ToInt32(lueStatusPay.EditValue);
                    aBookingHs.Status = Convert.ToInt32(lueBookingStatus.EditValue);
                    aBookingHs.PayMenthod = 1;
                    if (cbbType.Text == "Tiệc không thuộc phạm trù nhà bếp")
                    {
                        aBookingHs.Type = 1;
                    }
                    else
                    {
                        aBookingHs.Type = 2;
                    }
                    aBookingHs.Disable = false;
                    aBookingHs.Description = "";
                    aBookingHs.IDCustomer = Convert.ToInt32(lueCustomer.EditValue);
                    aBookingHs.IDCustomerGroup = Convert.ToInt32(lueCustomerGroup.EditValue);
                    aBookingHs.IDSystemUser = CORE.CURRENTUSER.SystemUser.ID;

                    //Add du lieu cho BookingHall
                    List<BookingHalls> aListBookingHall = new List<BookingHalls>();
                    BookingHalls aTemp;
                    for (int i = 0; i < aListSelected.Count; i++)
                    {
                        aTemp = new BookingHalls();
                        aTemp.CodeHall = aListSelected[i].Code;
                        aTemp.Cost = aListSelected[i].Cost;
                        aTemp.PercentTax = 10;
                        aTemp.CostRef_Halls = aListSelected[i].CostRef;
                        aTemp.Date = DateTime.Now;
                        IFormatProvider theCultureInfo = new System.Globalization.CultureInfo("en-GB", true);
                        DateTime Lunardate = DateTime.ParseExact(Convert.ToString(LunarDateExt.ToLunarDate(DateTime.Now, 7)), "d/M/yyyy", theCultureInfo);
                        aTemp.LunarDate = Lunardate;
                        aTemp.BookingStatus = null;
                        aTemp.Unit = aListSelected[i].Unit;
                        aTemp.TableOrPerson = aListSelected[i].TableOrPerson;
                        aTemp.Note = "";
                        aTemp.Status = Convert.ToInt32(lueBookingStatus.EditValue);
                        aTemp.StartTime = !string.IsNullOrEmpty(tedStart.Time.ToString()) ? tedStart.Time.TimeOfDay : TimeSpan.Zero;
                        aTemp.EndTime = !string.IsNullOrEmpty(tedEnd.Time.ToString()) ? tedEnd.Time.TimeOfDay : TimeSpan.Zero;

                        aListBookingHall.Add(aTemp);
                    }
                    this.IDBookingH = aReceptionTaskBO.CheckIn(aBookingHs, aListBookingHall);

                    //Hiennv
                    if (this.IDBookingR > 0)
                    {
                        BookingRs_BookingHsBO aBookingRs_BookingHsBO = new BookingRs_BookingHsBO();

                        BookingRs_BookingHs aBookingRs_BookingHs = new BookingRs_BookingHs();
                        aBookingRs_BookingHs.IDBookingR = this.IDBookingR;
                        aBookingRs_BookingHs.IDBookingH = this.IDBookingH;
                        aBookingRs_BookingHs.Type = String.Empty;
                        aBookingRs_BookingHs.Status = String.Empty;
                        aBookingRs_BookingHs.Disable = false;
                        aBookingRs_BookingHs.Extension1 = String.Empty;
                        aBookingRs_BookingHs.Extension2 = String.Empty;
                        aBookingRs_BookingHs.Extension3 = String.Empty;

                        aBookingRs_BookingHsBO.Insert(aBookingRs_BookingHs);

                    }

                    MessageBox.Show("Đặt hội trường thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    DialogResult result = MessageBox.Show("Bạn có thêm dịch vụ cho hội trường " + aBookingHs.Subject + " này không?", "Thêm dịch vụ hội trường", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.Yes)
                    {
                        //frmTsk_Payment_Step2 afrmTsk_Payment_Step2 = new frmTsk_Payment_Step2(Convert.ToInt32(this.IDBookingR), Convert.ToInt32(this.IDBookingH));
                        //afrmTsk_Payment_Step2.ShowDialog();
                    }
                    if (afrmMain_Halls != null)
                    {
                        this.afrmMain_Halls.ReloadData();
                    }
                    this.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmTsk_BookingHall_Group.CheckIn\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        //Author: Linhting
        public int CheckIn(BookingHs BookingHs, List<BookingHalls> ListBookingHalls)
        {
            try
            {
                BookingHs aBookingHs = new BookingHs();

                aBookingHs.CreatedDate = BookingHs.CreatedDate;
                aBookingHs.CustomerType = BookingHs.CustomerType;
                aBookingHs.BookingType = BookingHs.BookingType;
                aBookingHs.Note = BookingHs.Note;
                aBookingHs.IDGuest = BookingHs.IDGuest;
                aBookingHs.StatusPay = BookingHs.StatusPay;
                aBookingHs.BookingMoney = BookingHs.BookingMoney;
                aBookingHs.Status = BookingHs.Status;
                aBookingHs.Type = BookingHs.Type;
                aBookingHs.Disable = BookingHs.Disable;
                aBookingHs.Level = BookingHs.Level;
                aBookingHs.Subject = BookingHs.Subject;
                aBookingHs.IDCustomerGroup = BookingHs.IDCustomerGroup;
                aBookingHs.IDCustomer = BookingHs.IDCustomer;
                aBookingHs.IDSystemUser = BookingHs.IDSystemUser;
                aBookingHs.Description = BookingHs.Description;

                //add new bookingRs
                BookingHsBO aBookingHsBO = new BookingHsBO();
                int IDBookingH = aBookingHsBO.InsertUnSync(aBookingHs);

                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHalls aBookingHall;
                for (int i = 0; i < ListBookingHalls.Count; i++)
                {
                    aBookingHall = new BookingHalls();
                    aBookingHall.IDBookingH = IDBookingH;
                    aBookingHall.CodeHall = ListBookingHalls[i].CodeHall;
                    aBookingHall.Cost = ListBookingHalls[i].Cost;
                    aBookingHall.PercentTax = ListBookingHalls[i].PercentTax;
                    aBookingHall.CostRef_Halls = ListBookingHalls[i].CostRef_Halls;
                    aBookingHall.Date = ListBookingHalls[i].Date;
                    aBookingHall.LunarDate = ListBookingHalls[i].LunarDate;
                    aBookingHall.BookingStatus = ListBookingHalls[i].BookingStatus;
                    aBookingHall.Unit = ListBookingHalls[i].Unit;
                    aBookingHall.TableOrPerson = ListBookingHalls[i].TableOrPerson;
                    aBookingHall.Note = ListBookingHalls[i].Note;
                    aBookingHall.Status = ListBookingHalls[i].Status;
                    aBookingHall.StartTime = ListBookingHalls[i].StartTime;
                    aBookingHall.EndTime = ListBookingHalls[i].EndTime;
                    aBookingHall.Location = ListBookingHalls[i].Location;
                    aBookingHall.Color = ListBookingHalls[i].Color;

                    aBookingHallsBO.InsertUnSync(aBookingHall);
                }

                return IDBookingH;

            }
            catch (Exception ex)
            {

                throw new Exception("ReceptionTaskBO.CheckIn\n" + ex.ToString());
            }
        }
        //Linhting - Book hội trường mới
        public int NewBookHall(NewBookingHEN aNewBookingHEN)
        {
            try
            {
                BookingHalls_ServicesBO aBookingHalls_ServicesBO = new BookingHalls_ServicesBO();

                //Tạo BookingH mới
                BookingHs aBookingHs = new BookingHs();

                aBookingHs.CreatedDate = aNewBookingHEN.CreatedDate;
                aBookingHs.CustomerType = aNewBookingHEN.CustomerType;
                aBookingHs.BookingType = aNewBookingHEN.BookingType;
                aBookingHs.Note = aNewBookingHEN.Note;
                aBookingHs.IDGuest = 0;
                aBookingHs.StatusPay = aNewBookingHEN.StatusPay;
                aBookingHs.BookingMoney = aNewBookingHEN.BookingMoney;
                aBookingHs.Status = aNewBookingHEN.Status;
                aBookingHs.Type = aNewBookingHEN.Type;
                aBookingHs.Disable = aNewBookingHEN.Disable;
                aBookingHs.Level = aNewBookingHEN.Level;
                aBookingHs.Subject = aNewBookingHEN.Subject;
                aBookingHs.IDCustomerGroup = aNewBookingHEN.IDCustomerGroup;
                aBookingHs.IDCustomer = aNewBookingHEN.IDCustomer;
                aBookingHs.IDSystemUser = aNewBookingHEN.IDSystemUser;
                aBookingHs.Description = aNewBookingHEN.Description;

                //Tạo BookingHall mới
                BookingHsBO aBookingHsBO = new BookingHsBO();
                int IDBookingH = aBookingHsBO.InsertUnSync(aBookingHs);

                BookingHallsBO aBookingHallsBO = new BookingHallsBO();
                BookingHalls aBookingHall;
                for (int i = 0; i < aNewBookingHEN.aListBookingHallUsed.Count; i++)
                {
                    aBookingHall = new BookingHalls();
                    aBookingHall.IDBookingH = IDBookingH;
                    aBookingHall.CodeHall = aNewBookingHEN.aListBookingHallUsed[i].CodeHall;
                    aBookingHall.Cost = aNewBookingHEN.aListBookingHallUsed[i].Cost;
                    aBookingHall.PercentTax = 10; //Để tạm thuế = 10%
                    aBookingHall.CostRef_Halls = aNewBookingHEN.aListBookingHallUsed[i].CostRef_Halls;
                    aBookingHall.Date = aNewBookingHEN.aListBookingHallUsed[i].Date;
                    aBookingHall.LunarDate = aNewBookingHEN.aListBookingHallUsed[i].LunarDate;
                    aBookingHall.BookingStatus = aNewBookingHEN.aListBookingHallUsed[i].BookingStatus;
                    aBookingHall.Unit = aNewBookingHEN.aListBookingHallUsed[i].Unit;
                    aBookingHall.TableOrPerson = aNewBookingHEN.aListBookingHallUsed[i].TableOrPerson;
                    aBookingHall.Note = aNewBookingHEN.aListBookingHallUsed[i].Note;
                    aBookingHall.Status = aNewBookingHEN.aListBookingHallUsed[i].Status;
                    aBookingHall.StartTime = aNewBookingHEN.aListBookingHallUsed[i].StartTime;
                    aBookingHall.EndTime = aNewBookingHEN.aListBookingHallUsed[i].EndTime;
                    aBookingHall.Location = aNewBookingHEN.aListBookingHallUsed[i].Location;
                    aBookingHall.Color = aNewBookingHEN.aListBookingHallUsed[i].Color;

                    aBookingHallsBO.InsertUnSync(aBookingHall);
                    int IDBookingHall = aBookingHall.ID;
                    // Thêm dịch vụ đã chọn vào hội trường
                    foreach (ServiceUsedEN aTemp in aNewBookingHEN.aListBookingHallUsed[i].aListServiceUsed)
                    {
                        BookingHalls_Services aBookingHalls_Services = new BookingHalls_Services();
                        aBookingHalls_Services.Info = "";
                        aBookingHalls_Services.Type = 1;
                        aBookingHalls_Services.Status = 1;
                        aBookingHalls_Services.Disable = false;
                        aBookingHalls_Services.IDBookingHall = aBookingHall.ID;
                        aBookingHalls_Services.IDService = aTemp.IDService;
                        aBookingHalls_Services.Cost = aTemp.Cost;
                        aBookingHalls_Services.Date = aTemp.DateUsed;
                        aBookingHalls_Services.CostRef_Services = aTemp.CostRef_Service;
                        aBookingHalls_Services.PercentTax = 10;// de mac dinh
                        aBookingHalls_Services.Quantity = aTemp.Quantity;
                        aBookingHalls_ServicesBO.Insert(aBookingHalls_Services);

                    }
                    // Thêm thực đơn vào hội trường
                    foreach (MenusEN aMenuEN in aNewBookingHEN.aListBookingHallUsed[i].aListMenuEN)
                    {
                        aMenuEN.IDBookingHall = IDBookingHall;
                        aMenuEN.Type = 1; // type =1 ; thuc don mau ; Type 2: thuc don moi
                        aMenuEN.Status = 1; // de tam
                        aMenuEN.Disable = false; // de tam
                        aMenuEN.IDSystemUser = 1;//Khi kinh doanh thêm thực đơn mặc định trạng thái là 0 - đã xác nhận thực đơn
                        this.CreateMenus(aMenuEN);
                    }

                }

                return IDBookingH;

            }
            catch (Exception ex)
            {

                throw new Exception("ReceptionTaskBO.NewBookHall\n" + ex.ToString());
            }
        }