Пример #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validationResult() == true)
            {
                var    demandMaster = dbContext.ItemDemandMaster.Find(_itemDemandMasterId);
                double quantity     = Convert.ToDouble(txtQuantity.EditValue == "" ? 0 : txtQuantity.EditValue);
                if (_stockDetailId == 0)
                {
                    string barcode            = BarcodeHelper.BarcodeVerify(txtBarcode.EditValue.ToString());
                    var    barcodeStockDetail = StockHelper.GetBarcodeStocksWithStore(barcode, (int)lueStore.EditValue);
                    if (barcodeStockDetail == null)
                    {
                        MessageBox.Show("Ürün Bulunamadı !");
                        txtBarcode.EditValue = "";
                        txtBarcode.Focus();
                        return;
                    }
                    var stockDetail = new StockDetail();
                    stockDetail.STOCKDETAIL_BARCODE_ID = barcode;
                    stockDetail.STOCKDETAIL_MASTER_ID  = _stockMasterId;
                    stockDetail.STOCKDETAIL_STORE_ID   = (int)lueStore.EditValue;
                    stockDetail.STOCKDETAIL_ITEM_ID    = barcodeStockDetail.STOCKDETAIL_ITEM_ID;
                    stockDetail.STOCKDETAIL_RACK_ID    = barcodeStockDetail.STOCKDETAIL_RACK_ID;
                    stockDetail.STOCKDETAIL_QUANTITY   = quantity * -1;
                    dbContext.StockDetail.Add(stockDetail);
                    dbContext.SaveChanges();

                    var stockDetailSecond = new StockDetail();
                    stockDetailSecond.STOCKDETAIL_BARCODE_ID    = barcode;
                    stockDetailSecond.STOCKDETAIL_MASTER_ID     = _stockMasterId;
                    stockDetailSecond.STOCKDETAIL_STORE_ID      = demandMaster.Project.Company.COMPANY_STORE_ID.Value;
                    stockDetailSecond.STOCKDETAIL_ITEM_ID       = barcodeStockDetail.STOCKDETAIL_ITEM_ID;
                    stockDetailSecond.STOCKDETAIL_RACK_ID       = barcodeStockDetail.STOCKDETAIL_RACK_ID;
                    stockDetailSecond.STOCKDETAIL_QUANTITY      = quantity;
                    stockDetailSecond.STOCKDETAIL_PRIVATEVALUE1 = string.IsNullOrEmpty(txtCableStart.Text) ? 0 : (double)txtCableStart.EditValue;
                    stockDetailSecond.STOCKDETAIL_PRIVATEVALUE2 = string.IsNullOrEmpty(txtCableEnd.Text) ? 0 : (double)txtCableEnd.EditValue;
                    stockDetailSecond.STOCKDETAIL_REF_ID        = stockDetail.ID;
                    dbContext.StockDetail.Add(stockDetailSecond);
                    dbContext.SaveChanges();
                }
                else
                {
                    var existStockDetail = dbContext.StockDetail.FirstOrDefault(x => x.ID == _stockDetailId);
                    existStockDetail.STOCKDETAIL_QUANTITY = quantity * -1;
                    var existStockDetailSecond = dbContext.StockDetail.FirstOrDefault(x => x.STOCKDETAIL_REF_ID == _stockDetailId);
                    existStockDetailSecond.STOCKDETAIL_QUANTITY      = quantity;
                    existStockDetailSecond.STOCKDETAIL_PRIVATEVALUE1 = string.IsNullOrEmpty(txtCableStart.Text) ? 0 : (double)txtCableStart.EditValue;
                    existStockDetailSecond.STOCKDETAIL_PRIVATEVALUE2 = string.IsNullOrEmpty(txtCableEnd.Text) ? 0 : (double)txtCableEnd.EditValue;
                    dbContext.SaveChanges();
                }
                ClearControl();
            }
        }
Пример #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (validationResult() == true)
            {
                if (_stockDetailId == 0)
                {
                    string barcode            = BarcodeHelper.BarcodeVerify(txtBarcode.EditValue.ToString());
                    var    barcodeStockDetail = BarcodeHelper.GetBarcodeDetail(barcode, (int)lueStore.EditValue);
                    if (barcodeStockDetail == null)
                    {
                        MessageBox.Show("Ürün Bulunamadı !");
                        txtBarcode.EditValue = "";
                        txtBarcode.Focus();
                        return;
                    }

                    var stockDetail = new StockDetail();
                    stockDetail.STOCKDETAIL_BARCODE_ID    = barcode;
                    stockDetail.STOCKDETAIL_MASTER_ID     = _stockMasterId;
                    stockDetail.STOCKDETAIL_STORE_ID      = (int)lueTargetStore.EditValue;
                    stockDetail.STOCKDETAIL_ITEM_ID       = barcodeStockDetail.ItemId;
                    stockDetail.STOCKDETAIL_RACK_ID       = barcodeStockDetail.RackId;
                    stockDetail.STOCKDETAIL_QUANTITY      = 0;
                    stockDetail.STOCKDETAIL_PRIVATEVALUE1 = string.IsNullOrEmpty(txtCableStart.Text) ? 0 : Convert.ToDouble(txtCableStart.EditValue);
                    stockDetail.STOCKDETAIL_PRIVATEVALUE2 = string.IsNullOrEmpty(txtCableEnd.Text) ? 0 : Convert.ToDouble(txtCableEnd.EditValue);
                    dbContext.StockDetail.Add(stockDetail);
                }
                else
                {
                    if (txtCableStart.Text != "")
                    {
                        double cableStart = Convert.ToDouble(txtCableStart.Text);
                        double cableEnd   = Convert.ToDouble(txtCableEnd.Text);
                        txtQuantity.Text = (cableEnd - cableStart).ToString();
                    }
                    double quantity         = Convert.ToDouble(txtQuantity.EditValue == "" ? 0 : txtQuantity.EditValue);
                    var    existStockDetail = dbContext.StockDetail.FirstOrDefault(x => x.ID == _stockDetailId);
                    existStockDetail.STOCKDETAIL_QUANTITY      = quantity;
                    existStockDetail.STOCKDETAIL_PRIVATEVALUE1 = string.IsNullOrEmpty(txtCableStart.Text) ? 0 : Convert.ToDouble(txtCableStart.EditValue);
                    existStockDetail.STOCKDETAIL_PRIVATEVALUE2 = string.IsNullOrEmpty(txtCableEnd.Text) ? 0 : Convert.ToDouble(txtCableEnd.EditValue);
                }
                dbContext.SaveChanges();
                LoadData();
                btnDelete.Enabled       = false;
                _stockDetailId          = 0;
                txtBarcode.EditValue    = "";
                txtQuantity.EditValue   = "";
                txtCableStart.EditValue = "";
                txtCableEnd.EditValue   = "";
                txtBarcode.Focus();
            }
        }
Пример #3
0
 private void txtBarcode_KeyPress(object sender, KeyPressEventArgs e)
 {
     if (e.KeyChar == (char)Keys.Return)
     {
         string barcode            = BarcodeHelper.BarcodeVerify(txtBarcode.EditValue.ToString());
         var    barcodeStockDetail = BarcodeHelper.GetBarcodeDetail(barcode, (int)lueStore.EditValue);
         if (barcodeStockDetail == null)
         {
             MessageBox.Show("Ürün Bulunamadı !");
             txtBarcode.EditValue = "";
             txtBarcode.Focus();
             return;
         }
         if (_stockDetailId == 0)
         {
             var stockDetail = new StockDetail();
             stockDetail.STOCKDETAIL_BARCODE_ID    = barcode;
             stockDetail.STOCKDETAIL_MASTER_ID     = _stockMasterId;
             stockDetail.STOCKDETAIL_STORE_ID      = (int)lueTargetStore.EditValue;
             stockDetail.STOCKDETAIL_ITEM_ID       = barcodeStockDetail.ItemId;
             stockDetail.STOCKDETAIL_RACK_ID       = barcodeStockDetail.RackId;
             stockDetail.STOCKDETAIL_QUANTITY      = 0;
             stockDetail.STOCKDETAIL_PRIVATEVALUE1 = string.IsNullOrEmpty(txtCableStart.Text) ? 0 : Convert.ToDouble(txtCableStart.EditValue);
             stockDetail.STOCKDETAIL_PRIVATEVALUE2 = string.IsNullOrEmpty(txtCableEnd.Text) ? 0 : Convert.ToDouble(txtCableEnd.EditValue);
             dbContext.StockDetail.Add(stockDetail);
             dbContext.SaveChanges();
         }
         LoadData();
         btnDelete.Enabled       = false;
         _stockDetailId          = 0;
         txtBarcode.EditValue    = "";
         txtQuantity.EditValue   = "";
         txtCableStart.EditValue = "";
         txtCableEnd.EditValue   = "";
         txtBarcode.Focus();
     }
 }