public void OpenForm() { //заполнение datagridview DataProducts.Load(); DataTable dt = DataProducts.DBOperation(); DataView dv = new DataView(dt); bsProducts.DataSource = dv; dgvProducts.DataSource = bsProducts; //фильтры if (dgvProducts.Rows.Count > 0) { cbManufacturer.DataSource = dv.ToTable(true, "Производитель"); cbManufacturer.DisplayMember = "Производитель"; cbManufacturer.Text = String.Empty; btDelManufacturer.Visible = false; cbName.DataSource = dv.ToTable(true, "Наименование"); cbName.DisplayMember = "Наименование"; cbName.Text = String.Empty; btDelName.Visible = false; cbCountry.DataSource = dv.ToTable(true, "Страна изготовления"); cbCountry.DisplayMember = "Страна изготовления"; cbCountry.Text = String.Empty; btDelCountry.Visible = false; cbAnimal.DataSource = dv.ToTable(true, "Животное"); cbAnimal.DisplayMember = "Животное"; cbAnimal.Text = String.Empty; btDelAnimal.Visible = false; } }
private void btDelete_Click(object sender, EventArgs e) { string del = dgvProducts.CurrentRow.Cells[0].ToString(); DataProducts.Delete(del); OpenForm(); }
public List <Product> ConsultProductEnabled() { List <Product> products = new List <Product>(); DataProducts product = new DataProducts(); products = product.ConsulProductsEnabled(); return(products); }
public List <DataProducts> ProductsGetByBrandID(int BrandID) { List <DataProducts> brandProducts = new List <DataProducts>(); try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand("dbo.sp_ProductsGetByBrandID", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@BrandID", BrandID); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { DataProducts dProduct = new DataProducts(); dProduct.ProductID = reader.GetInt32(0); dProduct.ProductName = reader.GetString(1); dProduct.SupplierID = reader.GetInt32(2); dProduct.SupplierName = reader.GetString(3); dProduct.CategoryID = reader.GetInt32(4); dProduct.CategoryName = reader.GetString(5); dProduct.BrandID = reader.GetInt32(6); dProduct.BrandName = reader.GetString(7); dProduct.RetailPrice = reader.GetDecimal(8); dProduct.WholeSalePrice = reader.GetDecimal(9); dProduct.OnSale = reader.GetBoolean(10); dProduct.Quantity = reader.GetInt32(11); dProduct.Color = reader.GetString(12); dProduct.Description = reader.GetString(13); dProduct.ProductCreateDate = reader.GetDateTime(14); dProduct.ProductPhotoURL = reader.GetString(15); dProduct.BrandPhotoURL = reader.GetString(16); brandProducts.Add(dProduct); } } } } catch (Exception exception) { Logger.LogError(exception); } return(brandProducts); }
public List <DataProducts> ProductsGetAll() { List <DataProducts> allProducts = new List <DataProducts>(); try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand("dbo.sp_ProductsGetAll", connection)) { command.CommandType = CommandType.StoredProcedure; SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { DataProducts dProducts = new DataProducts(); dProducts.ProductID = reader.GetInt32(0); dProducts.SupplierID = reader.GetInt32(1); dProducts.CategoryID = reader.GetInt32(2); dProducts.BrandID = reader.GetInt32(3); dProducts.ProductName = reader.GetString(4); dProducts.RetailPrice = reader.GetDecimal(5); dProducts.WholeSalePrice = reader.GetDecimal(6); dProducts.OnSale = reader.GetBoolean(7); dProducts.Quantity = reader.GetInt32(8); dProducts.Color = reader.GetString(9); dProducts.Description = reader.GetString(10); dProducts.ProductCreateDate = reader.GetDateTime(11); dProducts.ProductPhotoURL = reader.GetString(12); allProducts.Add(dProducts); } } } } catch (Exception exception) { Logger.LogError(exception); } return(allProducts); }
private void button1_Click(object sender, EventArgs e) { string Manufacturer = tbManufacturer.Text; string Name = tbName.Text; string Country = tbCountry.Text; string Supplier = tbSupplier.Text; string Animal = tbAnimal.Text; string Type = tbType.Text; string Price = tbPrice.Text; string Valid = tbValid.Text; string stock = tbStock.Text; string Expected = tbExpected.Text; DataProducts.Insert(Manufacturer, Name, Country, Supplier, Animal, Type, Price, Valid, stock, Expected); ProductsForm productform = new ProductsForm(); productform.OpenForm(); productform.Show(); this.Close(); }
public bool ProductsUpdateByID(DataProducts product) { bool noError = true; try { using (SqlConnection connection = new SqlConnection(ConnectionString)) { connection.Open(); using (SqlCommand command = new SqlCommand("dbo.sp_CartItemsUpdateQuantity", connection)) { command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@SupplierID", product.SupplierID); command.Parameters.AddWithValue("@CategoryID", product.CategoryID); command.Parameters.AddWithValue("@BrandID", product.BrandID); command.Parameters.AddWithValue("@ProductName", product.ProductName); command.Parameters.AddWithValue("@RetailPrice", product.RetailPrice); command.Parameters.AddWithValue("@WholeSalePrice", product.WholeSalePrice); command.Parameters.AddWithValue("@OnSale", product.OnSale); command.Parameters.AddWithValue("@Quantity", product.Quantity); command.Parameters.AddWithValue("@Color", product.Color); command.Parameters.AddWithValue("@Description", product.Description); command.Parameters.AddWithValue("@ProductCreateDate", product.ProductCreateDate); command.Parameters.AddWithValue("@ProductPhotoURL", product.ProductPhotoURL); command.ExecuteNonQuery(); } } } catch (Exception exception) { noError = false; Logger.LogError(exception); } return(noError); }
public DataProducts Map(ModelProducts mProduct) { DataProducts returnProduct = new DataProducts(); returnProduct.ProductID = mProduct.ProductID; returnProduct.ProductName = mProduct.ProductName; returnProduct.SupplierID = mProduct.SupplierID; returnProduct.SupplierName = mProduct.SupplierName; returnProduct.CategoryID = mProduct.CategoryID; returnProduct.CategoryName = mProduct.CategoryName; returnProduct.BrandID = mProduct.BrandID; returnProduct.BrandName = mProduct.BrandName; returnProduct.RetailPrice = mProduct.RetailPrice; returnProduct.WholeSalePrice = mProduct.WholeSalePrice; returnProduct.OnSale = mProduct.OnSale; returnProduct.Quantity = mProduct.Quantity; returnProduct.Color = mProduct.Color; returnProduct.Description = mProduct.Description; returnProduct.ProductCreateDate = mProduct.ProductCreateDate; returnProduct.ProductPhotoURL = mProduct.ProductPhotoURL; returnProduct.BrandPhotoURL = mProduct.BrandPhotoURL; return(returnProduct); }
public ProductsController() { DataProducts data = new DataProducts(); dataProducts = data; }