コード例 #1
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         Companies aCompany = new Companies();
         aCompany.ID = this.IDCompany_Old;
         aCompany.Name = txtName.Text;
         aCompany.TaxNumberCode = txtTaxNumberCode.Text;
         aCompany.Address = txtAddress.Text;
         aCompany.Status =Convert.ToInt32(cboStatus.Text);
         aCompany.Type = Convert.ToInt32(lueCustomerType.EditValue);
         aCompany.Disable =Convert.ToBoolean(cboDisable.Text);
         aCompanyBO.Update(aCompany);
         if (this.afrmLst_Companies_Old !=null)
         {
             this.afrmLst_Companies_Old.ReloadData();
         }
         MessageBox.Show("Sửa tổ chức thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
         this.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmUpd_Companies.btnUpdate_Click\n " + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
コード例 #2
0
 //=======================================================
 //Author: LinhTing
 //Function : Them Company
 //=======================================================
 public int Insert(Companies Companies)
 {
     try
        {
        aDatabaseDA.Companies.Add(Companies);
        aDatabaseDA.SaveChanges();
        return Companies.ID;
        }
        catch (Exception ex)
        {
        throw new Exception(string.Format("CompaniesBO.Insert :"+ ex.Message.ToString()));
        }
 }
コード例 #3
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateData() == true)
                {
                    string name = txtName.Text;
                    if (name.Length <= 255)
                    {
                        Companies aCompanies = new Companies();
                        aCompanies.Type = Convert.ToInt32(lueCompanyType.EditValue);
                        aCompanies.Name = name;
                        aCompanies.Status = cboStatus.SelectedIndex + 1;
                        aCompanies.Disable = bool.Parse(cboDisable.Text);
                        aCompaniesBO.Insert(aCompanies);
                        int IDCompany = aCompanies.ID;
                        if (afrmLst_Companies_Old != null)
                        {
                            afrmLst_Companies_Old.ReloadData();
                        }
                        else if (afrmIns_CustomerGroups_Customers_Old != null)
                        {
                            afrmIns_CustomerGroups_Customers_Old.Reload();
                        }
                        else if (afrmTsk_BookingHall_Goverment != null)
                        {
                            afrmTsk_BookingHall_Goverment.ReloadData();
                        }
                        else if (afrmTsk_BookingHall_Group != null)
                        {
                            afrmTsk_BookingHall_Group.ReloadData();
                        }
                        this.Close();
                        MessageBox.Show("Thêm mới thành công .!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }

                    else
                    {
                        txtName.Focus();
                        MessageBox.Show("Tên công ty chỉ được phép nhập tối đa 255 ký tự .", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_Companies.btnAddNew_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #4
0
        // Linhting - Tạo công ty tự động
        public int AutoInsertCompany(string NameCompany,int Type)
        {
            try
               {

               Companies Companies = new Companies();
               Companies.Name = NameCompany;
               Companies.Status = 1;
               Companies.Disable = false;
               Companies.Type = Type;
               this.Insert(Companies);
               return Companies.ID;
               }
               catch (Exception ex)
               {
               throw new Exception(string.Format("CompaniesBO.AutoInsertCompany :" + ex.Message.ToString()));
               }
        }
コード例 #5
0
        private void frmIns_CustomerGroups_Load(object sender, EventArgs e)
        {
            try
            {
                CompaniesBO aCompaniesBO = new CompaniesBO();
                List<Companies> aListCompanies = aCompaniesBO.Select_All();
                Companies aItem = new Companies();
                aItem.Name ="[Tất cả]";
                aItem.ID = 0;
                aListCompanies.Add(aItem);

                lueFilterCompany.Properties.DataSource = aListCompanies;
                lueFilterCompany.Properties.DisplayMember = "Name";
                lueFilterCompany.Properties.ValueMember = "ID";

                this.IsReadyInit = true;
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_CustomerGroups.frmIns_CustomerGroups_Load\n" + ex.Message, "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #6
0
 private void btnUpdate_Click(object sender, EventArgs e)
 {
     try
     {
         if (ValidateData() == true)
         {
             Companies aCompany = new Companies();
             aCompany.ID = IDCompany_Old;
             aCompany.Name = txtName.Text;
             aCompany.Status = int.Parse(cboStatus.Text);
             aCompany.Type = Convert.ToInt32(lueType.EditValue);
             aCompany.Disable = bool.Parse(cboDisable.Text);
             aCompanyBO.Update(aCompany);
             this.afrmLst_Companies_Old.ReloadData();
             MessageBox.Show("Sửa tổ chức thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmUpd_Companies.btnUpdate_Click\n " + ex.ToString(),"Lỗi",MessageBoxButtons.OK,MessageBoxIcon.Error);
     }
 }
        public void LoadData()
        {
            //Load dữ liệu công ty
            if (this.CustomerType == 1)
            {
                this.Text = "Đặt tiệc cho khách nhà nước";
                Companies aDefault = new Companies();
                List<Companies> aList = new List<Companies>();
                aDefault.Name = "[Tạo mới cty]";
                aDefault.ID = 0;

                aList = aCompaniesBO.Select_ByType(1);// [Company] Type = 1 : khách nhà nước
                aList.Add(aDefault);
                lueCompany.Properties.DataSource = aList;
                lueCompany.Properties.DisplayMember = "Name";
                lueCompany.Properties.ValueMember = "ID";

                if (this.IDCompany > 0)
                {
                    lueCompany.EditValue = this.IDCompany;
                }
                else
                {
                    lueCompany.EditValue = 0;
                }
            }
            if (this.CustomerType == 2)
            {
                this.Text = "Đặt tiệc cho khách đoàn";

                Companies aDefault = new Companies();
                List<Companies> aList = new List<Companies>();
                aDefault.Name = "[Tạo mới cty]";
                aDefault.ID = 0;

                aList = aCompaniesBO.Select_ByType(2);// [Company] Type = 2 : khách đoàn
                aList.Add(aDefault);
                lueCompany.Properties.DataSource = aList;
                lueCompany.Properties.DisplayMember = "Name";
                lueCompany.Properties.ValueMember = "ID";

                if (this.IDCompany > 0)
                {
                    lueCompany.EditValue = this.IDCompany;
                }
                else
                {
                    lueCompany.EditValue = 0;
                }
            }
            if (this.CustomerType == 3)
            {
                this.Text = "Đặt tiệc cho khách lẻ";

                Companies aDefault = new Companies();
                List<Companies> aList = new List<Companies>();
                aDefault.Name = "[Tạo mới cty]";
                aDefault.ID = 0;

                aList = aCompaniesBO.Select_ByType(3);// [Company] Type = 3 : khách lẻ
                aList.Add(aDefault);
                lueCompany.Properties.DataSource = aList;
                lueCompany.Properties.DisplayMember = "Name";
                lueCompany.Properties.ValueMember = "ID";
                if (this.IDCompany > 0)
                {
                    lueCompany.EditValue = this.IDCompany;
                }
                else
                {
                    lueCompany.EditValue = 0;
                }
            }
            //Load dữ liệu khách
            lueCustomer.Properties.DataSource = aCustomersBO.Select_All();
            lueCustomer.Properties.DisplayMember = "Name";
            lueCustomer.Properties.ValueMember = "ID";
            if (this.IDCustomer > 0)
            {
                lueCustomer.EditValue = this.IDCustomer;

            }
            else
            {
                lueCustomer.EditValue = 0;
            }

            // Load khách mời
            GuestsBO aGuestsBO = new GuestsBO();
            lueGuest.Properties.DataSource = aGuestsBO.Select_All();
            lueGuest.Properties.DisplayMember = "Name";
            lueGuest.Properties.ValueMember = "ID";
            LoadDataListFoods();
        }
コード例 #8
0
 private List<Companies> LoadListCompaniesByType()
 {
     try
     {
         CompaniesBO aCompaniesBO = new CompaniesBO();
         Companies aItem = new Companies();
         aItem.Name = "[Hiện tất cả]";
         aItem.ID = 0;
         List<Companies> aList = new List<Companies>();
         aList = aCompaniesBO.Select_All();
         aList.Add(aItem);
         return aList;
     }
     catch (Exception ex)
     {
         MessageBox.Show("frmTsk_BookingForRoom.LoadListCompaniesByType()\n" + ex.ToString(), "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
         return null;
     }
 }
コード例 #9
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            try
            {
                if (this.ValidateData() == true)
                {
                    string name = txtName.Text.Trim();
                    if (name.Length <= 255)
                    {
                        Companies aCompanies = new Companies();
                        aCompanies.Type = Convert.ToInt32(lueCustomerType.EditValue);
                        aCompanies.Name = name;
                        aCompanies.TaxNumberCode = txtTaxNumberCode.Text.Trim();
                        aCompanies.Address = txtAddress.Text.Trim();
                        aCompanies.Status = cboStatus.SelectedIndex + 1;
                        aCompanies.Disable = bool.Parse(cboDisable.Text);

                        aCompaniesBO.Insert(aCompanies);

                        int IDCompany = aCompanies.ID;

                        // Neu form AddNew_Company dc khoi dong tu form afrmAddNewBookingRs_Goverment thi reload lai afrmAddNewBookingRs_Goverment
                        if (this.afrmTsk_CheckIn_Goverment_Step2 != null)
                        {
                            this.afrmTsk_CheckIn_Goverment_Step2.LoadIDCompanies();
                            this.afrmTsk_CheckIn_Goverment_Step2.CallBackIDCompany(IDCompany);

                        }
                        else if (this.afrmTsk_CheckIn_Group_Step2 != null)
                        {
                            this.afrmTsk_CheckIn_Group_Step2.LoadIDCompanies();
                            this.afrmTsk_CheckIn_Group_Step2.CallBackIDCompany(IDCompany);
                        }
                        else if (this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2 != null)
                        {
                            this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2.LoadIDCompanies();
                            this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2.CallBackIDCompany(IDCompany);
                        }
                        else if (this.afrmTsk_CheckInGroup_ForRoomBooking_Step2 != null)
                        {
                            this.afrmTsk_CheckInGroup_ForRoomBooking_Step2.LoadIDCompanies();
                            this.afrmTsk_CheckInGroup_ForRoomBooking_Step2.CallBackIDCompany(IDCompany);
                        }
                        else if (afrmLst_Companies_Old != null)
                        {
                            afrmLst_Companies_Old.ReloadData();
                        }
                        else if (afrmTsk_Booking_Step2 != null)
                        {
                            this.afrmTsk_Booking_Step2.LoadIDCompanies(Type);
                            this.afrmTsk_Booking_Step2.CallBackIDCompany(IDCompany);
                        }
                        else if (afrmIns_CustomerGroups_Customers_Old != null)
                        {
                            this.afrmIns_CustomerGroups_Customers_Old.Reload();
                            this.afrmIns_CustomerGroups_Customers_Old.CallBackIDCompany(IDCompany);
                        }
                        else if (afrmTsk_BookingHall_Goverment != null)
                        {
                            afrmTsk_BookingHall_Goverment.ReloadData();
                        }
                        else if (afrmTsk_BookingHall_Group != null)
                        {
                            afrmTsk_BookingHall_Group.ReloadData();
                        }
                        this.Close();
                        MessageBox.Show("Thêm mới thành công .!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        txtName.Focus();
                        MessageBox.Show("Tên công ty chỉ được phép nhập tối đa 255 ký tự .", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("frmIns_Companies.btnAddNew_Click\n" + ex.ToString(), "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #10
0
        //Hiennv     26/11/2014     Viet lai phuong thuc checkInForRoomBooking
        public bool NewCheckInForRoomBooking(CheckInEN aCheckInEN)
        {
            try
            {
                CustomersBO aCustomersBO = new CustomersBO();
                List<Customers> aListCustomersTemp = aCustomersBO.Select_All();

                BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();
                List<BookingRooms> aListBookingRoomTemp = aBookingRoomsBO.Select_All();

                int IDBookingRooms = 0;
                int IDCompany = 0;
                int IDCustomerGroup = 0;
                int IDCustomer = 0;
                int Result = 0;

                string customerType = string.Empty;

                if (aCheckInEN.CustomerType == 0)
                {
                    customerType = "Tất cả loại khác";
                }
                else if (aCheckInEN.CustomerType == 1)
                {
                    customerType = "Khách nhà nước";
                }
                else if (aCheckInEN.CustomerType == 2)
                {
                    customerType = "Khách đoàn";
                }
                else if (aCheckInEN.CustomerType == 3)
                {
                    customerType = "Khách lẻ";
                }
                else if (aCheckInEN.CustomerType == 4)
                {
                    customerType = "Khách vãng lai";
                }
                else if (aCheckInEN.CustomerType == 5)
                {
                    customerType = "Khách bộ ngoại giao";
                }
                else
                {
                    customerType = string.Empty;
                }

                #region Them moi cong ty khi cong ty chua co
                if (aCheckInEN.IDCompany > 0)
                {
                    IDCompany = aCheckInEN.IDCompany;
                }
                else
                {
                    CompaniesBO aCompaniesBO = new CompaniesBO();
                    Companies aCompanies = new Companies();
                    if (aCheckInEN.NameCompany.Length > 250)
                    {
                        aCompanies.Name = aCheckInEN.NameCompany.Substring(0, 250);
                    }
                    else
                    {
                        aCompanies.Name = aCheckInEN.NameCompany;
                    }

                    aCompanies.TaxNumberCode = string.Empty;
                    aCompanies.Address = string.Empty;
                    aCompanies.Type = aCheckInEN.CustomerType;
                    aCompanies.Status = 1;
                    aCompanies.Disable = false;
                    IDCompany = aCompaniesBO.Insert(aCompanies);
                }
                #endregion

                #region Them moi nhom vao trong cong ty
                CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                CustomerGroups aCustomerGroups;
                aCustomerGroups = aCustomerGroupsBO.Select_ByIDCompanyAndIDCustomerGroup(IDCompany, aCheckInEN.IDCustomerGroup);

                if (aCustomerGroups == null)
                {

                    aCustomerGroups = new CustomerGroups();

                    string nameGroup = "[" + customerType + "][" + aCheckInEN.NameCompany + "][" + DateTime.Now.ToString() + "]";
                    aCustomerGroups.IDCompany = IDCompany;
                    if (nameGroup.Length > 250)
                    {
                        aCustomerGroups.Name = nameGroup.Substring(0, 250);
                    }
                    else
                    {
                        aCustomerGroups.Name = nameGroup;
                    }

                    aCustomerGroups.Type = 1;
                    aCustomerGroups.Status = 1;
                    aCustomerGroups.Disable = false;
                    IDCustomerGroup = aCustomerGroupsBO.Insert(aCustomerGroups);
                }
                else
                {
                    IDCustomerGroup = aCheckInEN.IDCustomerGroup;
                }
                #endregion

                string subject = "[" + customerType + "][" + aCheckInEN.NameCompany + "][" + DateTime.Now.ToString() + "]";

                BookingRsBO aBookingRsBO = new BookingRsBO();
                BookingRs aBookingRs = aBookingRsBO.Select_ByID(aCheckInEN.IDBookingR);
                if (aBookingRs != null)
                {
                    aBookingRs.CreatedDate = DateTime.Now;
                    aBookingRs.CustomerType = aCheckInEN.CustomerType;
                    aBookingRs.BookingType = aCheckInEN.BookingType;
                    if (subject.Length > 250)
                    {
                        aBookingRs.Subject = subject.Substring(0, 250);
                    }
                    else
                    {
                        aBookingRs.Subject = subject;
                    }

                    aBookingRs.IDCustomerGroup = IDCustomerGroup;
                    aBookingRs.IDCustomer = aCheckInEN.IDCustomer;
                    aBookingRs.IDSystemUser = aCheckInEN.IDSystemUser;
                    aBookingRs.PayMenthod = aCheckInEN.PayMenthod;
                    aBookingRs.StatusPay = aCheckInEN.StatusPay;
                    aBookingRs.BookingMoney = aCheckInEN.BookingMoney;
                    aBookingRs.ExchangeRate = aCheckInEN.ExchangeRate;
                    aBookingRs.Level = 0;// de mac dinh hien tai chua dung den
                    aBookingRs.Note = string.Empty;
                    aBookingRs.Description = string.Empty;
                    aBookingRs.DatePay = aCheckInEN.CheckOutPlan;
                    aBookingRs.DateEdit = aCheckInEN.CheckInActual;
                    aBookingRs.Status = aCheckInEN.Status;
                    aBookingRs.Type = aCheckInEN.Type;
                    aBookingRs.Disable = aCheckInEN.Disable;
                    aBookingRsBO.Update(aBookingRs);
                }

                //==========================================================
                BookingRooms aBookingRooms;
                BookingRoomsMembers aBookingRoomsMembers;

                for (int i = 0; i < aCheckInEN.aListRoomMembers.Count; i++)
                {

                    List<BookingRooms> aListBookingRoom = aListBookingRoomTemp.Where(r => r.ID == aCheckInEN.aListRoomMembers[i].IDBookingRooms).ToList();
                    if (aListBookingRoom.Count > 0)
                    {
                        aBookingRooms = new BookingRooms();
                        aBookingRooms = aListBookingRoom[0];
                        aBookingRooms.IDBookingR = aCheckInEN.IDBookingR;
                        aBookingRooms.CodeRoom = aCheckInEN.aListRoomMembers[i].RoomCode;
                        aBookingRooms.PercentTax = 10;
                        aBookingRooms.CostRef_Rooms = aCheckInEN.aListRoomMembers[i].RoomCostRef;
                        aBookingRooms.Cost = aCheckInEN.aListRoomMembers[i].RoomCostRef;
                        aBookingRooms.CheckInPlan = aCheckInEN.CheckInActual;
                        aBookingRooms.CheckInActual = aCheckInEN.CheckInActual;
                        aBookingRooms.CheckOutPlan = aCheckInEN.CheckOutPlan;
                        aBookingRooms.CheckOutActual = aCheckInEN.CheckOutActual;
                        aBookingRooms.StartTime = aCheckInEN.CheckInActual;
                        aBookingRooms.EndTime = aCheckInEN.CheckOutPlan;
                        aBookingRooms.BookingStatus = 1;
                        aBookingRooms.Type = 3; //Tính CheckIn sớm và CheckOut muộn
                        aBookingRooms.Status = aCheckInEN.Status;
                        aBookingRooms.PriceType = "G1";
                        aBookingRoomsBO.Update(aBookingRooms);

                        IDBookingRooms = aCheckInEN.aListRoomMembers[i].IDBookingRooms;
                    }
                    else
                    {
                        aBookingRooms = new BookingRooms();
                        aBookingRooms.IDBookingR = aCheckInEN.IDBookingR;
                        aBookingRooms.CodeRoom = aCheckInEN.aListRoomMembers[i].RoomCode;
                        aBookingRooms.PercentTax = 10;
                        aBookingRooms.CostRef_Rooms = aCheckInEN.aListRoomMembers[i].RoomCostRef;
                        aBookingRooms.Cost = aCheckInEN.aListRoomMembers[i].RoomCostRef;
                        aBookingRooms.CheckInPlan = aCheckInEN.CheckInActual;
                        aBookingRooms.CheckInActual = aCheckInEN.CheckInActual;
                        aBookingRooms.CheckOutPlan = aCheckInEN.CheckOutPlan;
                        aBookingRooms.CheckOutActual = aCheckInEN.CheckOutActual;
                        aBookingRooms.StartTime = aCheckInEN.CheckInActual;
                        aBookingRooms.EndTime = aCheckInEN.CheckOutPlan;
                        aBookingRooms.BookingStatus = 1;
                        aBookingRooms.Type = 3; //Tính CheckIn sớm và CheckOut muộn
                        aBookingRooms.Status = aCheckInEN.Status;
                        aBookingRooms.PriceType = "G1";
                        //add new bookingRoom
                        IDBookingRooms = aBookingRoomsBO.Insert(aBookingRooms);
                    }

                    //-----------------------------------------------------------
                    aBookingRoomsMembers = new BookingRoomsMembers();
                    aBookingRoomsMembers.IDBookingRoom = IDBookingRooms;

                    BookingRoomsMembersBO aBookingRoomsMembersBO = new BookingRoomsMembersBO();
                    for (int ii = 0; ii < aCheckInEN.aListRoomMembers[i].ListCustomer.Count; ii++)
                    {
                        Customers aCustomers;
                        List<Customers> aListCustomers = aListCustomersTemp.Where(c => c.ID == aCheckInEN.aListRoomMembers[i].ListCustomer[ii].ID).ToList();
                        if (aListCustomers.Count > 0)
                        {
                            IDCustomer = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].ID;
                            aCustomers = aListCustomers[0];
                            aCustomers.Name = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Name;
                            aCustomers.Identifier1 = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Identifier1;
                            aCustomers.Birthday = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Birthday;
                            aCustomers.Gender = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Gender;
                            aCustomers.Tel = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Tel;
                            aCustomers.Nationality = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Nationality;
                            aCustomersBO.Update(aCustomers);
                        }
                        else
                        {
                            aCustomers = new Customers();
                            aCustomers.Name = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Name;
                            aCustomers.Identifier1 = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Identifier1;
                            aCustomers.Birthday = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Birthday;
                            aCustomers.Gender = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Gender;
                            aCustomers.Tel = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Tel;
                            aCustomers.Nationality = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Nationality;

                            //Them moi khach hang
                            IDCustomer = aCustomersBO.Insert(aCustomers);
                        }
                        aBookingRoomsMembers.IDCustomer = IDCustomer;
                        aBookingRoomsMembers.PurposeComeVietnam = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].PurposeComeVietnam;
                        aBookingRoomsMembers.DateEnterCountry = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].DateEnterCountry;
                        aBookingRoomsMembers.EnterGate = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].EnterGate;
                        aBookingRoomsMembers.TemporaryResidenceDate = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].TemporaryResidenceDate;
                        aBookingRoomsMembers.LimitDateEnterCountry = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].LimitDateEnterCountry;
                        aBookingRoomsMembers.Organization = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Organization;
                        aBookingRoomsMembers.LeaveDate = aCheckInEN.aListRoomMembers[i].ListCustomer[ii].LeaveDate;

                        //add new bookingRoomMember
                        aBookingRoomsMembersBO.Insert(aBookingRoomsMembers);

                        #region  them nguoi vao trong customergroup_customer

                        string nameCustomerGroup_customer = "[" + customerType + "][" + aCheckInEN.aListRoomMembers[i].ListCustomer[ii].Name + "]";

                        CustomerGroups_CustomersBO aCustomerGroups_CustomersBO = new CustomerGroups_CustomersBO();
                        CustomerGroups_Customers aCustomerGroups_Customers = new CustomerGroups_Customers();
                        if (nameCustomerGroup_customer.Length > 150)
                        {
                            aCustomerGroups_Customers.Name = nameCustomerGroup_customer.Substring(0, 150);
                        }
                        else
                        {
                            aCustomerGroups_Customers.Name = nameCustomerGroup_customer;
                        }

                        aCustomerGroups_Customers.Type = 1;
                        aCustomerGroups_Customers.Status = 1;
                        aCustomerGroups_Customers.Disable = false;
                        aCustomerGroups_Customers.FromDate = DateTime.Now;
                        aCustomerGroups_Customers.ToDate = DateTime.Now;
                        aCustomerGroups_Customers.IDCustomer = IDCustomer;
                        aCustomerGroups_Customers.IDCustomerGroup = IDCustomerGroup;
                        aCustomerGroups_CustomersBO.Insert(aCustomerGroups_Customers);
                        #endregion

                        // dung de cap nhap lai nguoi dai dien khi dat phong
                        if (aCheckInEN.aListRoomMembers[i].ListCustomer[ii].PepoleRepresentative == true)
                        {
                            aBookingRsBO = new BookingRsBO();
                            aBookingRs = new BookingRs();
                            aBookingRs = aBookingRsBO.Select_ByID(aCheckInEN.IDBookingR);
                            if (aBookingRs != null)
                            {
                                aBookingRs.IDCustomer = IDCustomer;
                                Result = aBookingRsBO.Update(aBookingRs);
                            }

                        }
                        else
                        {
                            if (ii == (aCheckInEN.aListRoomMembers[i].ListCustomer.Count - 1))
                            {
                                if (Result == 0)
                                {
                                    aBookingRsBO = new BookingRsBO();
                                    aBookingRs = new BookingRs();
                                    aBookingRs = aBookingRsBO.Select_ByID(aCheckInEN.IDBookingR);
                                    if (aBookingRs != null)
                                    {
                                        aBookingRs.IDCustomer = IDCustomer;
                                        aBookingRsBO.Update(aBookingRs);
                                    }
                                }
                            }
                        }

                    }
                }
                return true;

            }
            catch (Exception ex)
            {
                return false;
            }
        }
コード例 #11
0
        //Hiennv     25/11/2014     Viet lai phuong thuc BookingRoom
        public bool NewBookingRoom(NewBookingEN aNewBookingEN)
        {
            try
            {
                int IDBookingR = 0;
                int IDCompany = 0;
                int IDCustomerGroup = 0;
                int IDCustomer = 0;

                string customerType = string.Empty;
                if (aNewBookingEN.CustomerType == 0)
                {
                    customerType = "Tất cả loại khác";
                }
                else if (aNewBookingEN.CustomerType == 1)
                {
                    customerType = "Khách nhà nước";
                }
                else if (aNewBookingEN.CustomerType == 2)
                {
                    customerType = "Khách đoàn";
                }
                else if (aNewBookingEN.CustomerType == 3)
                {
                    customerType = "Khách lẻ";
                }
                else if (aNewBookingEN.CustomerType == 4)
                {
                    customerType = "Khách vãng lai";
                }
                else if (aNewBookingEN.CustomerType == 5)
                {
                    customerType = "Khách bộ ngoại giao";
                }
                else
                {
                    customerType = string.Empty;
                }

                #region Them moi khach hang khi khach hang chua co
                if (aNewBookingEN.IDCustomer > 0)
                {
                    IDCustomer = aNewBookingEN.IDCustomer;
                }
                else
                {
                    CustomersBO aCustomersBO = new CustomersBO();
                    Customers aCustomers = new Customers();
                    if (aNewBookingEN.NameCustomer.Length > 50)
                    {
                        aCustomers.Name = aNewBookingEN.NameCustomer.Substring(0, 50);
                    }
                    else
                    {
                        aCustomers.Name = aNewBookingEN.NameCustomer;
                    }
                    IDCustomer = aCustomersBO.Insert(aCustomers);
                }
                #endregion

                #region Them moi cong ty khi cong ty chua co
                if (aNewBookingEN.IDCompany > 0)
                {
                    IDCompany = aNewBookingEN.IDCompany;
                }
                else
                {
                    CompaniesBO aCompaniesBO = new CompaniesBO();
                    Companies aCompanies = new Companies();
                    if (aNewBookingEN.NameCompany.Length > 250)
                    {
                        aCompanies.Name = aNewBookingEN.NameCompany.Substring(0, 250);
                    }
                    else
                    {
                        aCompanies.Name = aNewBookingEN.NameCompany;
                    }

                    aCompanies.TaxNumberCode = string.Empty;
                    aCompanies.Address = string.Empty;
                    aCompanies.Type = aNewBookingEN.CustomerType;
                    aCompanies.Status = 1;
                    aCompanies.Disable = false;
                    IDCompany = aCompaniesBO.Insert(aCompanies);
                }
                #endregion

                #region Them moi nhom vao trong cong ty
                if (IDCompany > 0)
                {
                    CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO();
                    CustomerGroups aCustomerGroups = new CustomerGroups();
                    string nameGroup;
                    if (string.IsNullOrEmpty(aNewBookingEN.Subject))
                    {
                        nameGroup = "[" + customerType + "][" + aNewBookingEN.NameCompany + "][" + DateTime.Now.ToString() + "]";
                    }
                    else
                    {
                        nameGroup = aNewBookingEN.Subject;
                    }
                    aCustomerGroups.IDCompany = IDCompany;
                    if (nameGroup.Length > 250)
                    {
                        aCustomerGroups.Name = nameGroup.Substring(0, 250);
                    }
                    else
                    {
                        aCustomerGroups.Name = nameGroup;
                    }

                    aCustomerGroups.Type = 1;
                    aCustomerGroups.Status = 1;
                    aCustomerGroups.Disable = false;
                    IDCustomerGroup = aCustomerGroupsBO.Insert(aCustomerGroups);
                }
                #endregion

                #region Them moi bookingRs
                if (IDCustomer > 0 && IDCustomerGroup > 0)
                {
                    string subject = "[" + customerType + "][" + aNewBookingEN.NameCompany + "][" + DateTime.Now.ToString() + "]";

                    BookingRs aBookingRs = new BookingRs();

                    aBookingRs.CreatedDate = DateTime.Now;
                    aBookingRs.CustomerType = aNewBookingEN.CustomerType;
                    aBookingRs.BookingType = aNewBookingEN.BookingType;
                    if (subject.Length > 250)
                    {
                        aBookingRs.Subject = subject.Substring(0, 250);
                    }
                    else
                    {
                        aBookingRs.Subject = subject;
                    }
                    aBookingRs.IDCustomerGroup = IDCustomerGroup;
                    aBookingRs.IDCustomer = IDCustomer;
                    aBookingRs.IDSystemUser = aNewBookingEN.IDSystemUser;
                    aBookingRs.PayMenthod = aNewBookingEN.PayMenthod;
                    aBookingRs.StatusPay = aNewBookingEN.StatusPay;
                    aBookingRs.BookingMoney = aNewBookingEN.BookingMoney;
                    aBookingRs.ExchangeRate = aNewBookingEN.ExchangeRate;
                    aBookingRs.Level = 0;// de mac dinh hien tai chua dung den
                    aBookingRs.Note = string.Empty;
                    aBookingRs.Description = string.Empty;
                    aBookingRs.DatePay = aNewBookingEN.CheckOutPlan;
                    aBookingRs.DateEdit = aNewBookingEN.CheckInActual;
                    aBookingRs.Status = aNewBookingEN.Status;
                    aBookingRs.Type = aNewBookingEN.Type;
                    aBookingRs.Disable = aNewBookingEN.Disable;

                    //add new bookingRs
                    BookingRsBO aBookingRsBO = new BookingRsBO();
                    IDBookingR = aBookingRsBO.Insert(aBookingRs);
                }
                #endregion

                #region them moi bookingRoom
                if (IDBookingR > 0)
                {
                    BookingRoomsBO aBookingRoomsBO = new BookingRoomsBO();
                    BookingRooms aBookingRooms;
                    for (int i = 0; i < aNewBookingEN.aListNewRoomMembers.Count; i++)
                    {
                        aBookingRooms = new BookingRooms();
                        aBookingRooms.IDBookingR = IDBookingR;
                        aBookingRooms.CodeRoom = aNewBookingEN.aListNewRoomMembers[i].RoomCode;
                        aBookingRooms.PercentTax = 10;
                        aBookingRooms.CostRef_Rooms = aNewBookingEN.aListNewRoomMembers[i].RoomCostRef;
                        aBookingRooms.Cost = aNewBookingEN.aListNewRoomMembers[i].RoomCostRef;
                        aBookingRooms.CheckInPlan = aNewBookingEN.CheckInActual;
                        aBookingRooms.CheckInActual = aNewBookingEN.CheckInActual;
                        aBookingRooms.CheckOutPlan = aNewBookingEN.CheckOutPlan;
                        aBookingRooms.CheckOutActual = aNewBookingEN.CheckOutActual;
                        aBookingRooms.StartTime = aNewBookingEN.CheckInActual;
                        aBookingRooms.EndTime = aNewBookingEN.CheckOutPlan;
                        aBookingRooms.BookingStatus = 1;
                        aBookingRooms.Type = 3; //Tính CheckIn sớm và CheckOut muộn
                        aBookingRooms.Status = aNewBookingEN.Status;
                        aBookingRooms.PriceType = "G1";
                        //add new bookingRoom
                        aBookingRoomsBO.Insert(aBookingRooms);

                    }
                }
                #endregion

                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
コード例 #12
0
 //=======================================================
 //Author: LinhTing
 //Function : Updata Company
 //=======================================================
 public int Update(Companies Companies)
 {
     try
        {
        aDatabaseDA.Companies.AddOrUpdate(Companies);
        return aDatabaseDA.SaveChanges();
        }
        catch (Exception ex)
        {
        throw new Exception(string.Format("CompaniesBO.Update :"+ ex.Message.ToString()));
        }
 }