Skip to content

Instantly share code, notes, and snippets.

@nicoletirado
Created December 14, 2011 01:34
Show Gist options
  • Save nicoletirado/1474818 to your computer and use it in GitHub Desktop.
Save nicoletirado/1474818 to your computer and use it in GitHub Desktop.
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim RecordNumber As Integer
If (IsNumeric(txtCustomerId.Text) And (txtCustomerId.Text.Length = 9)) Then
RecordNumber = Int(Math.Sqrt(txtCustomerId.Text.Trim))
Else
MessageBox.Show("The customer id is invalid.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
' Limpiar el campo
txtCustomerId.Clear()
txtCustomerId.Focus()
End If
If (txtName.Text.Trim <> String.Empty) Then
formMain.CustInfo.Name = txtName.Text.Trim
Else
MessageBox.Show("Please, fill out the name field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtFLName.Text.Trim <> String.Empty) Then
formMain.CustInfo.FLName = txtFLName.Text.Trim
Else
MessageBox.Show("Please, fill out the first last name field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtSLName.Text.Trim <> String.Empty) Then
formMain.CustInfo.SLName = txtSLName.Text.Trim
Else
MessageBox.Show("Please, fill out the second last name field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtAddressLine1.Text.Trim <> String.Empty) Then
formMain.CustInfo.AddressLine1 = txtAddressLine1.Text.Trim
Else
MessageBox.Show("Please, fill out the address line 1 field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtCity.Text.Trim <> String.Empty) Then
formMain.CustInfo.City = txtCity.Text.Trim
Else
MessageBox.Show("Please, fill out the city field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtState.Text.Trim <> String.Empty) Then
formMain.CustInfo.State = txtState.Text.Trim
Else
MessageBox.Show("Please, fill out the state field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtZipCode.Text.Trim <> String.Empty) Then
formMain.CustInfo.ZipCode = txtZipCode.Text.Trim
Else
MessageBox.Show("Please, fill out the zip code field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtCountry.Text.Trim <> String.Empty) Then
formMain.CustInfo.Country = txtCountry.Text.Trim
Else
MessageBox.Show("Please, fill out the country field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtBirthDate.Text.Trim <> String.Empty) Then
formMain.CustInfo.BirthDate = txtBirthDate.Text.Trim
Else
MessageBox.Show("Please, fill out the birth date field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtSocialSecurity.Text.Trim <> String.Empty) Then
formMain.CustInfo.SocialSecurity = txtSocialSecurity.Text.Trim
Else
MessageBox.Show("Please, fill out the social security field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtWorkPhone.Text.Trim <> String.Empty) Then
formMain.CustInfo.WorkPhone = txtWorkPhone.Text.Trim
Else
MessageBox.Show("Please, fill out the work phone field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtFaxPhone.Text.Trim <> String.Empty) Then
formMain.CustInfo.FaxPhone = txtFaxPhone.Text.Trim
Else
MessageBox.Show("Please, fill out the fax phone field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtCellPhone.Text.Trim <> String.Empty) Then
formMain.CustInfo.CellPhone = txtCellPhone.Text.Trim
Else
MessageBox.Show("Please, fill out the cellphone field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtEmail.Text.Trim <> String.Empty) Then
formMain.CustInfo.Email = txtEmail.Text.Trim
Else
MessageBox.Show("Please, fill out the email field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtCreditLine.Text.Trim <> String.Empty) Then
formMain.CustInfo.CreditLine = txtCreditLine.Text.Trim
Else
MessageBox.Show("Please, fill out the credit line field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtCompanyName.Text.Trim <> String.Empty) Then
formMain.CustInfo.CompanyName = txtCompanyName.Text.Trim
Else
MessageBox.Show("Please, fill out the company name field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
If (txtPin.Text.Trim <> String.Empty) Then
formMain.CustInfo.PinNumber = txtPin.Text.Trim
Else
MessageBox.Show("Please, fill out the pin number field", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
End If
End Sub
'Clears all fields in the form.
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
txtCustomerId.Text = String.Empty
txtName.Text = String.Empty
txtFLName.Text = String.Empty
txtSLName.Text = String.Empty
txtAddressLine1.Text = String.Empty
txtAddressLine2.Text = String.Empty
txtCity.Text = String.Empty
txtState.Text = String.Empty
txtZipCode.Text = String.Empty
txtCountry.Text = String.Empty
txtBirthDate.Text = String.Empty
txtSocialSecurity.Text = String.Empty
txtWorkPhone.Text = String.Empty
txtFaxPhone.Text = String.Empty
txtCellPhone.Text = String.Empty
txtEmail.Text = String.Empty
txtCreditLine.Text = String.Empty
txtCompanyName.Text = String.Empty
txtPin.Text = String.Empty
End Sub
Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
Me.Close()
End Sub
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment