コード例 #1
0
        public int Update(PRDChemProdReq model, int userId)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        #region PI_Informaiton_Update
                        var CurrentRequisition = (from p in _context.PRD_ChemProdReq.AsEnumerable()
                                                  where p.RequisitionID == model.RequisitionID
                                                  select p).FirstOrDefault();

                        CurrentRequisition.RequisitionCategory = model.RequisitionCategory;
                        CurrentRequisition.RequisitionType     = model.RequisitionType;
                        CurrentRequisition.RequisitionFrom     = model.RequisitionFrom;
                        CurrentRequisition.RequisitionTo       = model.RequisitionTo;
                        CurrentRequisition.RequiredByTime      = model.RequiredByTime;
                        CurrentRequisition.ReqRaisedBy         = 1;
                        CurrentRequisition.ReqRaisedOn         = DalCommon.SetDate((model.ReqRaisedOn).ToString());

                        if (model.RecipeFor == 0)
                        {
                            CurrentRequisition.RecipeFor = null;
                        }
                        else
                        {
                            CurrentRequisition.RecipeFor = model.RecipeFor;
                        }
                        if (model.RecipeID == 0)
                        {
                            CurrentRequisition.RecipeID = null;
                        }
                        else
                        {
                            CurrentRequisition.RecipeID = model.RecipeID;
                        }

                        //CurrentRequisition.RecipeFor = model.RecipeFor;
                        //CurrentRequisition.RecipeID = model.RecipeID;
                        CurrentRequisition.ArticleNo = model.ArticleNo;

                        CurrentRequisition.Thickness = model.Thickness;
                        if (model.ThicknessUnit != null)
                        {
                            CurrentRequisition.ThicknessUnit = model.ThicknessUnit;
                        }
                        CurrentRequisition.LeatherSize = model.LeatherSize;
                        if (model.SizeUnit != null)
                        {
                            CurrentRequisition.SizeUnit = model.SizeUnit;
                        }
                        CurrentRequisition.Selection     = model.Selection;
                        CurrentRequisition.ProductionQty = model.ProductionQty;
                        CurrentRequisition.ModifiedBy    = userId;
                        CurrentRequisition.ModifiedOn    = DateTime.Now;

                        _context.SaveChanges();
                        #endregion

                        #region Update Requisition ItemList
                        if (model.RequisitionItemList != null)
                        {
                            foreach (var item in model.RequisitionItemList)
                            {
                                var checkRequisitionItem = (from i in _context.PRD_ChemProdReqItem.AsEnumerable()
                                                            where i.RequisitionItemID == item.RequisitionItemID
                                                            select i).Any();

                                #region New_Requisition_Insertion
                                if (!checkRequisitionItem)
                                {
                                    PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem();
                                    objItem.RequisitionID = model.RequisitionID;
                                    objItem.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }

                                    objItem.RequiredQty = item.RequiredQty;


                                    if (item.RequiredUnitName == null)
                                    {
                                        objItem.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }

                                    objItem.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);

                                    if (item.PackSizeName == null)
                                    {
                                        objItem.PackSize = null;
                                    }
                                    else
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        objItem.SizeUnit = null;
                                    }
                                    else
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }


                                    objItem.PackQty     = item.PackQty;
                                    objItem.ApproveQty  = item.ApproveQty;
                                    objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    //objItem.ManufacturerID = item.ManufacturerID;
                                    objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);
                                    objItem.SetOn      = DateTime.Now;
                                    objItem.SetBy      = userId;

                                    _context.PRD_ChemProdReqItem.Add(objItem);
                                    _context.SaveChanges();
                                }
                                #endregion

                                #region Existing_Requisition_Update
                                else
                                {
                                    var FoundRequisition = (from i in _context.PRD_ChemProdReqItem.AsEnumerable()
                                                            where i.RequisitionItemID == item.RequisitionItemID
                                                            select i).FirstOrDefault();

                                    FoundRequisition.RequisitionID = model.RequisitionID;
                                    FoundRequisition.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        FoundRequisition.SupplierID = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.SupplierID = item.SupplierID;
                                    }

                                    FoundRequisition.RequiredQty = item.RequiredQty;

                                    if (item.RequiredUnitName == null)
                                    {
                                        FoundRequisition.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }

                                    FoundRequisition.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    FoundRequisition.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);
                                    if (item.PackSizeName == null)
                                    {
                                        FoundRequisition.PackSize = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        FoundRequisition.SizeUnit = null;
                                    }
                                    else
                                    {
                                        FoundRequisition.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }
                                    FoundRequisition.PackQty     = item.PackQty;
                                    FoundRequisition.ApproveQty  = item.ApproveQty;
                                    FoundRequisition.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    FoundRequisition.ItemSource  = DalCommon.ReturnItemSource(item.ItemSource);
                                    FoundRequisition.ModifiedOn  = DateTime.Now;
                                    FoundRequisition.ModifiedBy  = userId;

                                    _context.SaveChanges();
                                }
                                #endregion
                            }
                        }

                        #endregion
                    }

                    transaction.Complete();
                }
                return(1);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
コード例 #2
0
        public List <PRDChemProdReqItem> GetTransactionItemList(long _TransactionID, string _IssueFrom)
        {
            using (var context = new BLC_DEVEntities())
            {
                var FinalStock = DalChemicalStock.ItemWiseStockInSpecificChemicalStore(Convert.ToByte(_IssueFrom));

                var RequisitionID = (from r in context.INV_StoreTransRequest.AsEnumerable()
                                     where r.TransactionID == _TransactionID
                                     select r.RequisitionID
                                     ).FirstOrDefault();

                var Data = (from i in context.INV_StoreTransItem.AsEnumerable()
                            where i.TransactionID == _TransactionID

                            from r in context.PRD_ChemProdReqItem.Where(x => x.RequisitionID == RequisitionID & x.ItemID == i.ItemID).DefaultIfEmpty()

                            join reqsize in context.Sys_Size on(r == null?null:r.PackSize) equals reqsize.SizeID into ReqPackSizes
                            from reqsize in ReqPackSizes.DefaultIfEmpty()

                            join reqsizeunit in context.Sys_Unit on(r == null ? null : r.SizeUnit) equals reqsizeunit.UnitID into ReqPackSizeUnits
                            from reqsizeunit in ReqPackSizeUnits.DefaultIfEmpty()

                            join requnit in context.Sys_Unit on(r == null ? 0 : r.RequisitionUnit) equals requnit.UnitID into ReqUnits
                            from requnit in ReqUnits.DefaultIfEmpty()

                            join s in FinalStock on i.ItemID equals s.ItemID into badhon
                            from item in badhon.DefaultIfEmpty()

                            join su in context.Sys_Unit on(item == null ? 0 : item.UnitID) equals su.UnitID into StockUnits
                            from su in StockUnits.DefaultIfEmpty()

                            join sup in context.Sys_Supplier on(item == null ? 0 : item.SupplierID) equals sup.SupplierID into badhon2
                            from finalitem in badhon2.DefaultIfEmpty()

                            from it in context.Sys_ChemicalItem.Where(x => x.ItemID == i.ItemID).DefaultIfEmpty()
                            from sup in context.Sys_Supplier.Where(x => x.SupplierID == i.SupplierID).DefaultIfEmpty()
                            from iu in context.Sys_Unit.Where(x => x.UnitID == i.TransactionUnit).DefaultIfEmpty()
                            from issuesize in context.Sys_Size.Where(x => x.SizeID == i.PackSize).DefaultIfEmpty()
                            from issuesizeunit in context.Sys_Unit.Where(x => x.UnitID == i.SizeUnit).DefaultIfEmpty()

                            select new PRDChemProdReqItem
                {
                    TransItemID = i.TransItemID,
                    ItemID = Convert.ToInt16(i.ItemID),
                    ItemName = (it == null ? null : it.ItemName),

                    StockQty = (item == null ? 0 : item.ClosingQty),
                    StockUnitName = (su == null ? null : su.UnitName),
                    SupplierID = (finalitem == null ? 0 : finalitem.SupplierID),
                    SupplierName = (finalitem == null ? null : finalitem.SupplierName),

                    PackSizeName = (reqsize == null ? null : reqsize.SizeName),
                    SizeUnitName = (reqsizeunit == null ? null : reqsizeunit.UnitName),
                    PackQty = (r == null ? 0 : Convert.ToInt16(r.PackQty)),
                    RequsitionQty = (r == null ? 0 : r.RequsitionQty),
                    RequisitionUnitName = (requnit == null ? null : requnit.UnitName),

                    IssuePackSize = Convert.ToByte(i.PackSize),
                    IssuePackSizeName = (issuesize == null ? null : issuesize.SizeName),
                    IssueSizeUnit = Convert.ToByte(i.SizeUnit),
                    IssueSizeUnitName = (issuesizeunit == null ? null : issuesizeunit.UnitName),
                    IssuePackQty = Convert.ToInt16(i.PackQty),
                    IssueQty = Convert.ToDecimal(i.TransactionQty),
                    IssueUnitName = (iu == null ? null : iu.UnitName),

                    ItemSource = DalCommon.ReturnItemSource(i.ItemSource)
                }).ToList();

                foreach (var item in Data)
                {
                    if (item.ItemSource == "From Order")
                    {
                        item.PackSizeName        = null;
                        item.SizeUnitName        = null;
                        item.PackQty             = 0;
                        item.RequsitionQty       = 0;
                        item.RequisitionUnitName = null;
                    }
                }
                return(Data);
            }
        }
コード例 #3
0
        public int Save(PRDChemProdReq model, int userId, string pageUrl)
        {
            int CurrentRequisitionID = 0;

            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        var GetRequisitionNo = DalCommon.GetPreDefineNextCodeByUrl(pageUrl);

                        if (GetRequisitionNo != null)
                        {
                            #region New_Requisition_Insert

                            PRD_ChemProdReq objRequisition = new PRD_ChemProdReq();

                            objRequisition.RequisitionNo       = GetRequisitionNo;
                            objRequisition.RequisitionCategory = model.RequisitionCategory;
                            objRequisition.RequisitionType     = model.RequisitionType;
                            objRequisition.RequisitionFrom     = model.RequisitionFrom;
                            objRequisition.RequisitionTo       = model.RequisitionTo;
                            objRequisition.RequiredByTime      = model.RequiredByTime;
                            objRequisition.ReqRaisedBy         = userId;
                            objRequisition.ReqRaisedOn         = DalCommon.SetDate((model.ReqRaisedOn).ToString());
                            if (model.RecipeFor == 0)
                            {
                                objRequisition.RecipeFor = null;
                            }
                            else
                            {
                                objRequisition.RecipeFor = model.RecipeFor;
                            }
                            if (model.RecipeID == 0)
                            {
                                objRequisition.RecipeID = null;
                            }
                            else
                            {
                                objRequisition.RecipeID = model.RecipeID;
                            }
                            objRequisition.ArticleNo = model.ArticleNo;

                            objRequisition.Thickness = model.Thickness;
                            if (model.ThicknessUnit != null)
                            {
                                objRequisition.ThicknessUnit = model.ThicknessUnit;
                            }
                            objRequisition.LeatherSize = model.LeatherSize;
                            if (model.SizeUnit != null)
                            {
                                objRequisition.SizeUnit = model.SizeUnit;
                            }
                            objRequisition.Selection     = model.Selection;
                            objRequisition.ProductionQty = model.ProductionQty;

                            objRequisition.RequisitionState  = "RNG";
                            objRequisition.RequisitionStatus = "PND";
                            objRequisition.RecordStatus      = "NCF";
                            objRequisition.SetBy             = userId;
                            objRequisition.SetOn             = DateTime.Now;



                            //if (model.BuyerAddressID == 0)
                            //    objPI.BeneficiaryAddressID = null;
                            //else
                            //    objPI.BeneficiaryAddressID = model.BuyerAddressID;

                            _context.PRD_ChemProdReq.Add(objRequisition);
                            _context.SaveChanges();
                            CurrentRequisitionID = objRequisition.RequisitionID;
                            #endregion

                            #region Item Insert
                            if (model.RequisitionItemList != null)
                            {
                                foreach (var item in model.RequisitionItemList)
                                {
                                    PRD_ChemProdReqItem objItem = new PRD_ChemProdReqItem();
                                    objItem.RequisitionID = CurrentRequisitionID;
                                    objItem.ItemID        = Convert.ToInt32(item.ItemID);

                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }
                                    //objItem.SupplierID = item.SupplierID;

                                    objItem.RequiredQty = item.RequiredQty;


                                    if (item.RequiredUnitName == null)
                                    {
                                        objItem.RequiredUnit = null;
                                    }
                                    else
                                    {
                                        objItem.RequiredUnit = DalCommon.GetUnitCode(item.RequiredUnitName);
                                    }


                                    objItem.RequsitionQty   = Convert.ToDecimal(item.RequsitionQty);
                                    objItem.RequisitionUnit = DalCommon.GetUnitCode(item.RequisitionUnitName);

                                    if (item.PackSizeName == null)
                                    {
                                        objItem.PackSize = null;
                                    }
                                    else
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    //objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);

                                    if (item.SizeUnitName == null)
                                    {
                                        objItem.SizeUnit = null;
                                    }
                                    else
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }
                                    //objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);


                                    objItem.PackQty     = item.PackQty;
                                    objItem.ApproveQty  = item.ApproveQty;
                                    objItem.ApproveUnit = DalCommon.GetUnitCode(item.ApproveUnitName);
                                    //objItem.ManufacturerID = item.ManufacturerID;
                                    objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);
                                    objItem.SetOn      = DateTime.Now;
                                    objItem.SetBy      = userId;

                                    _context.PRD_ChemProdReqItem.Add(objItem);
                                    _context.SaveChanges();
                                }
                            }
                            #endregion
                        }
                    }
                    transaction.Complete();
                }
                return(CurrentRequisitionID);
            }
            catch (Exception e)
            {
                return(0);
            }
        }
コード例 #4
0
        public int Update(INVStoreTrans model, int userId)
        {
            try
            {
                using (TransactionScope transaction = new TransactionScope())
                {
                    using (_context)
                    {
                        #region Transaction_Informaiton_Update
                        var CurrentTransaction = (from p in _context.INV_StoreTrans
                                                  where p.TransactionID == model.TransactionID
                                                  select p).FirstOrDefault();

                        if (model.AdjustmentType == "Addition")
                        {
                            CurrentTransaction.TransactionCategory = "RCV";
                        }
                        else
                        {
                            CurrentTransaction.TransactionCategory = "ISU";
                        }
                        if (model.PageName == "Adjustment")
                        {
                            CurrentTransaction.TransactionType = "ADI";
                        }
                        else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Addition")
                        {
                            CurrentTransaction.TransactionType = "ADR";
                        }
                        else if (model.PageName == "InventoryAdjustment" & model.AdjustmentType == "Subtraction")
                        {
                            CurrentTransaction.TransactionType = "ADI";
                        }
                        else
                        {
                            CurrentTransaction.TransactionType = "ITP";
                            CurrentTransaction.TransactionTo   = model.TransactionTo;
                        }

                        CurrentTransaction.Remarks = model.Remark;



                        CurrentTransaction.TransactionDate = DalCommon.SetDate(model.TransactionDate);
                        CurrentTransaction.ModifiedBy      = userId;
                        CurrentTransaction.ModifiedOn      = DateTime.Now;
                        //_context.SaveChanges();

                        #endregion

                        #region Request Infromation Update

                        if (model.PageName != "InventoryAdjustment")
                        {
                            if (model.PageName == "Adjustment")
                            {
                                var CurrentRequest = (from r in _context.INV_StoreTransRequest
                                                      where r.TransactionID == model.TransactionID
                                                      select r).FirstOrDefault();

                                CurrentRequest.ReqFromDate = DalCommon.SetDate(model.ReqFromDate);
                                CurrentRequest.ReqToDate   = DalCommon.SetDate(model.ReqToDate);
                                CurrentRequest.ModifiedBy  = userId;
                                CurrentRequest.ModifiedOn  = DateTime.Now;
                                CurrentRequest.Remark      = model.Remark;
                            }
                            else
                            {
                                var CurrentRequest = (from r in _context.INV_StoreTransRequest
                                                      where r.TransactionID == model.TransactionID &&
                                                      r.RequisitionID == model.RefTransactionID
                                                      select r).FirstOrDefault();
                                CurrentRequest.Remark     = model.Remark;
                                CurrentRequest.ModifiedBy = userId;
                                CurrentRequest.ModifiedOn = DateTime.Now;
                            }
                        }



                        #endregion

                        #region Update Requisition ItemList

                        if (model.InvStoreTransItemList != null)
                        {
                            foreach (var item in model.InvStoreTransItemList)
                            {
                                var checkRequisitionItem = (from i in _context.INV_StoreTransItem
                                                            where i.TransItemID == item.TransItemID
                                                            select i).Any();

                                #region New_Item_Insertion
                                if (!checkRequisitionItem)
                                {
                                    INV_StoreTransItem objItem = new INV_StoreTransItem();

                                    objItem.TransactionID = model.TransactionID;
                                    objItem.ItemID        = item.ItemID;
                                    if (item.SupplierID == 0)
                                    {
                                        objItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        objItem.SupplierID = item.SupplierID;
                                    }
                                    objItem.TransactionQty = item.TransactionQty;

                                    objItem.TransactionUnit = DalCommon.GetUnitCode(item.TransactionUnitName);


                                    if (item.PackSizeName != null)
                                    {
                                        objItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    if (item.SizeUnitName != null)
                                    {
                                        objItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }


                                    objItem.PackQty    = item.PackQty;
                                    objItem.ItemSource = DalCommon.ReturnItemSource(item.ItemSource);

                                    objItem.SetOn = DateTime.Now;
                                    objItem.SetBy = userId;

                                    _context.INV_StoreTransItem.Add(objItem);
                                    //_context.SaveChanges();
                                }
                                #endregion

                                #region Existing_Item_Update
                                else
                                {
                                    var FoundItem = (from i in _context.INV_StoreTransItem
                                                     where i.TransItemID == item.TransItemID
                                                     select i).FirstOrDefault();

                                    FoundItem.ItemID = item.ItemID;
                                    if (item.SupplierID == 0)
                                    {
                                        FoundItem.SupplierID = null;
                                    }
                                    else
                                    {
                                        FoundItem.SupplierID = item.SupplierID;
                                    }
                                    FoundItem.TransactionQty = item.TransactionQty;

                                    FoundItem.TransactionUnit = DalCommon.GetUnitCode(item.TransactionUnitName);


                                    if (item.PackSizeName != null)
                                    {
                                        FoundItem.PackSize = DalCommon.GetSizeCode(item.PackSizeName);
                                    }

                                    if (item.SizeUnitName != null)
                                    {
                                        FoundItem.SizeUnit = DalCommon.GetUnitCode(item.SizeUnitName);
                                    }


                                    FoundItem.PackQty    = item.PackQty;
                                    FoundItem.ModifiedBy = userId;
                                    FoundItem.ModifiedOn = DateTime.Now;

                                    //_context.SaveChanges();
                                }
                                #endregion
                            }
                        }

                        #endregion

                        _context.SaveChanges();
                    }

                    transaction.Complete();
                }
                return(1);
            }
            catch (Exception e)
            {
                return(0);
            }
        }