public bool OnSave() { try { if (objMaster.PrimaryKeyValue == null) { objMaster.New(); } else { objMaster.Edit(); } objMaster.Current.CompanyName = txtCompanyName.Text.Trim(); objMaster.Current.EmailAddress = txtCompanyEmail.Text.Trim(); objMaster.Current.Address = txtAddress.Text.Trim(); objMaster.Current.TelephoneNo = txtTelNo.Text.Trim(); objMaster.Current.EmergencyNo = txtCompanyEmergencyNo.Text.Trim(); objMaster.Current.WebsiteUrl = txtCompanyWebsite.Text.Trim(); objMaster.Current.Fax = txtCompanyFax.Text.Trim(); objMaster.Current.EmailCC = txtEmailCC.Text.Trim(); objMaster.Current.IsSysGen = false; if (pb_logo.GetImage() != null) { objMaster.Current.CompanyLogo = pb_logo.GetByteArrayOfImage(); } else { objMaster.Current.CompanyLogo = null; } objMaster.Current.BankName = txtBank.Text.Trim(); objMaster.Current.AccountNo = txtAccountNo.Text.Trim(); objMaster.Current.AccountTitle = txtAccountTitle.Text.Trim(); objMaster.Current.CompanyNumber = txtCompanyNumber.Text.Trim(); objMaster.Current.CompanyVatNumber = txtVATNumber.Text.Trim(); objMaster.Current.SortCode = txtSortCode.Text.Trim(); objMaster.Current.IbanNumber = txtIBAN.Text.Trim(); objMaster.Current.BlcNumber = txtBLC.Text.Trim(); objMaster.Current.BackgroundColor = txtBgColor.Tag.ToInt(); string mapIcon = ddlMapIcon.SelectedValue.ToStr().Trim(); if (string.IsNullOrEmpty(mapIcon)) { mapIcon = ddlMapIcon.Items[0].Value.ToStr(); } objMaster.Current.MapIcon = mapIcon; objMaster.Current.SmtpHasSSL = smtpchkIsSecureConn.Checked; objMaster.Current.SmtpHost = SmtpHost.Text.Trim(); objMaster.Current.SmtpPassword = smtpPassword.Text.Trim(); objMaster.Current.SmtpPort = smtpPort.Text.Trim(); objMaster.Current.SmtpUserName = smtpUserName.Text.Trim(); objMaster.Current.UseDifferentEmailForInvoices = chkUseInvoiceEmail.Checked; objMaster.Current.SmtpInvoiceUserName = smtpInvoiceEmail.Text.ToStr().Trim(); objMaster.Current.SmtpInvoicePassword = smtpInvoicePassword.Text.ToStr().Trim(); objMaster.Current.SmtpInvoiceHost = smtpInvoiceHost.Text.ToStr().Trim(); objMaster.Current.SmtpInvoicePort = smtpInvoicePort.Text.Trim(); objMaster.Current.SmtpInvoiceSSL = smtpInvoiceSSL.Checked; objMaster.Current.DisableAcceptEmail = chkDisableAcceptEmail.Checked; objMaster.Current.DisableDeclineEmail = chkDisableDeclineEmail.Checked; objMaster.Current.ConnectionString = txtCLINumbers.Text.Trim(); objMaster.Save(); // chkAmount.Checked = true; using (TaxiDataContext db = new TaxiDataContext()) { if (db.Gen_ServiceCharges.Where(c => c.SubCompanyId == objMaster.Current.Id).Count() == 0) { Gen_ServiceCharge objServiceCharge = new Gen_ServiceCharge(); objServiceCharge.SubCompanyId = objMaster.Current.Id; objServiceCharge.AmountWise = chkAmount.Checked; if (chkAmount.Checked) { objServiceCharge.ServiceChargePercent = 0; objServiceCharge.ServiceChargeAmount = numBookingFees.Value.ToDecimal(); } else { objServiceCharge.ServiceChargeAmount = 0; objServiceCharge.ServiceChargePercent = numBookingFees.Value.ToDecimal(); } db.Gen_ServiceCharges.InsertOnSubmit(objServiceCharge); db.SubmitChanges(); } else { // int Id = db.Gen_ServiceCharges.Where(c => c.SubCompanyId == objMaster.Current.Id).FirstOrDefault().Id; var query = db.Gen_ServiceCharges.FirstOrDefault(c => c.SubCompanyId == objMaster.Current.Id); query.AmountWise = chkAmount.Checked; if (chkAmount.Checked) { query.ServiceChargePercent = 0; query.ServiceChargeAmount = numBookingFees.Value.ToDecimal(); } else { query.ServiceChargeAmount = 0; query.ServiceChargePercent = numBookingFees.Value.ToDecimal(); } db.SubmitChanges(); } } // OnNew(); PopulateData(); UpdateEmailSettings(); return(true); } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } return(false); } }
public bool OnSave() { try { if (objMaster.PrimaryKeyValue == null) { objMaster.New(); } else { objMaster.Edit(); } objMaster.Current.CompanyName = txtCompanyName.Text.Trim(); objMaster.Current.EmailAddress = txtCompanyEmail.Text.Trim(); objMaster.Current.Address = txtAddress.Text.Trim(); objMaster.Current.TelephoneNo = txtTelNo.Text.Trim(); objMaster.Current.EmergencyNo = txtCompanyEmergencyNo.Text.Trim(); objMaster.Current.WebsiteUrl = txtCompanyWebsite.Text.Trim(); //objMaster.Current.EmailCC = txtEmailCC.Text.Trim(); objMaster.Current.IsSysGen = false; objMaster.Current.BackgroundColor = txtBgColor.Tag.ToInt(); objMaster.Current.IsTpCompany = true; //string mapIcon = ddlMapIcon.SelectedValue.ToStr().Trim(); //if (string.IsNullOrEmpty(mapIcon)) // mapIcon = ddlMapIcon.Items[0].Value.ToStr(); //objMaster.Current.MapIcon = mapIcon; //objMaster.Current.SmtpHasSSL = smtpchkIsSecureConn.Checked; //objMaster.Current.SmtpHost = SmtpHost.Text.Trim(); //objMaster.Current.SmtpPassword = smtpPassword.Text.Trim(); //objMaster.Current.SmtpPort = smtpPort.Text.Trim(); //objMaster.Current.SmtpUserName = smtpUserName.Text.Trim(); //objMaster.Current.DisableAcceptEmail = chkDisableAcceptEmail.Checked; //objMaster.Current.DisableDeclineEmail = chkDisableDeclineEmail.Checked; objMaster.Save(); OnNew(); PopulateData(); return(true); } catch (Exception ex) { if (objMaster.Errors.Count > 0) { ENUtils.ShowMessage(objMaster.ShowErrors()); } else { ENUtils.ShowMessage(ex.Message); } return(false); } }