// Ngoc public int InsertCustomerIntoCustomerGroup_ByIDBookingRs(int IDCustomer, int IDBookingRs) { // Add customer vao group CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO(); CustomerGroups aCustomerGroups = new CustomerGroups(); aCustomerGroups = aCustomerGroupsBO.Select_ByIDBookingR(IDBookingRs); CustomerGroups_CustomersBO aCustomerGroups_CustomersBO = new CustomerGroups_CustomersBO(); //Kiem tra xe khach do da co trong custome group chua CustomerGroups_Customers aCustomerGroups_Customers = new CustomerGroups_Customers(); aCustomerGroups_Customers = aCustomerGroups_CustomersBO.Select_ByIDCustomer_ByIDCustomerGroup(IDCustomer, aCustomerGroups.ID); if (aCustomerGroups_Customers == null) { aCustomerGroups_Customers = new CustomerGroups_Customers(); Customers aCustomers = (new CustomersBO()).Select_ByID(IDCustomer); aCustomerGroups_Customers.IDCustomer = IDCustomer; aCustomerGroups_Customers.IDCustomerGroup = aCustomerGroups.ID; aCustomerGroups_Customers.Name = aCustomerGroups.Name + "_" + aCustomers.Name + "_" + aCustomers.Identifier1 + "_" + DateTime.Now.ToShortDateString(); return aCustomerGroups_CustomersBO.Insert(aCustomerGroups_Customers); } else { return 0; } }
//hiennv private void btnApply_Click(object sender, EventArgs e) { try { if (this.CheckDataBeforeApply() == true) { CustomerGroups_CustomersBO aCustomerGroupsCustomersBO = new CustomerGroups_CustomersBO(); if (aListRemove.Count > 0) { foreach (Customers item in aListRemove) { CustomerGroups_Customers aCustomerGroups_Customers = aCustomerGroupsCustomersBO.Select_ByIDCustomer_ByIDCustomerGroup(item.ID, IDCustomerGroup); if (aCustomerGroups_Customers != null) { aCustomerGroupsCustomersBO.Delete(item.ID, IDCustomerGroup); } } if (this.afrmTsk_CheckIn_Goverment_Step2 != null) { this.afrmTsk_CheckIn_Goverment_Step2.LoadIDCustomers(); } else if (this.afrmTsk_CheckIn_Group_Step2 != null) { this.afrmTsk_CheckIn_Group_Step2.LoadIDCustomers(); } else if (this.afrm_Tsk_CheckIn_Customer_Step2 != null) { this.afrm_Tsk_CheckIn_Customer_Step2.LoadCustomers(); } else if (this.afrmTsk_Booking_Step2 != null) { this.afrmTsk_Booking_Step2.LoadIDCustomers(); } else if (this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2 != null) { this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2.LoadIDCustomers(); this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_CheckInGroup_ForRoomBooking_Step2 != null) { this.afrmTsk_CheckInGroup_ForRoomBooking_Step2.LoadIDCustomers(); this.afrmTsk_CheckInGroup_ForRoomBooking_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2 != null) { this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2.LoadCustomers(); this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2.CallBackIDCustomer(aListAdd[0].ID); } } if (aListAdd.Count > 0) { CustomerGroups_Customers aCustomerGroups_Customers = new CustomerGroups_Customers(); foreach (Customers item in aListAdd) { aCustomerGroups_Customers = aCustomerGroupsCustomersBO.Select_ByIDCustomer_ByIDCustomerGroup(item.ID, IDCustomerGroup); if (aCustomerGroups_Customers != null) { string name = (NameCustomerGroup + "_" + item.Name).Length > 150 ? (NameCustomerGroup + "_" + item.Name).Substring(0, 150) : (NameCustomerGroup + "_" + item.Name); aCustomerGroups_Customers.Name = name; aCustomerGroups_Customers.IDCustomer = item.ID; aCustomerGroups_Customers.IDCustomerGroup = IDCustomerGroup; aCustomerGroupsCustomersBO.Insert(aCustomerGroups_Customers); } } if (this.afrmTsk_CheckIn_Goverment_Step2 != null) { this.afrmTsk_CheckIn_Goverment_Step2.LoadIDCustomers(); this.afrmTsk_CheckIn_Goverment_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_CheckIn_Group_Step2 != null) { this.afrmTsk_CheckIn_Group_Step2.LoadIDCustomers(); this.afrmTsk_CheckIn_Group_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrm_Tsk_CheckIn_Customer_Step2 != null) { this.afrm_Tsk_CheckIn_Customer_Step2.LoadCustomers(); this.afrm_Tsk_CheckIn_Customer_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_Booking_Step2 != null) { this.afrmTsk_Booking_Step2.LoadIDCustomers(); this.afrmTsk_Booking_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2 != null) { this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2.LoadIDCustomers(); this.afrmTsk_CheckInGoverment_ForRoomBooking_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_CheckInGroup_ForRoomBooking_Step2 != null) { this.afrmTsk_CheckInGroup_ForRoomBooking_Step2.LoadIDCustomers(); this.afrmTsk_CheckInGroup_ForRoomBooking_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2!= null) { this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2.LoadCustomers(); this.afrmTsk_CheckInCustomer_ForRoomBooking_Step2.CallBackIDCustomer(aListAdd[0].ID); } else if (afrmTsk_BookingHall_Goverment != null) { afrmTsk_BookingHall_Goverment.CallBackIDCustomer(aListSelectCustomers); } else if (afrmTsk_BookingHall_Group != null) { afrmTsk_BookingHall_Group.CallBackIDCustomer(aListSelectCustomers); } else if (afrmTsk_BookingHall_Customer != null) { afrmTsk_BookingHall_Customer.CallBackIDCustomer(aListSelectCustomers); } else if (afrmTsk_UpdBooking != null) { afrmTsk_UpdBooking.CallBackIDCustomer(aListSelectCustomers); } } this.Close(); MessageBox.Show("Thực hiện thành công!", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch (Exception ex) { MessageBox.Show("frmAddListCustomerToCustomerGroups.btnApply_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public int InsertCustomerIntoCustomerGroup(int IDCustomer, int IDCustomerGroup) { // Add customer vao group CustomerGroupsBO aCustomerGroupsBO = new CustomerGroupsBO(); CustomerGroups aCustomerGroups = new CustomerGroups(); aCustomerGroups = aCustomerGroupsBO.Select_ByID(IDCustomerGroup); CustomerGroups_CustomersBO aCustomerGroups_CustomersBO = new CustomerGroups_CustomersBO(); CustomerGroups_Customers aCustomerGroups_Customers = new CustomerGroups_Customers(); aCustomerGroups_Customers = aCustomerGroups_CustomersBO.Select_ByIDCustomer_ByIDCustomerGroup(IDCustomer, IDCustomerGroup); if (aCustomerGroups_Customers == null) { Customers aCustomers = (new CustomersBO()).Select_ByID(IDCustomer); aCustomerGroups_Customers.IDCustomer = IDCustomer; aCustomerGroups_Customers.IDCustomerGroup = aCustomerGroups.ID; aCustomerGroups_Customers.Name = aCustomerGroups.Name + "_" + aCustomers.Name + "_" + aCustomers.Identifier1 + "_" + DateTime.Now.ToShortDateString(); return aCustomerGroups_CustomersBO.Insert(aCustomerGroups_Customers); } else return 0; }
private void btnApply_Click(object sender, EventArgs e) { try { CustomerGroups_CustomersBO aCustomerGroupsCustomersBO = new CustomerGroups_CustomersBO(); if (aListRemove.Count > 0) { foreach (Customers item in aListRemove) { List<CustomerGroups_Customers> count = aCustomerGroupsCustomersBO.Select_ByIDCustomer_ByIDCustomerGroup(item.ID, IDCustomerGroup); if (count.Count > 0) { aCustomerGroupsCustomersBO.Delete(item.ID, IDCustomerGroup); } } } if (aListAdd.Count > 0) { foreach (Customers item in aListAdd) { List<CustomerGroups_Customers> list = aCustomerGroupsCustomersBO.Select_ByIDCustomer_ByIDCustomerGroup(item.ID, IDCustomerGroup); if (list.Count < 1) { CustomerGroups_Customers aCustomerGroups_Customers = new CustomerGroups_Customers(); string name = (NameCustomerGroup + "_" + item.Name).Length > 150 ? (NameCustomerGroup + "_" + item.Name).Substring(0, 250) : (NameCustomerGroup + "_" + item.Name); aCustomerGroups_Customers.Name = name; aCustomerGroups_Customers.IDCustomer = item.ID; aCustomerGroups_Customers.IDCustomerGroup = IDCustomerGroup; aCustomerGroupsCustomersBO.Insert(aCustomerGroups_Customers); } } } if (afrmTsk_BookingHall_Goverment != null) { afrmTsk_BookingHall_Goverment.CallBackIDCustomer(aListSelectCustomers); } if (afrmTsk_BookingHall_Group != null) { afrmTsk_BookingHall_Group.CallBackIDCustomer(aListSelectCustomers); } if (afrmTsk_BookingHall_Customer != null) { afrmTsk_BookingHall_Customer.CallBackIDCustomer(aListSelectCustomers); } if (afrmTsk_UpdBooking != null) { afrmTsk_UpdBooking.CallBackIDCustomer(aListSelectCustomers); } MessageBox.Show("Thực hiện thành công!", "Thông báo ", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } catch (Exception ex) { MessageBox.Show("frmAddListCustomerToCustomerGroups.btnApply_Click\n" + ex.ToString(), "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error); } }