private void txtContact_Leave(object sender, EventArgs e) { if (txtContact.Text.Length > 11 && txtContact.Text.Length <= 10) { lblphone.Hide(); } else if (txtContact.Text.Contains("09") && txtContact.Text.Length == 11 || txtContact.Text.Contains("639") && txtContact.Text.Length == 12 || txtContact.Text.Contains("+639") && txtContact.Text.Length == 13) { lblphone.Hide(); } else { lblphone.Show(); return; } if (!txtContact.Text.Contains("09") && !txtContact.Text.Contains("639") && !txtContact.Text.Contains("+639")) { lblphone.Show(); return; } if (Phonevalidation.checkPhonenumber(txtContact.Text.ToString())) { lblphone.Hide(); } else { lblphone.Show(); return; } }
private void btnSaveChange_Click(object sender, EventArgs e) { MySqlConnection Conn = ConString.Connection; string Query = "Update tbl_store set store_name = '" + txtStore.Text + "', contact_person = '" + txtCPerson.Text + "', contact_number = '" + txtContact.Text + "', telephone = '" + txtTelephone.Text + "', street = '" + txtStreet.Text + "', barangay = '" + txtBarangay.Text + "', city = '" + txtCity.Text + "' where store_id = '" + getbranchid + "'"; MySqlCommand cmd = new MySqlCommand(Query, Conn); cmd.CommandTimeout = 50000; // Conn.Open(); if (txtContact.Text.Length > 11 && txtContact.Text.Length <= 10) { lblphone.Hide(); } else if (txtContact.Text.Contains("09") && txtContact.Text.Length == 11 || txtContact.Text.Contains("639") && txtContact.Text.Length == 12 || txtContact.Text.Contains("+639") && txtContact.Text.Length == 13) { lblphone.Hide(); } else { // MessageBox.Show("The phone number format is not recognized.", "Fabula's Merchandise System", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblphone.Show(); return; } if (!txtContact.Text.Contains("09") && !txtContact.Text.Contains("639") && !txtContact.Text.Contains("+639")) { MessageBox.Show("The phone number format is not recognized.", "Fabula's Merchandise System", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblphone.Show(); return; } if (Phonevalidation.checkPhonenumber(txtContact.Text.ToString())) { lblphone.Hide(); } else { MessageBox.Show("The phone number format is not recognized.", "Fabula's Merchandise System", MessageBoxButtons.OK, MessageBoxIcon.Warning); lblphone.Show(); return; } if (TelephoneValidation.TelephoneNumber(txtTelephone.Text.ToString())) { lbltelephone.Hide(); } else { lbltelephone.Show(); return; } if (MessageBox.Show("Do you want to save the changes you have made to the field(s)?", "Fabula's Merchandise System", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes) { try { MySqlDataReader myReader; myReader = cmd.ExecuteReader(); while (myReader.Read()) { } Conn.Close(); MessageBox.Show("Save changed successfully.", "Fabula's Merchandise System", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception ex) { MessageBox.Show(ex.Message); } DGVBranchInfo(); btnSave1.Enabled = false; btnSave1.BackColor = Color.DarkGray; } }