Example #1
0
        private void registeredCustomer_Click(object sender, EventArgs e)
        {
            if (!(dataGridView1.Rows.Count <= 0))
            {
                int customerID = SelectCustomer.Show();

                if (!(customerID == -1))
                {
                    var query = (from q in data.Customer
                                 where q.CustomerID == customerID
                                 select q).First();
                    MessageDöndür.MessageResult messageResult = MessageDöndür.Message("Müsteri :" + query.CustomerName + " " + query.CustomerSurname + "\nAdlı Müşteriye " + totalPrice + " TL Tutarında işlem Yapmayı Onaylıyormusunuz", "Satış Onayı", MessageDöndür.MessageIcon.Information, MessageDöndür.MessageButton.YesNoCancel);
                    if (MessageDöndür.MessageResult.Yes == messageResult)
                    {
                        Model.Sale satis = new Model.Sale();
                        satis.SaleDate          = DateTime.Now.Date;
                        satis.PaymentMethodSale = 3;
                        satis.TotalPrice        = totalPrice;
                        satis.CustomerID        = query.CustomerID;
                        satis.TotalDiscount     = Convert.ToDecimal(totalDiscount);
                        data.Sale.InsertOnSubmit(satis);
                        data.SubmitChanges();
                        foreach (DataGridViewRow row in dataGridView1.Rows)
                        {//TODO:Ürün Stokta Varmı Yokmu Kontrol Edilecek++
                            Model.BarcodeSystemDataContext pdata          = new Model.BarcodeSystemDataContext();
                            Model.OpeationProduct          satilanurunler = new Model.OpeationProduct();

                            satilanurunler.SaleProduct = (from q in data.Sale
                                                          orderby q.SaleID descending
                                                          select q).First().SaleID;
                            satilanurunler.ProductID       = (int)(row.Cells["ProductID"].Value);
                            satilanurunler.ProductDiscount = Convert.ToDecimal(row.Cells["ProductDiscount"].Value);
                            satilanurunler.ProductPrice    = Convert.ToDecimal((row.Cells["ProductSalePrice"].Value.ToString().Split(' ')[0]));
                            pdata.OpeationProduct.InsertOnSubmit(satilanurunler);
                            pdata.SubmitChanges();
                        }
                        Model.CustomerProcces satisislemi = new Model.CustomerProcces();
                        satisislemi.CustomerID   = query.CustomerID;
                        satisislemi.ProccesDate  = DateTime.Now;
                        satisislemi.ProccesType  = 1;
                        satisislemi.ProccesPrice = totalPrice;
                        query.CustomerAccount   += totalPrice;
                        data.CustomerProcces.InsertOnSubmit(satisislemi);
                        data.SubmitChanges();
                        totalDiscount   = 0;
                        totalPrice      = 0;
                        productDiscount = 0;
                        lblName.Text    = "Ürün Adı : null";
                        lblPrice.Text   = "Ürün Fiyat : null";
                        lblTotal.Text   = "Toplam Fiyat : null";
                        datagridviewID  = 1;
                        dataGridView1.Rows.Clear();
                        MessageDöndür.Message("Satış İşlemi başarıyla Gerçekleştirildi.", "İşlem Onaylandı", MessageDöndür.MessageIcon.OK, MessageDöndür.MessageButton.OK);
                    }
                }
                else
                {
                    MessageDöndür.Message("Müşteri Seçimi Başarısız Oldu !", "Müşteri Seçim Başarısız .", MessageDöndür.MessageIcon.Eror, MessageDöndür.MessageButton.OK);
                }
            }
            else
            {
                MessageDöndür.Message("Ürün Listesi Boş Olduğu İçin Çıkış yapılamıyor", "DataGridView Boş", MessageDöndür.MessageIcon.Eror, MessageDöndür.MessageButton.OK);
            }
        }
Example #2
0
 /// <summary>
 /// Customer Sayfası Açılır Datagridviewden Müşteri Seçilir Bu Methodla Müşterinin ID'si geri Döner
 /// </summary>
 /// <returns>CustomerID</returns>
 public static int Show()
 {
     sc = new SelectCustomer();
     sc.ShowDialog();
     return(selectedid);
 }