示例#1
0
 private void button2_Click(object sender, EventArgs e)
 {
     //Stok ekle Butonu
     if (!String.IsNullOrEmpty(textBox2.Text))
     {
         Product p = HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
         p.stock += Convert.ToInt32(textBox2.Text);
         var   degistir = HelperProduct.CUD(p, System.Data.Entity.EntityState.Modified);
         Stock s        = new Stock()
         {
             productID   = p.productID,
             dateOfAdded = DateTime.Now,
             count       = Convert.ToInt32(textBox2.Text)
         };
         var ekle = HelperStock.CUD(s, System.Data.Entity.EntityState.Added);
         if (ekle.Item2)
         {
             MessageBox.Show("Stok ekleme başarılı.");
         }
         else
         {
             MessageBox.Show("Stok eklenemedi");
         }
         Yenile();
         DataGrid2Yenile();
         textBox2.Clear();
     }
     else
     {
         MessageBox.Show("Lütfen adet giriniz.");
     }
 }
示例#2
0
 private void button4_Click(object sender, EventArgs e)
 {
     //Ürün düzenle butonu
     if (!String.IsNullOrEmpty(textBox2.Text) && !String.IsNullOrEmpty(textBox3.Text))
     {
         Product p = HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
         p.productName = textBox2.Text;
         p.unitPrice   = Convert.ToDouble(textBox3.Text);
         p.supplierID  = Convert.ToInt32(comboBox2.SelectedValue);
         p.categoryID  = Convert.ToInt32(comboBox3.SelectedValue);
         p.discount    = Convert.ToInt32(textBox4.Text);
         var degistir = HelperProduct.CUD(p, System.Data.Entity.EntityState.Modified);
         if (degistir.Item2)
         {
             MessageBox.Show("Güncelleme başarılı.");
         }
         else
         {
             MessageBox.Show("Güncelleme yapılamadı.");
         }
         Yenile();
     }
     else
     {
         MessageBox.Show("Lütfen tüm alanları doldurunuz.");
     }
 }
示例#3
0
 private void button3_Click(object sender, EventArgs e)
 {
     //Ürün silme butonu
     if (!String.IsNullOrEmpty(textBox2.Text) && !String.IsNullOrEmpty(textBox3.Text))
     {
         var a = MessageBox.Show(" Silmek istediğinize emin misiniz?", "Bilgilendirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
         if (a == DialogResult.Yes)
         {
             Product p = HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
             p.IsActive = false;
             var b = HelperProduct.CUD(p, System.Data.Entity.EntityState.Modified);
             if (b.Item2)
             {
                 MessageBox.Show("Silme işlemi başarılı");
             }
             else
             {
                 MessageBox.Show("Silme yapılamadı");
             }
         }
         Yenile();
     }
     else
     {
         MessageBox.Show("Lütfen silinecek ürünü seçiniz.");
     }
 }
示例#4
0
        private void dataGridView1_SelectionChanged(object sender, EventArgs e)
        {
            dataGridView1.ClearSelection();
            Product  p = HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
            Category c = HelperCategory.GetByID(p.categoryID);
            Supplier s = HelperSupplier.GetByID(p.supplierID);

            textBox2.Text   = p.productName;
            textBox3.Text   = p.unitPrice.ToString();
            textBox4.Text   = p.discount.ToString();
            comboBox2.Text  = s.companyName;
            comboBox3.Text  = c.categoryName;
            button6.Enabled = true;
            button7.Enabled = true;
        }
示例#5
0
        private void button7_Click(object sender, EventArgs e)
        {
            //Satışı devam ettir
            if (!String.IsNullOrEmpty(textBox2.Text) && !String.IsNullOrEmpty(textBox3.Text))
            {
                Product p = HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value));
                p.discontinued = false;

                var degistir = HelperProduct.CUD(p, System.Data.Entity.EntityState.Modified);
                if (degistir.Item2)
                {
                    MessageBox.Show("Güncelleme başarılı.");
                }
                else
                {
                    MessageBox.Show("Güncelleme yapılamadı.");
                }
                Yenile();
            }
            else
            {
                MessageBox.Show("Lütfen seçim yapınız.");
            }
        }
        private void button2_Click(object sender, EventArgs e)
        {
            //Satışı tamamla butonu
            //toplam tutar hesapla
            int totalPrice = 0;

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                totalPrice += Convert.ToInt32(dataGridView1.Rows[i].Cells[5].Value);
            }
            label1.Text = totalPrice.ToString();

            Cashier cashier = HelperCashier.GetByName(label3.Text);

            customer = HelperCustomer.GetByID(customer.CustomerID);
            Order or = new Order()
            {
                customerID = customer.CustomerID,
                orderDate  = DateTime.Now,
                cashierID  = cashier.cashierID,
                totalPrice = Convert.ToInt32(label1.Text),
            };
            var ekle = HelperOrder.CUD(or, System.Data.Entity.EntityState.Added);

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                p.Add(HelperProduct.GetByID(Convert.ToInt32(dataGridView1.Rows[i].Cells[1].Value)));
            }
            int k = 0;

            foreach (var item in p)
            {
                for (; k < dataGridView1.Rows.Count;)
                {
                    item.stock -= Convert.ToInt32(dataGridView1.Rows[k].Cells[4].Value);
                    var a = HelperProduct.CUD(item, System.Data.Entity.EntityState.Modified);
                    break;
                }
                k++;
            }

            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                //fiş için yapılanlar
                List <string> temp       = new List <string>();
                string        ad         = dataGridView1.Rows[i].Cells[0].Value.ToString();
                string        id         = dataGridView1.Rows[i].Cells[1].Value.ToString();
                string        birimFiyat = dataGridView1.Rows[i].Cells[2].Value.ToString();
                string        indirim    = dataGridView1.Rows[i].Cells[3].Value.ToString();
                string        adet       = dataGridView1.Rows[i].Cells[4].Value.ToString();
                string        tutar      = dataGridView1.Rows[i].Cells[5].Value.ToString();
                temp.Add(ad);
                temp.Add(id);
                temp.Add(birimFiyat);
                temp.Add(indirim);
                temp.Add(adet);
                temp.Add(tutar);
                receipt.Add(temp);
            }
            foreach (var item in p)
            {
                ord = new OrderDetail();

                ord.orderID   = or.orderID;
                ord.productID = item.productID;
                ord.unitPrice = item.unitPrice;
                for (; j < dataGridView1.Rows.Count; j++)
                {
                    ord.count = Convert.ToInt32(dataGridView1.Rows[j].Cells[4].Value);
                    break;
                }
                j++;

                var ekle2 = HelperOrderDetail.CUD(ord, System.Data.Entity.EntityState.Added);
            }

            ReceiptForm rpf = new ReceiptForm(receipt, customer, label1.Text);

            rpf.Show();
            this.Hide();
        }