private void OnCommandClick(object sender, System.EventArgs e) { //Event handler for button selection this.Cursor = Cursors.WaitCursor; try { Button btn = (Button)sender; switch (btn.Name) { case "btnClose": this.DialogResult = DialogResult.Cancel; this.Close(); break; case "btnVerifyAddress": //Validate\correct the address dlgVerifyAddress verify = new dlgVerifyAddress(); if (verify.VerifyAddress(this.txtName.Text, this.txtAddressLine1.Text, this.txtAddressLine2.Text, this.txtCity.Text, this.txtState.Text, this.txtZip5.Text, this.txtZip4.Text)) { this.txtName.Text = verify.FirmName; this.txtAddressLine1.Text = verify.AddressLine1; this.txtAddressLine2.Text = verify.AddressLine2; this.txtCity.Text = verify.City; this.txtState.Text = verify.State; this.txtZip5.Text = verify.Zip5; this.txtZip4.Text = verify.Zip4; this.mAddressValid = true; OnValidateForm(null, EventArgs.Empty); MessageBox.Show("Address is valid.", App.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "btnOk": //this.mShipper.Number this.mShipper.Name = this.txtName.Text; this.mShipper.AddressLine1 = this.txtAddressLine1.Text; this.mShipper.AddressLine2 = this.txtAddressLine2.Text; this.mShipper.City = this.txtCity.Text; this.mShipper.State = this.txtState.Text; this.mShipper.Zip = this.txtZip5.Text; this.mShipper.Zip4 = this.txtZip4.Text; this.mShipper.WindowTimeStart = DateTime.Parse("01-01-2000 " + this.mskWindowStart.Text); this.mShipper.WindowTimeEnd = DateTime.Parse("01-01-2000 " + this.mskWindowEnd.Text); this.mShipper.ContactName = this.txtContactName.Text; this.mShipper.ContactPhone = this.mskContactPhone.Text; this.mShipper.ContactEmail = this.txtContactEmail.Text; this.mShipper.LastUpdated = DateTime.Now; this.mShipper.UserID = Environment.UserName; this.DialogResult = DialogResult.OK; this.Close(); break; } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } finally { this.Cursor = Cursors.Default; } }
private void OnCommandClick(object sender, System.EventArgs e) { //Event handler for button selection this.Cursor = Cursors.WaitCursor; try { Button btn = (Button)sender; switch (btn.Name) { case "btnClose": this.DialogResult = DialogResult.Cancel; this.Close(); break; case "btnVerifyAddress": //Validate\correct the address dlgVerifyAddress verify = new dlgVerifyAddress(); if (verify.VerifyAddress(this.txtName.Text, this.txtAddressLine1.Text, this.txtAddressLine2.Text, this.txtCity.Text, this.txtState.Text, this.txtZip5.Text, this.txtZip4.Text)) { this.txtName.Text = verify.FirmName; this.txtAddressLine1.Text = verify.AddressLine1; this.txtAddressLine2.Text = verify.AddressLine2; this.txtCity.Text = verify.City; this.txtState.Text = verify.State; this.txtZip5.Text = verify.Zip5; this.txtZip4.Text = verify.Zip4; this.mAddressValid = true; OnValidateForm(null, EventArgs.Empty); MessageBox.Show("Address is valid.", App.Title, MessageBoxButtons.OK, MessageBoxIcon.Information); } break; case "btnOk": //this.mClient.ID this.mClient.Name = this.txtName.Text; this.mClient.AddressLine1 = this.txtAddressLine1.Text; this.mClient.AddressLine2 = ""; this.mClient.City = this.txtCity.Text; this.mClient.State = this.txtState.Text; this.mClient.Zip = this.txtZip5.Text; this.mClient.Zip4 = ""; this.mClient.ContactName = this.txtContactName.Text; this.mClient.ContactPhone = this.mskContactPhone.Text; this.mClient.ContactEmail = this.txtContactEmail.Text; this.mClient.CorporateName = this.txtCorpName.Text; this.mClient.CorporateAddressLine1 = this.txtCorpAddressLine1.Text; this.mClient.CorporateAddressLine2 = ""; this.mClient.CorporateCity = this.txtCorpCity.Text; this.mClient.CorporateState = this.txtCorpState.Text; this.mClient.CorporateZip = this.txtCorpZip5.Text; this.mClient.CorporateZip4 = ""; this.mClient.TaxID = this.txtTaxID.Text; if (this.mClient.ID == 0) { this.mClient.BillingAddressLine1 = this.txtBillAddressLine1.Text; this.mClient.BillingAddressLine2 = ""; this.mClient.BillingCity = this.txtBillCity.Text; this.mClient.BillingState = this.txtBillState.Text; this.mClient.BillingZip = this.txtBillZip5.Text; this.mClient.BillingZip4 = ""; } this.mClient.UserID = Environment.UserName; this.mClient.SalesRepClientNumber = this.txtSalesRepClientNumber.Text; this.DialogResult = DialogResult.OK; this.Close(); break; } } catch (Exception ex) { App.ReportError(ex, true, LogLevel.Error); } finally { this.Cursor = Cursors.Default; } }