Ejemplo n.º 1
0
        public void AddStock(/*out ErrorDto error*/)
        {
            Stock newStock = new Stock();

            if (CheckAddStockFields())
            {
                newStock.StockName        = addStockForm.mtxtStockName.Text;
                newStock.CurrentUnitPrice = Convert.ToDouble(addStockForm.mtxtUnitPrice.Text);
                newStock.Description      = addStockForm.mtxtStockDescription.Text;
                newStock.UserCompanyId    = mainForm.userCompanyId;

                if (addStockForm.mtxtStockStartingCount.Text != "0")
                {
                    ProductTransaction newProductTransaction = new ProductTransaction();

                    newProductTransaction.ProductNumber = int.Parse(addStockForm.mtxtStockStartingCount.Text);
                    newProductTransaction.Date          = DateTime.Now;
                    newProductTransaction.UnitPrice     = int.Parse(addStockForm.mtxtUnitPrice.Text);
                    newProductTransaction.Description   = addStockForm.mtxtStockDescription.Text;

                    newStock.ProductTransactions.Add(newProductTransaction);
                }

                bStock.Add(newStock, out ErrorDto error);

                if (error.ProcessResult)
                {
                    addStockForm.Close();
                    MessageBox.Show("Stok Ekleme Başarılı.", "İşlem Başarılı", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FillProductsToDataGrid(mainForm.userCompanyId);
                }
                else
                {
                    Error.Show(error);
                }
            }
        }