double karZararHesapla() { var sales = DalSale.GetSaleModels(); var karZarar = 0; foreach (var sale in sales) { karZarar += sale.SoldUnit * (sale.Product.SalePrice - sale.Product.PurchasePrice); } return(karZarar); }
private void TextBox24_TextChanged(object sender, EventArgs e) { try { listView4.Items.Clear(); List <SaleModel> searchResult = new List <SaleModel>(); if (radioButton1.Checked) { searchResult = DalSale.GetSaleModels(textBox24.Text, null, null, dateTimePicker1.Value.Date, dateTimePicker2.Value.Date); } else if (radioButton2.Checked) { searchResult = DalSale.GetSaleModels(null, textBox24.Text, null, dateTimePicker1.Value.Date, dateTimePicker2.Value.Date); } else if (radioButton3.Checked) { searchResult = DalSale.GetSaleModels(null, null, textBox24.Text, dateTimePicker1.Value.Date, dateTimePicker2.Value.Date); } else { textBox24.Clear(); MessageBox.Show("Arama türünü seçiniz.", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Warning); } foreach (var sale in searchResult) { ListViewItem c = new ListViewItem(); c.SubItems.Add(sale.Customer.Name + " " + sale.Customer.Surname); c.SubItems.Add(sale.Product.Category.CategoryName); c.SubItems.Add(sale.Product.ProductName); c.SubItems.Add(sale.SoldUnit.ToString()); c.SubItems.Add(sale.Product.SalePrice.ToString()); c.SubItems.Add(sale.DateSold.ToShortDateString()); c.SubItems.Add(sale.User.Name + " " + sale.User.Surname); listView4.Items.Add(c); } } catch (Exception) { } }