public bool InsertUpdateDelete(Customer customer, Database db, DbTransaction transaction) { DbCommand commandInsert = db.GetStoredProcCommand("usp_CustomerGroupInsert"); db.AddInParameter(commandInsert, "@GroupId", DbType.Int32, customer.CustomerId); db.AddInParameter(commandInsert, "@CompanyId", DbType.Int32, customer.CompanyId); db.AddInParameter(commandInsert, "@CustomerName", DbType.String, "CustomerName", DataRowVersion.Current); db.AddInParameter(commandInsert, "@PassportNumber", DbType.String, "PassportNumber", DataRowVersion.Current); db.AddInParameter(commandInsert, "@Gender", DbType.String, "Gender", DataRowVersion.Current); db.AddInParameter(commandInsert, "@GuestTypeId", DbType.Int32, "GuestTypeId", DataRowVersion.Current); db.AddInParameter(commandInsert, "@Phone", DbType.String, "Phone", DataRowVersion.Current); db.AddInParameter(commandInsert, "@StatusId", DbType.Int32, (int)HBM.Common.Enums.HBMStatus.Active); db.AddInParameter(commandInsert, "@IsGroupCustomer", DbType.Boolean, customer.IsGroupCustomer); db.AddInParameter(commandInsert, "@CreatedUser", DbType.Int32, "CreatedUser", DataRowVersion.Current); DbCommand commandUpdate = db.GetStoredProcCommand("usp_CustomerGroupUpdate"); db.AddInParameter(commandUpdate, "@CustomerId", DbType.Int32, "CustomerId", DataRowVersion.Current); db.AddInParameter(commandUpdate, "@CustomerName", DbType.String, "CustomerName", DataRowVersion.Current); db.AddInParameter(commandUpdate, "@PassportNumber", DbType.String, "PassportNumber", DataRowVersion.Current); db.AddInParameter(commandUpdate, "@Gender", DbType.String, "Gender", DataRowVersion.Current); db.AddInParameter(commandUpdate, "@GuestTypeId", DbType.Int32, "GuestTypeId", DataRowVersion.Current); db.AddInParameter(commandUpdate, "@Phone", DbType.String, "Phone", DataRowVersion.Current); db.AddInParameter(commandUpdate, "@StatusId", DbType.Int32, (int)HBM.Common.Enums.HBMStatus.Active); db.AddInParameter(commandUpdate, "@UpdatedUser", DbType.Int32, "UpdatedUser", DataRowVersion.Current); DbCommand commandDelete = db.GetStoredProcCommand("usp_CustomerDelete"); db.AddInParameter(commandDelete, "@CustomerId", DbType.Int32, "CustomerId", DataRowVersion.Current); db.UpdateDataSet(customer.DsGroupCustomers, customer.DsGroupCustomers.Tables[0].TableName, commandInsert, commandUpdate, commandDelete, transaction); return true; }
private void ViewData() { try { CustMan.Customer CustomerObj = new CustMan.Customer(); CustomerObj.CustomerId = Int32.Parse(hdnCustomerId.Value.Trim() == String.Empty ? "0" : hdnCustomerId.Value.Trim()); if (CustomerObj.CustomerId > 0) { CustomerObj.CompanyId = Master.CurrentCompany.CompanyId; CustomerObj = CustomerObj.Select(); if (CustomerObj.IsGroupCustomer.HasValue && CustomerObj.IsGroupCustomer == true) { LoadGroupCustomers(CustomerObj); } else { LoadIndividualCustomers(CustomerObj); } } else { CustMan.Customer CustomerObj1 = new CustMan.Customer(); dsData = CustomerObj1.SelectGroupByGroupId(0); gvGroupMembers.DataSource = dsData; gvGroupMembers.DataBind(); dsData.Tables[0].PrimaryKey = new DataColumn[] { dsData.Tables[0].Columns["CustomerId"] }; Session[Constants.SESSION_GROUPCUSTOMERS] = dsData; } } catch (System.Exception) { } }
public bool Delete(Customer customer) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_CustomerDelete"); db.AddInParameter(command, "@CustomerId", DbType.Int32, customer.CustomerId); db.ExecuteNonQuery(command); return true; }
protected void gvCustomers_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { int i = gvCustomers.FindVisibleIndexByKeyValue(e.Keys[gvCustomers.KeyFieldName]); e.Cancel = true; CustomerManagement.Customer customer = new CustomerManagement.Customer(); customer.CustomerId =(int)e.Keys[gvCustomers.KeyFieldName]; if (customer.Delete()) { this.LoadCustomers(); } }
public bool Insert(Customer customer, Database db, DbTransaction transaction) { DbCommand command = db.GetStoredProcCommand("usp_CustomerInsert"); db.AddInParameter(command, "@CompanyId", DbType.Int32, customer.CompanyId); db.AddInParameter(command, "@CustomerName", DbType.String, customer.CustomerName); db.AddInParameter(command, "@Gender", DbType.String, customer.Gender); db.AddInParameter(command, "@GuestTypeId", DbType.Int32, customer.GuestTypeId); db.AddInParameter(command, "@Phone", DbType.String, customer.Phone); db.AddInParameter(command, "@Fax", DbType.String, customer.Fax); db.AddInParameter(command, "@Mobile", DbType.String, customer.Mobile); db.AddInParameter(command, "@Email", DbType.String, customer.Email); db.AddInParameter(command, "@CompanyName", DbType.String, customer.CompanyName); db.AddInParameter(command, "@CompanyAddressLine1", DbType.String, customer.CompanyAddressLine1); db.AddInParameter(command, "@CompanyAddressLine2", DbType.String, customer.CompanyAddressLine2); db.AddInParameter(command, "@CompanyCity", DbType.String, customer.CompanyCity); db.AddInParameter(command, "@CompanyState", DbType.String, customer.CompanyState); db.AddInParameter(command, "@CompanyPostCode", DbType.String, customer.CompanyPostCode); db.AddInParameter(command, "@CompanyCountryId", DbType.Int32, customer.CompanyCountryId); db.AddInParameter(command, "@CompanyNotes", DbType.String, customer.CompanyNotes); db.AddInParameter(command, "@BillingAddressLine1", DbType.String, customer.BillingAddressLine1); db.AddInParameter(command, "@BillingAddressLine2", DbType.String, customer.BillingAddressLine2); db.AddInParameter(command, "@BillingCity", DbType.String, customer.BillingCity); db.AddInParameter(command, "@BillingState", DbType.String, customer.BillingState); db.AddInParameter(command, "@BillingCountryId", DbType.Int32, customer.BillingCountryId); db.AddInParameter(command, "@BillingPostCode", DbType.String, customer.BillingPostCode); db.AddInParameter(command, "@PassportNumber", DbType.String, customer.PassportNumber); db.AddInParameter(command, "@PassportCountryOfIssue", DbType.Int32, customer.PassportCountryOfIssue); db.AddInParameter(command, "@PassportExpirationDate", DbType.DateTime, customer.PassportExpirationDate); db.AddInParameter(command, "@CreditCardTypeId", DbType.Int32, customer.CreditCardTypeId); db.AddInParameter(command, "@CCNo", DbType.String, customer.CCNo); db.AddInParameter(command, "@CCExpirationDate", DbType.DateTime, customer.CCExpirationDate); db.AddInParameter(command, "@CCNameOnCard", DbType.String, customer.CCNameOnCard); db.AddInParameter(command, "@Car", DbType.String, customer.Car); db.AddInParameter(command, "@CarLicensePlate", DbType.String, customer.CarLicensePlate); db.AddInParameter(command, "@DriverLicense", DbType.String, customer.DriverLicense); db.AddInParameter(command, "@CreatedUser", DbType.Int32, customer.CreatedUser); db.AddInParameter(command, "@StatusId", DbType.Int32, customer.StatusId); db.AddInParameter(command, "@CardSecurityCode", DbType.String, customer.CardSecurityCode); db.AddInParameter(command, "@CardStartDate", DbType.DateTime, customer.CardStartDate); db.AddInParameter(command, "@CardIssueNo", DbType.String, customer.CardIssueNo); db.AddInParameter(command, "@UseSameBillingAddress", DbType.Boolean, customer.UseSameBillingAddress); db.AddInParameter(command, "@IsGroupCustomer", DbType.Boolean, customer.IsGroupCustomer); db.AddOutParameter(command, "@CustomerId", DbType.Int32, 8); db.ExecuteNonQuery(command, transaction); customer.CustomerId = int.Parse(db.GetParameterValue(command, "@CustomerId").ToString()); return true; }
protected void gvCustomers_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e) { int i = gvCustomers.FindVisibleIndexByKeyValue(e.Keys[gvCustomers.KeyFieldName]); e.Cancel = true; CustomerManagement.Customer customer = new CustomerManagement.Customer(); customer.CustomerId = (int)e.Keys[gvCustomers.KeyFieldName]; if (customer.Delete()) { this.LoadCustomers(); } }
private void SaveData() { CustMan.Customer currentCustomer = new CustMan.Customer(); currentCustomer.CustomerId = Int32.Parse(hdnCustomerId.Value.Trim() == String.Empty ? "0" : hdnCustomerId.Value.Trim()); currentCustomer.CompanyId = Master.CurrentCompany.CompanyId; if (hdnCustomerMode.Value.Trim() == "1") { SaveSingleCustomerData(currentCustomer); } else { SaveCustomerGroupData(currentCustomer); } string errorMSG; if ((new CustomerManagement.CustomerManager()).IsValidToSave(currentCustomer, out errorMSG)) { if (string.IsNullOrEmpty(errorMSG) && currentCustomer.Save()) { hdnCustomerId.Value = currentCustomer.CustomerId.ToString(); this.ViewData(); dsData = currentCustomer.SelectGroupByGroupId(currentCustomer.CustomerId); gvGroupMembers.DataSource = dsData; gvGroupMembers.DataBind(); dsData.Tables[0].PrimaryKey = new DataColumn[] { dsData.Tables[0].Columns["CustomerId"] }; Session[Constants.SESSION_GROUPCUSTOMERS] = dsData; System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowSuccessMessage('" + Messages.Save_Success + "')", true); } else { System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "ShowMessage", "javascript:ShowInfoMessage('" + Messages.Save_Unsuccess + "')", true); } } }
/// <summary> /// Pass the customer object to this method and check if its valid to be saved. /// </summary> /// <param name="customer"></param> /// <param name="?"></param> /// <returns></returns> public bool IsValidToSave(Customer customer, out string errorMSG) { bool isValid = true; errorMSG = string.Empty; return isValid; }
private void LoadSharesList(int customerID) { DataSet dsCustomersList = new DataSet(); Customer customer = new Customer(); dsCustomersList = customer.SelectByGroup(customerID); if (dsCustomersList != null && dsCustomersList.Tables.Count > 0 && dsCustomersList.Tables[0] != null && dsCustomersList.Tables[0].Rows.Count > 0) { ASPxMenu tmpMenu = (ASPxMenu)ddlShareNames.FindControl("mnuGuest"); if (tmpMenu != null) { for (int i = 0; i <= dsCustomersList.Tables[0].Rows.Count - 1; i++) { tmpMenu.Items[0].Items.Add(new MenuItem(dsCustomersList.Tables[0].Rows[i]["CustomerName"] != null ? dsCustomersList.Tables[0].Rows[i]["CustomerName"].ToString() : string.Empty)); } } } }
private void LoadCardInformationByCustomer(int customerID) { DataSet dsCustomers = new DataSet(); Customer customer = new Customer(); dsCustomers = customer.SelectById(customerID); reservationPayments.ReservationId = 0; dsPaymentInformation = reservationPayments.SelectAllDataSetByReservationID(); dsPaymentInformation.Tables[0].PrimaryKey = new DataColumn[] { dsPaymentInformation.Tables[0].Columns["ReservationPaymentId"] }; DataRow dataRow = dsPaymentInformation.Tables[0].NewRow(); Random rd = new Random(); dataRow["ReservationPaymentId"] = rd.Next(); dataRow["PaymentDate"] = DateTime.Today; dataRow["PaymentTypeId"] = (int)HBM.Common.Enums.PaymentType.CreditCard; dataRow["CreditCardTypeId"] = dsCustomers.Tables[0].Rows[0]["CreditCardTypeId"] != null ? dsCustomers.Tables[0].Rows[0]["CreditCardTypeId"] : "1"; dataRow["CCNo"] = dsCustomers.Tables[0].Rows[0]["CCNo"] != null ? dsCustomers.Tables[0].Rows[0]["CCNo"] : string.Empty; dataRow["CCExpirationDate"] = dsCustomers.Tables[0].Rows[0]["CCExpirationDate"] != null ? dsCustomers.Tables[0].Rows[0]["CCExpirationDate"] : string.Empty; dataRow["CCNameOnCard"] = dsCustomers.Tables[0].Rows[0]["CCNameOnCard"] != null ? dsCustomers.Tables[0].Rows[0]["CCNameOnCard"] : string.Empty; dataRow["Amount"] = "0.00"; dataRow["CreatedUser"] = SessionHandler.LoggedUser.UsersId; dataRow["StatusId"] = (int)HBM.Common.Enums.HBMStatus.Active; if (dsCustomers.Tables[0].Rows[0]["CreditCardTypeId"] != null) { dsPaymentInformation.Tables[0].Rows.Add(dataRow); gvPaymentInformation.DataSource = dsPaymentInformation.Tables[0]; gvPaymentInformation.DataBind(); Session[Constants.SESSION_RESERVATION_PAYMENTINFORMATION] = dsPaymentInformation; } }
private void LoadGroupCustomers(CustMan.Customer CustomerObj) { hdnCustomerMode.Value = ((int)Common.Enums.CustomerModes.Group).ToString(); rblCustomerMode.SelectedValue = ((int)Common.Enums.CustomerModes.Group).ToString(); chkUseSameBillingAddressGrp.Checked = CustomerObj.UseSameBillingAddress; tblIndividualCustomer.Visible = false; tblGroupCustomer.Visible = true; if (CustomerObj.UseSameBillingAddress) { txtCompanyAddressLine1Grp.Enabled = false; txtCompanyAddressLine2Grp.Enabled = false; txtCompanyStateGrp.Enabled = false; cmbCompanyCountryGrp.Enabled = false; txtCompanyPostCodeGrp.Enabled = false; txtCompanyCityGrp.Enabled = false; } else { txtCompanyAddressLine1Grp.Enabled = true; txtCompanyAddressLine2Grp.Enabled = true; txtCompanyStateGrp.Enabled = true; cmbCompanyCountryGrp.Enabled = true; txtCompanyPostCodeGrp.Enabled = true; txtCompanyCityGrp.Enabled = true; } txtGroupName.Text = CustomerObj.CustomerName; txtBillingAddressLine1Grp.Text = CustomerObj.BillingAddressLine1; txtBillingAddressLine2Grp.Text = CustomerObj.BillingAddressLine2; txtBillingCityGrp.Text = CustomerObj.BillingCity; if (CustomerObj.BillingCountryId.HasValue) { cmbBillingCountryGrp.Value = CustomerObj.BillingCountryId; } txtBillingZipPostalCodeGrp.Text = CustomerObj.BillingPostCode; txtBillingStateGrp.Text = CustomerObj.BillingState; CCExpiryDateGrp = CustomerObj.CCExpirationDate; txtNameOnCardGrp.Text = CustomerObj.CCNameOnCard; txtCCNoGrp.Text = string.IsNullOrEmpty(CustomerObj.CCNo) ? string.Empty : CustomerObj.CCNo.ToString(); txtCardSecurityCodeGrp.Text = CustomerObj.CardSecurityCode; if (CustomerObj.CardStartDate == null) { dtStartDateGrp.Text = string.Empty; } else { dtStartDateGrp.Value = CustomerObj.CardStartDate; } txtCardIssueNoGrp.Text = CustomerObj.CardIssueNo; if (CustomerObj.CreditCardTypeId.HasValue) { cmbCCTypeGrp.Value = CustomerObj.CreditCardTypeId.Value; } txtCompanyAddressLine1Grp.Text = CustomerObj.CompanyAddressLine1; txtCompanyAddressLine2Grp.Text = CustomerObj.CompanyAddressLine2; txtCompanyCityGrp.Text = CustomerObj.CompanyCity; if (CustomerObj.CompanyCountryId.HasValue) { cmbCompanyCountryGrp.Value = CustomerObj.CompanyCountryId; } txtCompanyStateGrp.Text = CustomerObj.CompanyState; txtCompanyPostCodeGrp.Text = CustomerObj.CompanyPostCode; txtCompanyNameGrp.Text = CustomerObj.CompanyName; txtCompanyNotesGrp.Text = CustomerObj.CompanyNotes; txtEmailGrp.Text = CustomerObj.Email; txtFaxGrp.Text = CustomerObj.Fax; if (CustomerObj.GuestTypeId > 0) { cmbGuestTypeGrp.Value = CustomerObj.GuestTypeId; } txtMemberCodeGrp.Text = CustomerObj.MemberCode; txtPhoneGrp.Text = CustomerObj.Phone; //Load the grid gvGroupMembers.DataSource = CustomerObj.DsGroupCustomers; gvGroupMembers.DataBind(); dsData = CustomerObj.DsGroupCustomers; Session[Constants.SESSION_GROUPCUSTOMERS] = dsData; dsData.Tables[0].PrimaryKey = new DataColumn[] { dsData.Tables[0].Columns["CustomerId"] }; rblCustomerMode.Enabled = false; }
private void SaveSingleCustomerData(CustMan.Customer currentCustomer) { currentCustomer.CustomerName = txtCustomerName.Value.ToString(); if (cmbCar.SelectedItem != null && cmbCar.SelectedItem.Value != null && cmbCar.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.Car = cmbCar.SelectedItem.Value.ToString(); } else { currentCustomer.Car = null; } currentCustomer.CarLicensePlate = txtLicensePlate.Value == null ? string.Empty : txtLicensePlate.Value.ToString(); currentCustomer.CCExpirationDate = CCExpiryDate; currentCustomer.CCNameOnCard = txtNameOnCard.Value == null ? string.Empty : txtNameOnCard.Value.ToString(); currentCustomer.CCNo = txtCCNumber.Value == null ? string.Empty : txtCCNumber.Value.ToString(); currentCustomer.CardSecurityCode = txtCardSecurityCode.Value == null ? string.Empty : txtCardSecurityCode.Value.ToString(); if (dtStartDate.Value == null || dtStartDate.Value.ToString() == string.Empty) { currentCustomer.CardStartDate = null; } else { currentCustomer.CardStartDate = Convert.ToDateTime(dtStartDate.Value.ToString()); } currentCustomer.CardIssueNo = txtCardIssueNo.Value == null ? string.Empty : txtCardIssueNo.Value.ToString(); if (cmbCCType.SelectedItem != null && cmbCCType.SelectedItem.Value != null && cmbCCType.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.CreditCardTypeId = Convert.ToInt32(cmbCCType.SelectedItem.Value.ToString()); } else { currentCustomer.CreditCardTypeId = null; } currentCustomer.CompanyName = txtCompanyName.Value == null ? string.Empty : txtCompanyName.Value.ToString(); currentCustomer.CompanyNotes = txtNotes.Value == null ? string.Empty : txtNotes.Value.ToString(); currentCustomer.UseSameBillingAddress = chkUseSameBillingAddress.Checked == true ? true : false; if (chkUseSameBillingAddress.Checked) { currentCustomer.CompanyAddressLine1 = string.Empty; currentCustomer.CompanyAddressLine2 = string.Empty; currentCustomer.CompanyCity = string.Empty; currentCustomer.CompanyCountryId = null; currentCustomer.CompanyState = string.Empty; currentCustomer.CompanyPostCode = string.Empty; } else { currentCustomer.CompanyAddressLine1 = txtCompanyAddressLine1.Value == null ? string.Empty : txtCompanyAddressLine1.Value.ToString(); currentCustomer.CompanyAddressLine2 = txtCompanyAddressLine2.Value == null ? string.Empty : txtCompanyAddressLine2.Value.ToString(); currentCustomer.CompanyCity = txtCompanyCity.Text.Trim(); if (cmbCompanyCountry.SelectedItem != null && cmbCompanyCountry.SelectedItem.Value != null && cmbCompanyCountry.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.CompanyCountryId = Convert.ToInt32(cmbCompanyCountry.SelectedItem.Value.ToString()); } else { currentCustomer.CompanyCountryId = null; } currentCustomer.CompanyState = txtCompanyState.Value == null ? string.Empty : txtCompanyState.Value.ToString(); currentCustomer.CompanyPostCode = txtCompanyPostCode.Value == null ? string.Empty : txtCompanyPostCode.Value.ToString(); } currentCustomer.BillingAddressLine1 = txtBillingAddressLine1.Value == null ? string.Empty : txtBillingAddressLine1.Value.ToString(); currentCustomer.BillingAddressLine2 = txtBillingAddressLine2.Value == null ? string.Empty : txtBillingAddressLine2.Value.ToString(); currentCustomer.BillingCity = txtBillingCity.Value.ToString(); currentCustomer.BillingState = txtBillingState.Value == null ? string.Empty : txtBillingState.Value.ToString(); if (cmbBillingCountry.SelectedItem != null && cmbBillingCountry.SelectedItem.Value != null && cmbBillingCountry.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.BillingCountryId = Convert.ToInt32(cmbBillingCountry.SelectedItem.Value); } else { currentCustomer.BillingCountryId = null; } currentCustomer.BillingPostCode = txtBillingPostCode.Value == null ? string.Empty : txtBillingPostCode.Value.ToString(); currentCustomer.DriverLicense = txtDriveLicense.Value == null ? string.Empty : txtDriveLicense.Value.ToString(); currentCustomer.Email = txtEmail.Value == null ? string.Empty : txtEmail.Value.ToString(); currentCustomer.Fax = txtFax.Value == null ? string.Empty : txtFax.Value.ToString(); currentCustomer.Gender = cmbGender.SelectedItem == null ? string.Empty : cmbGender.SelectedItem.Value.ToString(); currentCustomer.MemberCode = txtMemberCode.Value == null ? string.Empty : txtMemberCode.Value.ToString(); currentCustomer.Mobile = txtPhone.Value == null ? string.Empty : txtPhone.Value.ToString(); if (cmbGuestType.SelectedItem != null) { currentCustomer.GuestTypeId = (int)cmbGuestType.SelectedItem.Value; } if (cmbPassportCountryOfIssue.SelectedItem != null && cmbPassportCountryOfIssue.SelectedItem.Value != null && cmbPassportCountryOfIssue.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.PassportCountryOfIssue = Convert.ToInt32(cmbPassportCountryOfIssue.SelectedItem.Value); } else { currentCustomer.PassportCountryOfIssue = null; } if (dtpExpiryDate.Value != null) { currentCustomer.PassportExpirationDate = (DateTime?)dtpExpiryDate.Value; } currentCustomer.PassportNumber = txtPassportNumber.Value == null ? string.Empty : txtPassportNumber.Value.ToString(); currentCustomer.Phone = txtPhone.Value == null ? string.Empty : txtPhone.Value.ToString(); currentCustomer.CreatedUser = Master.LoggedUser.UsersId; currentCustomer.UpdatedUser = Master.LoggedUser.UsersId; currentCustomer.StatusId = (int)HBM.Common.Enums.HBMStatus.Active; }
public DataSet SelectAll(Customer customer) { Database db = DatabaseFactory.CreateDatabase(Constants.HBMCONNECTIONSTRING); DbCommand command = db.GetStoredProcCommand("usp_CustomerSelectAll"); db.AddInParameter(command, "@CompanyId", DbType.Int32, customer.CompanyId); return db.ExecuteDataSet(command); }
private void LoadIndividualCustomers(CustMan.Customer CustomerObj) { hdnCustomerMode.Value = ((int)Common.Enums.CustomerModes.Individual).ToString(); rblCustomerMode.SelectedValue = ((int)Common.Enums.CustomerModes.Individual).ToString(); tblIndividualCustomer.Visible = true; tblGroupCustomer.Visible = false; chkUseSameBillingAddress.Checked = CustomerObj.UseSameBillingAddress; if (CustomerObj.UseSameBillingAddress) { txtCompanyAddressLine1.Enabled = false; txtCompanyAddressLine2.Enabled = false; txtCompanyState.Enabled = false; cmbCompanyCountry.Enabled = false; txtCompanyPostCode.Enabled = false; txtCompanyCity.Enabled = false; } else { txtCompanyAddressLine1.Enabled = true; txtCompanyAddressLine2.Enabled = true; txtCompanyState.Enabled = true; cmbCompanyCountry.Enabled = true; txtCompanyPostCode.Enabled = true; txtCompanyCity.Enabled = true; } txtCustomerName.Text = CustomerObj.CustomerName; txtBillingAddressLine1.Text = CustomerObj.BillingAddressLine1; txtBillingAddressLine2.Text = CustomerObj.BillingAddressLine2; txtBillingCity.Text = CustomerObj.BillingCity; if (CustomerObj.BillingCountryId.HasValue) { cmbBillingCountry.Value = CustomerObj.BillingCountryId; } txtBillingPostCode.Text = CustomerObj.BillingPostCode; txtBillingState.Text = CustomerObj.BillingState; if (string.IsNullOrEmpty(CustomerObj.Car) == false) { cmbCar.Text = CustomerObj.Car; } txtLicensePlate.Text = CustomerObj.CarLicensePlate; CCExpiryDate = CustomerObj.CCExpirationDate; txtNameOnCard.Text = CustomerObj.CCNameOnCard; txtCCNumber.Text = string.IsNullOrEmpty(CustomerObj.CCNo) ? string.Empty : CustomerObj.CCNo.ToString(); txtCardSecurityCode.Text = CustomerObj.CardSecurityCode; if (CustomerObj.CardStartDate == null) { dtStartDate.Text = string.Empty; } else { dtStartDate.Value = CustomerObj.CardStartDate; } txtCardIssueNo.Text = CustomerObj.CardIssueNo; if (CustomerObj.CreditCardTypeId.HasValue) { cmbCCType.Value = CustomerObj.CreditCardTypeId.Value; } txtCompanyAddressLine1.Text = CustomerObj.CompanyAddressLine1; txtCompanyAddressLine2.Text = CustomerObj.CompanyAddressLine2; txtCompanyCity.Text = CustomerObj.CompanyCity; if (CustomerObj.CompanyCountryId.HasValue) { cmbCompanyCountry.Value = CustomerObj.CompanyCountryId; } txtCompanyState.Text = CustomerObj.CompanyState; txtCompanyPostCode.Text = CustomerObj.CompanyPostCode; txtCompanyName.Text = CustomerObj.CompanyName; txtNotes.Text = CustomerObj.CompanyNotes; txtDriveLicense.Text = CustomerObj.DriverLicense; txtEmail.Text = CustomerObj.Email; txtFax.Text = CustomerObj.Fax; if (CustomerObj.GuestTypeId > 0) { cmbGuestType.Value = CustomerObj.GuestTypeId; } if (string.IsNullOrEmpty(CustomerObj.Gender) == false) { cmbGender.Value = CustomerObj.Gender; } txtMemberCode.Text = CustomerObj.MemberCode; if (CustomerObj.PassportCountryOfIssue.HasValue) { cmbPassportCountryOfIssue.Value = CustomerObj.PassportCountryOfIssue; } if (CustomerObj.PassportExpirationDate.HasValue) { dtpExpiryDate.Date = CustomerObj.PassportExpirationDate.Value; } txtPassportNumber.Text = CustomerObj.PassportNumber; txtPhone.Text = CustomerObj.Phone; rblCustomerMode.Enabled = false; }
private void SaveCustomerGroupData(CustMan.Customer currentCustomer) { currentCustomer.CustomerName = txtGroupName.Value.ToString(); currentCustomer.Car = null; currentCustomer.CarLicensePlate = null; currentCustomer.CCExpirationDate = CCExpiryDateGrp; currentCustomer.CCNameOnCard = txtNameOnCardGrp.Text.ToString(); currentCustomer.CCNo = txtCCNoGrp.Text.ToString(); currentCustomer.CardSecurityCode = txtCardSecurityCodeGrp.Text.ToString(); if (dtStartDateGrp.Value == null) { currentCustomer.CardStartDate = null; } else { if (dtStartDateGrp.Value == null && dtStartDateGrp.Value.ToString() == string.Empty) { currentCustomer.CardStartDate = null; } else { currentCustomer.CardStartDate = Convert.ToDateTime(dtStartDateGrp.Value.ToString()); } } currentCustomer.CardIssueNo = txtCardIssueNoGrp.Text.ToString(); if (cmbCCTypeGrp.SelectedItem == null) { currentCustomer.CreditCardTypeId = null; } else { if (cmbCCTypeGrp.SelectedItem.Value != null && cmbCCTypeGrp.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.CreditCardTypeId = Convert.ToInt32(cmbCCTypeGrp.SelectedItem.Value.ToString()); } else { currentCustomer.CreditCardTypeId = null; } } currentCustomer.CompanyName = txtCompanyNameGrp.Text.ToString(); currentCustomer.CompanyNotes = txtCompanyNotesGrp.Text.ToString(); currentCustomer.UseSameBillingAddress = chkUseSameBillingAddressGrp.Checked == true ? true : false; if (chkUseSameBillingAddressGrp.Checked) { currentCustomer.CompanyAddressLine1 = string.Empty; currentCustomer.CompanyAddressLine2 = string.Empty; currentCustomer.CompanyCity = string.Empty; currentCustomer.CompanyCountryId = null; currentCustomer.CompanyState = string.Empty; currentCustomer.CompanyPostCode = string.Empty; } else { currentCustomer.CompanyAddressLine1 = txtCompanyAddressLine1Grp.Text.ToString(); currentCustomer.CompanyAddressLine2 = txtCompanyAddressLine2Grp.Text.ToString(); currentCustomer.CompanyCity = txtCompanyCityGrp.Text.Trim(); if (cmbCompanyCountryGrp.Items == null || cmbCompanyCountryGrp.SelectedItem == null) { currentCustomer.CompanyCountryId = null; } else { if (cmbCompanyCountryGrp.SelectedItem.Value != null && cmbCompanyCountryGrp.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.CompanyCountryId = Convert.ToInt32(cmbCompanyCountryGrp.SelectedItem.Value.ToString()); } else { currentCustomer.CompanyCountryId = null; } } currentCustomer.CompanyState = txtCompanyStateGrp.Text.ToString(); currentCustomer.CompanyPostCode = txtCompanyPostCodeGrp.Text.ToString(); } currentCustomer.BillingAddressLine1 = txtBillingAddressLine1Grp.Text.ToString(); currentCustomer.BillingAddressLine2 = txtBillingAddressLine2Grp.Text.ToString(); currentCustomer.BillingCity = txtBillingCityGrp.Text.ToString(); currentCustomer.BillingState = txtBillingStateGrp.Text.ToString(); if (cmbBillingCountryGrp.Items == null || cmbBillingCountryGrp.SelectedItem == null) { currentCustomer.BillingCountryId = null; } else { if (cmbBillingCountryGrp.SelectedItem.Value != null && cmbBillingCountryGrp.SelectedItem.Value.ToString() != string.Empty) { currentCustomer.BillingCountryId = Convert.ToInt32(cmbBillingCountryGrp.SelectedItem.Value); } else { currentCustomer.BillingCountryId = null; } } currentCustomer.BillingPostCode = txtBillingZipPostalCodeGrp.Text.ToString(); currentCustomer.DriverLicense = null; currentCustomer.Email = txtEmailGrp.Text.ToString(); currentCustomer.Fax = txtFaxGrp.Text.ToString(); currentCustomer.Gender = "Male"; currentCustomer.MemberCode = txtMemberCodeGrp.Text.ToString(); currentCustomer.Mobile = txtPhoneGrp.Text.ToString(); currentCustomer.GuestTypeId = (int)cmbGuestTypeGrp.SelectedItem.Value; currentCustomer.PassportCountryOfIssue = null; currentCustomer.Phone = txtPhoneGrp.Text.ToString(); currentCustomer.CreatedUser = Master.LoggedUser.UsersId; currentCustomer.UpdatedUser = Master.LoggedUser.UsersId; currentCustomer.StatusId = (int)HBM.Common.Enums.HBMStatus.Active; currentCustomer.IsGroupCustomer = true; currentCustomer.DsGroupCustomers = (DataSet)Session[Constants.SESSION_GROUPCUSTOMERS]; }