Beispiel #1
0
 public static void DemirbasEkle(DemirbasView demirbas)
 {
     using (var context = new DataContext2())
     {
         context.sp_DemirbasEkle(demirbas.Departman.DepartmanId, demirbas.Sirket.SirketId, demirbas.Urun.UrunId, demirbas.Demirbas.DemirbasAdedi, demirbas.Demirbas.DemirbasOzellikleri);
         context.SaveChanges();
     }
 }
Beispiel #2
0
        private void btn_DemirbasEkle_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrEmpty(cmb_Sirket.SelectedValue.ToString()))
                {
                    throw new Exception("Lütfen Sirket ve Departman Bilgilerini Kontrol Ediniz !");
                }
                if (string.IsNullOrEmpty(_productName) || _productBuyId == 0)
                {
                    throw new Exception("Lütfen Demirbaş Olacak Ürünü Seçiniz !");
                }
                if (string.IsNullOrEmpty(txt_Adet.Text) || short.Parse(txt_Adet.Text) == 0 || short.Parse(txt_Adet.Text) < 0)
                {
                    throw new Exception("Lütfen Adet Bilgisini Kontrol Ediniz !");
                }
                if (short.Parse(txt_Adet.Text) > _selectedQuantity)
                {
                    throw new Exception("Stok Miktarındakinden Fazla Ürün Demirbaşa Eklenemez ! !");
                }

                DemirbasView model = new DemirbasView
                {
                    Sirket   = { SirketId = Convert.ToInt32(cmb_Sirket.SelectedValue) },
                    Demirbas =
                    {
                        DemirbasOzellikleri = txt_Aciklama.Text,
                        DemirbasAdedi       = Convert.ToInt32(txt_Adet.Text)
                    },
                    Urun = { UrunId = _productBuyId }
                };
                DemirbasController.DemirbasEkle(model);
                MessageBox.Show("Demirbaş Başarıyla Eklendi !", "Demirbaş Eklendi !", MessageBoxButtons.OK, MessageBoxIcon.Information);
                GetStocks();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Dikkat !", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }