private void txtTelephoneNumber_Leave(object sender, EventArgs e) { if (TelephoneValidation.TelephoneNumber(txtTelephone.Text.ToString())) { lbltelephone.Hide(); } else { lbltelephone.Show(); return; } }
private void btnAdd_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; MySqlConnection Conn = ConString.Connection; MySqlDataReader myReader; Cursor.Current = Cursors.WaitCursor; if (txtStore.Text == "" || txtBarangay.Text == "" || txtCity.Text == "" || txtStreet.Text == "" || txtTelephone.Text == "") { MessageBox.Show("Please enter require fields.", "Fabula's Merchandise System", MessageBoxButtons.OK, MessageBoxIcon.None); return; } //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; } string Query = "insert into tbl_store (store_name, telephone, street, barangay, city, status) values ('" + this.txtStore.Text + "', '" + txtTelephone.Text + "', '" + txtStreet.Text + "', '" + txtBarangay.Text + "', '" + txtCity.Text + "', 'New')"; MySqlCommand cmd = new MySqlCommand(Query, Conn); cmd.CommandTimeout = 50000; var dtt = new DataTable(); var sda = new MySqlDataAdapter("select store_name from tbl_store where REPLACE(store_name, ' ', '') = REPLACE('" + txtStore.Text + "', ' ', '')", Conn); sda.Fill(dtt); if (dtt.Rows.Count >= 1 || dtt.Rows.Count == 1) { if (txtStore.Text.Contains("")) { MessageBox.Show("The outlet: " + txtStore.Text + " already exists.", "Fabulas Merchandise", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return; } try { myReader = cmd.ExecuteReader(); while (myReader.Read()) { } } catch (Exception ex1) { MessageBox.Show(ex1.Message); } MessageBox.Show("Outlet added successfully.", "Fabulas Merchandise", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); Conn.Close(); //Cursor.Current = Cursors.AppStarting; //var myForm = new frm_Inventory(); //myForm.Show(); DGVBranchInfo(); btnAdd.Enabled = false; btnAdd.BackColor = Color.DarkGray; }
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; } }