コード例 #1
0
        //SAVE İşlemini Yapıyor
        public void AddNewItem()
        {
            ExceptionCatcher.ExceptionFinder(() => {
                using (SDB sdbContext = new SDB())
                {
                    if (Urunentity == null)
                    {
                        Urun urun      = new Urun();
                        urun.UrunAd    = productName.Text;
                        urun.UrunFiyat = Convert.ToDecimal(productPrice.Text);
                        urun.UrunKod   = productCode.Text;
                        urun.UrunStok  = Convert.ToInt16(txtedit_productStok.Text);
                        urun.UrunKatID = ((Kategori)productCat_combobox.SelectedItem).KategoriID;
                        urun.UrunPic   = BL.ImageHelper.ConvertImageToByte(Pro_pic_url.Text);

                        pro_image.Source = new BitmapImage(new Uri(Pro_pic_url.Text));
                        DAL.DAL dal      = new DAL.DAL();
                        dal.NewRecord(urun);

                        FormContainer.Visibility            = Visibility.Collapsed;
                        GridControl_ProductList.ItemsSource = null;
                        GetUrunList();
                    }
                    else
                    {
                        Urun urun      = new Urun();
                        urun.UrunID    = Urunentity.UrunID;
                        urun.UrunAd    = productName.Text;
                        urun.UrunFiyat = Convert.ToDecimal(productPrice.Text);
                        urun.UrunKod   = productCode.Text;
                        urun.UrunStok  = Convert.ToInt16(txtedit_productStok.Text);
                        if (Urunentity.UrunPic != null)
                        {
                            urun.UrunPic = Urunentity.UrunPic;
                        }

                        urun.UrunKatID = ((Kategori)productCat_combobox.SelectedItem).KategoriID;
                        DAL.DAL dal    = new DAL.DAL();
                        dal.UpdateRecord(urun);
                        MainWindow window = (MainWindow)Window.GetWindow(this);
                        window.RibbonController();
                        FormContainer.Visibility            = Visibility.Collapsed;
                        GridControl_ProductList.ItemsSource = null;
                        GetUrunList();
                        ClearForm();
                    }
                }
            });
        }