private void vendorToolStripMenuItem_Click(object sender, EventArgs e) { frmVendor frm = new frmVendor(); //frm.MdiParent = this; frm.ShowDialog(); }
private void btnVendor_Click(object sender, EventArgs e) { if (!Application.OpenForms.OfType <frmVendor>().Any()) { frmVendor vendor = new frmVendor(); vendor.Show(); } }
//Vendor events public void Insvendor(TextBox[] vendors, frmVendor vendor) { foreach (TextBox text in vendors) { if (string.IsNullOrEmpty(text.Text)) { MessageBox.Show("Please Fill all empty fields", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); break; } else { this.insertVendor(vendors, vendor); break; } } }
protected void insertVendor(TextBox[] vendors, frmVendor ven) { try { conn = new MySqlConnection(this.connection()); conn.Open(); using (command = new MySqlCommand("INSERT INTO vendor (vendor, address, contactPerson, telephoneNo, email, fax) VALUES (@vendor, @address, @contactperson, @telephone, @mail, @fax)", conn)) { command.Parameters.AddWithValue("@vendor", vendors[0].Text); command.Parameters.AddWithValue("@address", vendors[1].Text); command.Parameters.AddWithValue("@contactperson", vendors[2].Text); command.Parameters.AddWithValue("@telephone", vendors[3].Text); command.Parameters.AddWithValue("@mail", vendors[4].Text); command.Parameters.AddWithValue("@fax", vendors[5].Text); bool checkResult = (int)command.ExecuteNonQuery() > 0; if (checkResult == true) { MessageBox.Show("Successfully Save", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); ven.loadDataVendor(); } foreach (TextBox vendor in vendors) { vendor.Clear(); } } conn.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }