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;
}