private void btnGuncelle_Click(object sender, EventArgs e) { myparameters.Clear(); myparameters.Add(new SqlParameter()); myparameters.Add(new SqlParameter()); myparameters.Add(new SqlParameter()); myparameters.Add(new SqlParameter()); ProductDataAccess ser = new ProductDataAccess(connection, command, myparameters); var product = new Product(); product.ProductId = (listBox1.SelectedItem as Product).ProductId; product.ProductName = txtUrunAdi.Text; product.Price = decimal.Parse(txtFiyat.Text); product.UnitInStock = int.Parse(txtStok.Text); if (ser.Update(product) > 0) { MessageBox.Show("Update gerceklesti"); string commandText = "Select ProductID,ProductName,UnitsInStock,UnitPrice from Products where CategoryID=@CategoryId"; myparameters.Clear(); myparameters.Add(new SqlParameter()); DataAccessService service = new DataAccessService(new ProductDataAccess(connection, command, myparameters)); var plist = service.GetProductsByCategory(commandText, (cmbCat2.SelectedItem as Category).CategoryID); ListBoxBindEt(plist); } else { MessageBox.Show("Update Gerceklesemedi"); } }
private void Form2_Load(object sender, EventArgs e) { btnGuncelle.Enabled = false; DataAccessService service = new DataAccessService(new CategoryDataAccess(connection, command)); string commandText = "SELECT CategoryID,CategoryName,Description,Picture FROM Categories"; var catList = service.GetAllCategories(commandText); Combo2BindEt(catList); Combo1BindEt(catList); cmbCat2.SelectedValueChanged += cmbCat2_SelectedValueChanged; }
private void btnSil_Click(object sender, EventArgs e) { myparameters.Clear(); myparameters.Add(new SqlParameter()); DataAccessService service = new DataAccessService(new ProductDataAccess(connection, command, myparameters)); service.DeleteProduct((listBox1.SelectedItem as Product).ProductId); txtFiyat.Text = string.Empty; txtStok.Text = string.Empty; txtUrunAdi.Text = string.Empty; RefreshProducts(); }
private void RefreshProducts() { DataAccessService service = new DataAccessService(new ProductDataAccess(connection, command, myparameters)); myparameters.Clear(); myparameters.Add(new SqlParameter()); string commandText = "Select ProductID,ProductName,UnitsInStock,UnitPrice from Products where CategoryID=@CategoryId"; var plist = service.GetProductsByCategory(commandText, (cmbCat2.SelectedItem as Category).CategoryID); ListBoxBindEt(plist); }
private void btnEkle_Click(object sender, EventArgs e) { Product product = new Product(); product.ProductName = txtUrunAdi.Text; product.Price = decimal.Parse(txtFiyat.Text); product.UnitInStock = int.Parse(txtStok.Text); product.CategoryId = (cmbCat2.SelectedItem as Category).CategoryID; myparameters.Clear(); myparameters.Add(new SqlParameter()); myparameters.Add(new SqlParameter()); myparameters.Add(new SqlParameter()); myparameters.Add(new SqlParameter()); DataAccessService service = new DataAccessService(new ProductDataAccess(connection, command, myparameters)); service.AddProduct(product); RefreshProducts(); }