private void Clear_Click(object sender, EventArgs e) { ProductName.Clear(); productID.Clear(); VendorID.Clear(); Amount.Clear(); }
private void Delete_Click(object sender, EventArgs e) { try { Connect connectObj = new Connect(); con = connectObj.connect(); SqlCommand cmd = new SqlCommand("DELETE FROM VENDOR WHERE VID = @vid", con); cmd.Parameters.AddWithValue("@vid", VendorID.Text); int i = cmd.ExecuteNonQuery(); //If count is equal to 1, than show frmMain form if (i != 0) { MessageBox.Show("Customer Deletion Successful!"); } else { MessageBox.Show("Customer Deletion Failed"); } con.Close(); //Clear the fields VendorID.Clear(); VendorName.Clear(); } catch (Exception ex) { MessageBox.Show("Vendor Not found"); } }
private void clear_Click(object sender, EventArgs e) { VendorName.Clear(); VendorAddress.Clear(); PhoneNumber.Clear(); email.Clear(); VendorID.Clear(); }
private void clear_Click(object sender, EventArgs e) { VendorName.Clear(); VendorAddress.Clear(); VendorPhoneNo.Clear(); Email.Clear(); VendorID.Clear(); VendorName2.Clear(); }
private void submit_Click(object sender, EventArgs e) { if (VendorName.Text == "" || VendorAddress.Text == "" || PhoneNO.Text == "" || Email.Text == "" || VendorID.Text == "") { MessageBox.Show("Please provide all the details", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (PhoneNO.Text.Length != 10) { MessageBox.Show("Enter valid Phone number", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Connect connectObj = new Connect(); con = connectObj.connect(); SqlCommand cmd = new SqlCommand("Insert into VENDOR (vid,vname,address,phone_number,email) values(@id,@vname,@address,@phno,@email);", con); cmd.Parameters.AddWithValue("@id", VendorID.Text); cmd.Parameters.AddWithValue("@vname", VendorName.Text); cmd.Parameters.AddWithValue("@phno", Convert.ToInt64(PhoneNO.Text)); cmd.Parameters.AddWithValue("@address", VendorAddress.Text); cmd.Parameters.AddWithValue("@email", Email.Text); int i = cmd.ExecuteNonQuery(); //If count is equal to 1, than show frmMain form if (i != 0) { MessageBox.Show("Vendor Insertion Successful!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Vendor Insertion Failed", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); //Clear all the fields. VendorName.Clear(); VendorAddress.Clear(); PhoneNO.Clear(); Email.Clear(); VendorID.Clear(); } catch (Exception ex) { MessageBox.Show("Failed!! Try with Different ID!!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (con != null) { con.Close(); } } }
private void update_Click(object sender, EventArgs e) { if (VendorName.Text == "" || VendorAddress.Text == "" || PhoneNumber.Text == "" || email.Text == "" || VendorID.Text == "") { MessageBox.Show("Please provide all the details", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Connect connectObj = new Connect(); con = connectObj.connect(); SqlCommand cmd = new SqlCommand("UPDATE VENDOR SET vname = @vname,address = @address,phone_number = @phno,email = @email WHERE vid = @id;", con); cmd.Parameters.AddWithValue("@id", VendorID.Text); cmd.Parameters.AddWithValue("@vname", VendorName.Text); cmd.Parameters.AddWithValue("@phno", Convert.ToInt64(PhoneNumber.Text)); cmd.Parameters.AddWithValue("@address", VendorAddress.Text); cmd.Parameters.AddWithValue("@email", email.Text); int i = cmd.ExecuteNonQuery(); //If count is equal to 1, than show frmMain form if (i != 0) { MessageBox.Show("Vendor Updation Successful!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Vendor Updation Failed", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); } catch (Exception ex) { MessageBox.Show("Vendor not found", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (con != null) { con.Close(); } } VendorName.Clear(); VendorAddress.Clear(); PhoneNumber.Clear(); email.Clear(); VendorID.Clear(); }
private void Submit_Click(object sender, EventArgs e) { if (ProductName.Text == "" || VendorID.Text == "" || Amount.Text == "" || ProductID.Text == "") { MessageBox.Show("Please provide all the details", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Connect connectObj = new Connect(); con = connectObj.connect(); SqlCommand cmd = new SqlCommand("Insert into PRODUCT (PID,PNAME,AMOUNT,VID) values(@pid,@pname,@amount,@vid);", con); cmd.Parameters.AddWithValue("@pid", ProductID.Text); cmd.Parameters.AddWithValue("@pname", ProductName.Text); cmd.Parameters.AddWithValue("@vid", VendorID.Text); cmd.Parameters.AddWithValue("@amount", Amount.Text); int i = cmd.ExecuteNonQuery(); //If count is equal to 1, than show frmMain form if (i != 0) { MessageBox.Show("Product Insertion Successful!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Product Insertion Failed", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information); } con.Close(); ProductName.Clear(); VendorID.Clear(); Amount.Clear(); ProductID.Clear(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { if (con != null) { con.Close(); } } }
private void Update_Click(object sender, EventArgs e) { if (ProductName.Text == "" || productID.Text == "" || VendorID.Text == "" || Amount.Text == "") { MessageBox.Show("Please provide all the details", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { Connect conObj = new Connect(); con = conObj.connect(); SqlCommand cmd = new SqlCommand("UPDATE PRODUCT SET pname = @pname,amount = @amount,vid = @vid WHERE pid = @id;", con); cmd.Parameters.AddWithValue("@id", productID.Text); cmd.Parameters.AddWithValue("@pname", ProductName.Text); cmd.Parameters.AddWithValue("@vid", VendorID.Text); cmd.Parameters.AddWithValue("@amount", Amount.Text); //cid += 1; int i = cmd.ExecuteNonQuery(); //If count is equal to 1, than show frmMain form if (i != 0) { MessageBox.Show("Product Updation Successful!", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Product Updation Failed", "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } con.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Captions", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (con != null) { con.Close(); } } ProductName.Clear(); productID.Clear(); VendorID.Clear(); Amount.Clear(); }