public static void DeleteEntity(Vendors vendor) { using (SqlConnection cn = new SqlConnection(Common.ConnectionString)) { string proc = "pr_Vendor_Delete"; using (SqlCommand cmd = new SqlCommand(proc, cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@vendor_ID", vendor.vendor_ID); cn.Open(); cmd.ExecuteNonQuery(); } } }
private void Delete() { Vendors vendor = vendorBindingSource.Current as Vendors; // (BindingList<Vendors>)userBindingSource.DataSource; //Vendors vendor = OrderList[userBindingSource.Position]; decimal vendor_ID = vendor.vendor_ID; DialogResult dlg = MessageBox.Show(string.Format("Are you sure you want to delete Vendor # {0}?", vendor_ID.ToString())); if (dlg == System.Windows.Forms.DialogResult.OK) { Vendors.DeleteEntity(vendor); vendorBindingSource.RemoveCurrent(); MessageBox.Show(string.Format("Vendor # {0} was deleted.", vendor_ID.ToString())); } }
private void Save() { vendorBindingSource.EndEdit(); Vendors vendor = vendorBindingSource.Current as Vendors; //BindingList<Vendors> OrderList = (BindingList<Vendors>)userBindingSource.DataSource; //Vendors Vendors = OrderList[userBindingSource.Position]; Vendors.SaveEntity(vendor); BindingList <Vendors> vendorList = new BindingList <Vendors>(Vendors.GetEntityList()); vendorBindingSource.DataSource = vendorList; MessageBox.Show("Vendor was saved."); }
private void toolBtnFindOrderNumber_Click(object sender, EventArgs e) { List <Vendors> vendorList = new List <Vendors>(vendorBindingSource.DataSource as BindingList <Vendors>); VendorFilter vendorFilter = new VendorFilter(Convert.ToInt32(toolTxtFindOrderNumber.Text)); //Predicate<Vendors> filterByOrderID = new Predicate<Vendors>(orderFilter.MatchesOrderID); Predicate <Vendors> filterByOrderID = new Predicate <Vendors>(vendorFilter.BeginsWithOrderID); Vendors vendor = vendorList.Find(filterByOrderID); if (vendor == null) { MessageBox.Show("No matching Vendor found", "Not Found", MessageBoxButtons.OK); } else { int index = vendorBindingSource.IndexOf(vendor); vendorBindingSource.Position = index; } }
private static Vendors AddEntity(Vendors vendor) { int vendor_ID = 0; using (SqlConnection cn = new SqlConnection(Common.ConnectionString)) { string proc = "pr_Vendor_Add"; using (SqlCommand cmd = new SqlCommand(proc, cn)) { cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@v_name", vendor.v_name); cmd.Parameters.AddWithValue("@v_contactperson", vendor.v_contactperson); cmd.Parameters.AddWithValue("@v_address", vendor.v_address); cmd.Parameters.AddWithValue("@v_phone", vendor.v_phone); cmd.Parameters.AddWithValue("@v_mobile", vendor.v_mobile); cmd.Parameters.AddWithValue("@v_zip", vendor.v_zip); cmd.Parameters.AddWithValue("@v_fax", vendor.v_fax); cmd.Parameters.AddWithValue("@v_email", vendor.v_email); cmd.Parameters.AddWithValue("@v_status", vendor.v_status); cmd.Parameters.AddWithValue("@v_city", vendor.v_city); cmd.Parameters.AddWithValue("@v_state", vendor.v_state); cmd.Parameters.AddWithValue("@v_country", vendor.v_country); cmd.Parameters.AddWithValue("@v_regno", vendor.v_regno); cmd.Parameters.AddWithValue("@rEGdATE", vendor.rEGdATE); cmd.Parameters.AddWithValue("@VendorCode", vendor.VendorCode); cmd.Parameters.AddWithValue("@AVL", vendor.AVL); cmd.Parameters.AddWithValue("@paymentTerms", vendor.paymentTerms); cmd.Parameters.Add(new SqlParameter("@vendor_ID", SqlDbType.Decimal)); cmd.Parameters["@vendor_ID"].Direction = ParameterDirection.Output; cn.Open(); cmd.ExecuteNonQuery(); vendor_ID = Convert.ToInt32(cmd.Parameters["@vendor_ID"].Value); } vendor = GetEntity(vendor_ID); } return(vendor); }
private void SetupBindings() { BindingList <Vendors> vendorList = new BindingList <Vendors>(Vendors.GetEntityList()); vendorBindingSource.DataSource = vendorList; }
public bool BeginsWithOrderID(Vendors vendor) { return(vendor.vendor_ID.ToString().StartsWith(vendor_ID.ToString())); }
public bool MatchesOrderID(Vendors vendor) { return(vendor.vendor_ID == vendor_ID); }