Exemple #1
0
        public TblStockInformation AddStockInformation(ERPContext context, TblInvoiceMasterReturn invoiceReturn, TblBranch _branch, TblProduct _product, decimal?qty, decimal?rate)
        {
            try
            {
                //using(ERPContext context=new ERPContext())
                //{
                var _stockInformation = new TblStockInformation
                {
                    BranchId      = _branch.BranchId,
                    BranchCode    = _branch.BranchCode,
                    ShiftId       = invoiceReturn.ShiftId,
                    VoucherNo     = invoiceReturn.VoucherNo,
                    VoucherTypeId = invoiceReturn.VoucherTypeId,
                    InvoiceNo     = invoiceReturn.InvoiceReturnNo,
                    ProductId     = _product.ProductId,
                    ProductCode   = _product.ProductCode,
                    OutwardQty    = qty,
                    Rate          = rate
                };

                context.TblStockInformation.Add(_stockInformation);
                if (context.SaveChanges() > 0)
                {
                    return(_stockInformation);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #2
0
        private TblStockInformation AddStockInformation(ERPContext context, TblPurchaseInvoice invoice, TblBranch _branch, TblProduct _product, decimal?qty, decimal?rate)
        {
            try
            {
                //using(ERPContext context=new ERPContext())
                //{
                var _stockInformation = new TblStockInformation();

                _stockInformation.BranchId      = _branch.BranchId;
                _stockInformation.BranchCode    = _branch.BranchCode;
                _stockInformation.ShiftId       = invoice.ShiftId;
                _stockInformation.VoucherNo     = invoice.VoucherNo;
                _stockInformation.VoucherTypeId = invoice.VoucherTypeId;
                _stockInformation.InvoiceNo     = invoice.PurchaseInvNo;
                _stockInformation.ProductId     = _product.ProductId;
                _stockInformation.ProductCode   = _product.ProductCode;
                _stockInformation.InwardQty     = qty;
                _stockInformation.Rate          = rate;

                context.TblStockInformation.Add(_stockInformation);
                if (context.SaveChanges() > 0)
                {
                    return(_stockInformation);
                }

                #region Comment
                //var _stockInformation = new TblStockInformation();

                //_stockInformation.BranchId = _branch.BranchId;
                //_stockInformation.BranchCode = _branch.BranchCode;
                //_stockInformation.ShiftId = invoice.ShiftId;
                //_stockInformation.VoucherNo = invoice.VoucherNo;
                //_stockInformation.VoucherTypeId = invoice.VoucherTypeId;
                //_stockInformation.InvoiceNo = invoice.InvoiceNo;
                //_stockInformation.ProductId = _product.ProductId;
                //_stockInformation.ProductCode = _product.ProductCode;
                //_stockInformation.OutwardQty = invdtl.Qty > 0 ? invdtl.Qty : invdtl.FQty;
                //_stockInformation.Rate = invdtl.Rate;

                //repo.TblStockInformation.Add(_stockInformation);
                //repo.SaveChanges();
                #endregion

                return(null);
                //  }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Exemple #3
0
        private TblStockInformation AddStockInformation(ERPContext context, TblStockTransferDetail stockTransferDetail, TblStockTransferMaster stockTransfertMaster, string branchCode, bool isFromBranch, decimal?voucherTypeID = 29)
        {
            try
            {
                TblStockInformation stockInformation = new TblStockInformation();
                try { stockInformation.BranchId = Convert.ToDecimal(branchCode ?? "0"); } catch { };
                stockInformation.BranchCode      = branchCode;
                stockInformation.UserId          = stockTransfertMaster.UserId;
                stockInformation.ShiftId         = stockTransfertMaster.ShiftId;
                stockInformation.TransactionDate = stockTransfertMaster.StockTransferDate;
                stockInformation.VoucherNo       = string.Empty;
                stockInformation.VoucherTypeId   = voucherTypeID;
                stockInformation.InvoiceNo       = stockTransfertMaster.StockTransferNo;
                stockInformation.ProductId       = stockTransferDetail.ProductId;
                stockInformation.ProductCode     = stockTransferDetail.ProductCode;
                stockInformation.Rate            = stockTransferDetail.Rate;
                if (isFromBranch)
                {
                    stockInformation.OutwardQty = stockTransferDetail.FQty > 0 ? stockTransferDetail.FQty : stockTransferDetail.Qty;
                }
                else
                {
                    stockInformation.InwardQty = stockTransferDetail.FQty > 0 ? stockTransferDetail.FQty : stockTransferDetail.Qty;
                }

                stockInformation.OutwardQty = stockInformation.OutwardQty ?? 0;
                stockInformation.InwardQty  = stockInformation.InwardQty ?? 0;

                context.TblStockInformation.Add(stockInformation);
                if (context.SaveChanges() > 0)
                {
                    return(stockInformation);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }