private void btnAddAgency_Click(object sender, EventArgs e) { try { Vendor_DTO vendor = new Vendor_DTO(); vendor.VendorID = txtIDAgency.Text; vendor.VendorName = txtNameAgency.Text; vendor.VendorAddress = txtAddressOfAgency.Text; vendor.VendorPhone = txtNumberPhone.Text; if (txtIDAgency.Text == "" || txtNameAgency.Text == "" || txtAddressOfAgency.Text == "" || txtNumberPhone.Text == "") { XtraMessageBox.Show("You have to fullfill vendor information!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (Vendor_BUS.InsertVendor(vendor)) { XtraMessageBox.Show("Vendor Info has been inserted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); LoadVendorList(); ClearDisplay(); return; } } catch { XtraMessageBox.Show("Insert Info Failed!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public void btnDeleteAgency_Click(object sender, EventArgs e) { try { Vendor_DTO vendor = new Vendor_DTO(); vendor.VendorID = dtgvAgencyInfoList.CurrentRow.Cells["VendorID"].Value.ToString(); vendor.VendorName = txtNameAgency.Text; if (txtIDAgency.Text == "" || txtNameAgency.Text == "" || txtAddressOfAgency.Text == "" || txtNumberPhone.Text == "") { XtraMessageBox.Show("You have to choose at least one vendor to delete!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Warning); ClearDisplay(); return; } if (Vendor_BUS.DeleteVendor(vendor)) { LoadVendorList(); XtraMessageBox.Show("Vendor Info has been deleted sucessfully!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); ClearDisplay(); return; } }catch { XtraMessageBox.Show("Delete Info Failed!", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } }
public static bool UpdateVendor(Vendor_DTO vendor) { SqlConnection con = DataProvider.OpenConnection(); SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_updateVendor]", con); try { cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@VendorID", vendor.VendorID); cmd.Parameters.Add(p); p = new SqlParameter("@VendorName", vendor.VendorName); cmd.Parameters.Add(p); p = new SqlParameter("@Address", vendor.VendorAddress); cmd.Parameters.Add(p); p = new SqlParameter("@PhoneNo", vendor.VendorPhone); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.CloseConnection(con); return(true); } catch { DataProvider.CloseConnection(con); return(false); } }
public static bool DeleteVendor(Vendor_DTO vendor) { SqlConnection con = DataProvider.OpenConnection(); SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_deleteVendor]", con); try { cmd.CommandType = CommandType.StoredProcedure; SqlParameter p = new SqlParameter("@VendorID", vendor.VendorID); cmd.Parameters.Add(p); cmd.ExecuteNonQuery(); DataProvider.CloseConnection(con); return(true); } catch (Exception ex) { MessageBox.Show(ex.Message, "Notification", MessageBoxButtons.OK, MessageBoxIcon.Error); DataProvider.CloseConnection(con); return(false); } }
public static List <Vendor_DTO> LoadVendor() { List <Vendor_DTO> listVendor = new List <Vendor_DTO>(); SqlConnection con = DataProvider.OpenConnection(); SqlCommand cmd = new SqlCommand("[JEWELRYSTOREMGMT].[dbo].[usp_getVendorList]", con); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = cmd; DataTable dt = new DataTable(); da.Fill(dt); if (dt.Rows.Count == 0) { return(null); } for (int i = 0; i < dt.Rows.Count; i++) { Vendor_DTO vendor = new Vendor_DTO(); vendor.VendorID = dt.Rows[i]["VendorID"].ToString(); vendor.VendorName = dt.Rows[i]["VendorName"].ToString(); vendor.VendorAddress = dt.Rows[i]["Address"].ToString(); vendor.VendorPhone = dt.Rows[i]["PhoneNo"].ToString(); listVendor.Add(vendor); } DataProvider.CloseConnection(con); return(listVendor); }
public static bool DeleteVendor(Vendor_DTO vendor) { return(Vendor_DAL.DeleteVendor(vendor)); }
public static bool UpdateVendor(Vendor_DTO vendor) { return(Vendor_DAL.UpdateVendor(vendor)); }
public static bool InsertVendor(Vendor_DTO vendor) { return(Vendor_DAL.InsertVendor(vendor)); }