private void Button15_Click(object sender, EventArgs e) { try { var urunID = Convert.ToInt32(listView5.SelectedItems[0].SubItems[1].Text); var satilacakUrun = DalProduct.GetProduct(urunID); var EmptyArea = EmptyTextBoxControl(groupBox18); if (EmptyArea) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (satilacakUrun.Count >= Convert.ToInt32(textBox26.Text)) { var newSale = new Sale(); newSale.ProductID = satilacakUrun.ProductID; newSale.DateSold = DateTime.Now.Date; newSale.CustomerID = (int)comboBox4.SelectedValue; newSale.UserID = Form1.LoggedInUser.UserID; newSale.SoldUnit = Convert.ToInt32(textBox26.Text); var sorgu = DalSale.CUD(newSale, System.Data.Entity.EntityState.Added); if (sorgu) { satilacakUrun.Count -= Convert.ToInt32(textBox26.Text); DalProduct.CUD(satilacakUrun, System.Data.Entity.EntityState.Modified); GuncelleSatilacakListe(); MessageBox.Show("Ürün satıldı.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Satış gerçekleşmedi.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Stoklarda bu kadar ürün yok.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception) { } }
private void Button5_Click(object sender, EventArgs e) { try { var anyEmptyArea = EmptyTextBoxControl(groupBox6); if (anyEmptyArea) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { Product productToUpdate = new Product { ProductID = Convert.ToInt32(textBox29.Text), ProductName = textBox18.Text, CategoryID = (int)comboBox2.SelectedValue, PurchasePrice = Convert.ToInt32(textBox17.Text), SalePrice = Convert.ToInt32(textBox15.Text), Count = Convert.ToInt32(textBox12.Text), Description = textBox11.Text, }; var sorgu = DalProduct.CUD(productToUpdate, System.Data.Entity.EntityState.Modified); if (sorgu == true) { textBox29.Clear(); textBox18.Clear(); comboBox2.SelectedIndex = -1; textBox17.Clear(); textBox15.Clear(); textBox12.Clear(); textBox11.Clear(); GuncelleUrunler(); MessageBox.Show("Ürün güncellendi.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Ürün güncelleme başarısız.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } catch (Exception) { MessageBox.Show("Eksik bilgi girdiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }