Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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)
            {
            }
        }
Esempio n. 3
0
        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)
            {
            }
        }