private void VendorNametextBox_Leave(object sender, EventArgs e) { // int Minlen = 3; //if (!(VendorNametextBox.Text.Length >= Minlen)) //{ // MessageBox.Show("input atleast 3 Character"); //// VendorNametextBox.Clear(); // VendorNametextBox.Focus(); // } if (!string.IsNullOrEmpty(VendorNametextBox.Text)) { string vendorname = VendorNametextBox.Text.Trim(); Regex mRegxExpression; int Minlen = 3; mRegxExpression = new Regex(@"^[A-Za-z]+[\s][A-Za-z]+[.][A-Za-z]+$"); if ((!mRegxExpression.IsMatch(vendorname)) && (!(VendorNametextBox.Text.Length >= Minlen))) { MessageBox.Show("Please type your valid Vendor Name.", "MojoCRM", MessageBoxButtons.OK, MessageBoxIcon.Error); VendorNametextBox.Clear(); VendorNametextBox.Focus(); } } }
private void CompanyTypecomboBox_SelectedIndexChanged(object sender, EventArgs e) { VendorNametextBox.Focus(); try { con = new SqlConnection(cs.DBConn); con.Open(); cmd = con.CreateCommand(); cmd.CommandText = "SELECT CompanyTypeId from VendorCompanyType WHERE CompanyTypeName= '" + CompanyTypecomboBox.Text + "'"; rdr = cmd.ExecuteReader(); if (rdr.Read()) { companytypeid = rdr.GetInt32(0); } if ((rdr != null)) { rdr.Close(); } if (con.State == ConnectionState.Open) { con.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void CompanyTypecomboBox_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { VendorNametextBox.Focus(); e.Handled = true; } }
private bool ValidateControlls() { bool validate = true; if (string.IsNullOrEmpty(CompanyTypecomboBox.Text)) { MessageBox.Show(@"Please select Company Type", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); validate = false; CompanyTypecomboBox.Focus(); } else if (string.IsNullOrEmpty(VendorNametextBox.Text)) { MessageBox.Show(@"Please enter Vendor name", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); validate = false; VendorNametextBox.Focus(); } else if (string.IsNullOrEmpty(cmbRADivision.Text)) { MessageBox.Show(@"Please select division", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); validate = false; cmbRADivision.Focus(); } else if (string.IsNullOrWhiteSpace(cmbRADistrict.Text)) { MessageBox.Show(@"Please Select district", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); validate = false; cmbRADistrict.Focus(); } else if (string.IsNullOrWhiteSpace(cmbRAThana.Text)) { MessageBox.Show(@"Please select Thana", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); validate = false; cmbRAThana.Focus(); } else if (string.IsNullOrWhiteSpace(cmbRAPost.Text)) { MessageBox.Show(@"Please Select Post Office", @"Error", MessageBoxButtons.OK, MessageBoxIcon.Error); validate = false; cmbRAPost.Focus(); } else if (ValidateVendor()) { validate = false; } return(validate); }