示例#1
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);
            }
        }