Beispiel #1
0
        public bool UpdateProductionBatchStatus(List <ProductionMaster> producList)
        {
            foreach (var item in producList)
            {
                _entity.Configuration.LazyLoadingEnabled = false;
                ProductionMaster productionMaster =
                    _entity.ProductionMaster.FirstOrDefault(
                        x => x.ProductionId == item.ProductionId && x.MobileCode == item.MobileCode);


                if (productionMaster != null)
                {
                    if (!string.IsNullOrEmpty(item.AgingBatchNumber))
                    {
                        productionMaster.AgingBatchNumber = item.AgingBatchNumber;
                    }


                    _entity.Entry(productionMaster).State = EntityState.Modified;
                    _entity.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Beispiel #2
0
 public List <ProductionMaster> ProductionMasterInfo(ProductionMaster productionMaster)
 {
     try
     {
         ISelectingCommon iDataAccessSelect = new DALGetCommonSelecting();
         return(iDataAccessSelect.ProductionMasterInfo(productionMaster));
     }
     catch (Exception ex) { throw ex; }
 }
Beispiel #3
0
 public Result InsertFunctionalQcStatus(ProductionMaster productionMaster)
 {
     try
     {
         return(productionManager.InsertFunctionalQcStatus(productionMaster));
     }
     catch (Exception ex)
     {
         return(new Result {
             IsSuccess = false, Message = ex.Message
         });
     }
 }
Beispiel #4
0
 public bool InsertFunctionalQcStatus(ProductionMaster productionMaster)
 {
     try
     {
         _entity.ProductionMaster.Add(productionMaster);
         _entity.SaveChanges();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(true);
 }
Beispiel #5
0
        public List <ProductionMaster> ProductionMasterInfo(ProductionMaster productionMaster)
        {
            var productionMasterList = new List <ProductionMaster>();

            try
            {
                productionMasterList = _CommonManager.ProductionMasterInfo(productionMaster);
            }
            catch (Exception ex)
            {
            }

            return(productionMasterList);
        }
        public List <ProductionMaster> ProductionMasterInfo(ProductionMaster productionMaster)
        {
            List <ProductionMaster> list;

            try
            {
                list = _wcmsEntities.ProductionMaster
                       .WhereIf(productionMaster.ProjectId != null, x => x.ProjectId == productionMaster.ProjectId)
                       .WhereIf(productionMaster.MobileCode != null, x => x.MobileCode == productionMaster.MobileCode)
                       .WhereIf(productionMaster.Imei1 != null, x => x.Imei1 == productionMaster.Imei1)
                       .WhereIf(productionMaster.Imei2 != null, x => x.Imei2 == productionMaster.Imei2)
                       .WhereIf(productionMaster.Passed != null, x => x.Passed == productionMaster.Passed)
                       .WhereIf(productionMaster.QcStation != null, x => x.QcStation == productionMaster.QcStation)
                       .WhereIf(productionMaster.AgingBatchNumber != null, x => x.AgingBatchNumber == productionMaster.AgingBatchNumber)


                       .WhereIf(productionMaster.FunctionalBy != null, x => x.FunctionalBy == productionMaster.FunctionalBy)
                       .WhereIf(productionMaster.FunctionalAD != null, x => x.FunctionalAD == productionMaster.FunctionalAD)
                       .WhereIf(productionMaster.AestheticBy != null, x => x.AestheticBy == productionMaster.AestheticBy)
                       .WhereIf(productionMaster.AestheticAD != null, x => x.AestheticAD == productionMaster.AestheticAD)
                       .WhereIf(productionMaster.AgingBy != null, x => x.AgingBy == productionMaster.AgingBy)
                       .WhereIf(productionMaster.AgingAD != null, x => x.AgingAD == productionMaster.AgingAD)
                       .WhereIf(productionMaster.PackagingBy != null, x => x.AgingBy == productionMaster.PackagingBy)
                       .WhereIf(productionMaster.PackagingAD != null, x => x.PackagingAD == productionMaster.PackagingAD)
                       .WhereIf(productionMaster.PackagingAstheticBy != null, x => x.PackagingAstheticBy == productionMaster.PackagingAstheticBy)
                       .WhereIf(productionMaster.PackagingAstheticAD != null, x => x.PackagingAstheticAD == productionMaster.PackagingAstheticAD)
                       .WhereIf(productionMaster.PackagingOQCBy != null, x => x.PackagingOQCBy == productionMaster.PackagingOQCBy)
                       .WhereIf(productionMaster.PackagingOQCAD != null, x => x.PackagingOQCAD == productionMaster.PackagingOQCAD)



                       .AsNoTracking().ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(list);
        }
Beispiel #7
0
        public Result InsertFunctionalQcStatus(ProductionMaster productionMaster)
        {
            try
            {
                IProduction _IProductionInsert = new WCMS_DAL_Production();
                using (
                    var transaction = new TransactionScope(TransactionScopeOption.Required,
                                                           ApplicationState.TransactionOptions))
                {
                    Result _Result = new Result();
                    _Result.IsSuccess = _IProductionInsert.InsertFunctionalQcStatus(productionMaster);

                    if (_Result.IsSuccess)
                    {
                        transaction.Complete();
                    }
                    return(_Result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Beispiel #8
0
        public void Create(ProductionMasterViewModel ProductionMasterViewModel, ProductionDetailsViewModel[] productionDetailsViewModels, int?intStoreId)
        {
            int?StorId             = null;
            int?SubStorId          = null;
            int?SubSubStorId       = null;
            int?SubSubSubStorId    = null;
            int?SubSubSubSubStorId = null;

            if (intStoreId >= 1000 && intStoreId < 2000)
            {
                StorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubStorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubSubStorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubSubSubStorId = intStoreId;
            }
            else if (intStoreId >= 2000 && intStoreId < 3000)
            {
                SubSubSubSubStorId = intStoreId;
            }



            ProductionMaster Producionheader = new ProductionMaster();

            Producionheader.ProductId           = ProductionMasterViewModel.ProductId;
            Producionheader.ProductionQuantity  = ProductionMasterViewModel.ProductionQuantity;
            Producionheader.ProductPrice        = ProductionMasterViewModel.ProductPrice;
            Producionheader.Productiondate      = DateTime.Now;
            Producionheader.StoreId             = StorId;
            Producionheader.SubStoreId          = SubStorId;
            Producionheader.SubSubStoreId       = SubSubStorId;
            Producionheader.SubSubSubStoreId    = SubSubSubStorId;
            Producionheader.SubSubSubSubStoreId = SubSubSubSubStorId;

            unitOfWork.ProductionMasterRepository.Insert(Producionheader);
            unitOfWork.Save();

            var Productionhdid = Producionheader.ProductionMasterId;

            foreach (var items in productionDetailsViewModels)
            {
                var productionDetails = new ProductionDetails
                {
                    ProductionMasterId = Productionhdid,
                    ItemId             = items.ItemId,
                    ItemQuantity       = items.ItemQuantity,
                    ItemCost           = items.ItemCost,
                    SubTotal           = items.SubTotal
                };
                unitOfWork.ProductionDetailsRepository.Insert(productionDetails);
                unitOfWork.Save();


                var avalableqty = unitOfWork.InventoryMasterRepository.Get().Join(unitOfWork.InventoryDetailRepository.Get(),
                                                                                  (invd => invd.Inv_HD_ID),
                                                                                  (invh => invh.Inv_HD_ID),
                                                                                  ((invd, invh) => new { Inventorymaster = invd, inventorydetails = invh })).Where(k => k.Inventorymaster.StoreId == StorId || k.Inventorymaster.SubStoreId == SubStorId || k.Inventorymaster.SubSubStoreId == SubSubStorId || k.Inventorymaster.SubSubSubStoreId == SubSubSubStorId || k.Inventorymaster.SubSubSubSubStoreId == SubSubSubSubStorId).Where(i => i.inventorydetails.ItemId == items.ItemId).Select(q => q.inventorydetails.AvailableQty).Sum();
                var itemqty = Convert.ToDecimal(items.ItemQuantity);



                var invdetails = (from p in unitOfWork.InventoryDetailRepository.Get()
                                  join m in unitOfWork.InventoryMasterRepository.Get() on p.Inv_HD_ID equals m.Inv_HD_ID
                                  where p.AvailableQty > 0 && p.ItemId == items.ItemId && (m.StoreId == StorId || m.SubStoreId == SubStorId || m.SubSubStoreId == SubSubStorId || m.SubSubSubStoreId == SubSubSubStorId || m.SubSubSubSubStoreId == SubSubSubSubStorId)
                                  select new
                {
                    InvDetailsId = p.Inv_Details_ID,
                }).ToList();



                foreach (var invid in invdetails)
                {
                    if (itemqty > 0)
                    {
                        var invdetailidqty = unitOfWork.InventoryDetailRepository.Get().Where(m => m.Inv_Details_ID == invid.InvDetailsId).Select(l => l.AvailableQty).SingleOrDefault();

                        if (itemqty <= invdetailidqty)
                        {
                            var result = unitOfWork.InventoryDetailRepository.Get().SingleOrDefault(b => b.Inv_Details_ID == invid.InvDetailsId);
                            if (result != null)
                            {
                                result.AvailableQty = invdetailidqty - itemqty;
                                unitOfWork.Save();
                                itemqty = Convert.ToDecimal(items.ItemQuantity) - itemqty;
                            }
                        }
                        else
                        {
                            var result = unitOfWork.InventoryDetailRepository.Get().SingleOrDefault(b => b.Inv_Details_ID == invid.InvDetailsId);
                            if (result != null)
                            {
                                result.AvailableQty = result.AvailableQty - invdetailidqty;
                                unitOfWork.Save();
                                itemqty = itemqty - invdetailidqty;
                            }
                        }
                    }
                }
            }


            var InventoryMaster = new InventoryMaster
            {
                ProductionMasterId = Productionhdid,
                StoreId            = ProductionMasterViewModel.StoreId,
                CreateDate         = DateTime.Now
            };

            unitOfWork.InventoryMasterRepository.Insert(InventoryMaster);
            unitOfWork.Save();

            var invId = InventoryMaster.Inv_HD_ID;

            InventoryDetail inventoryDetail = new InventoryDetail();

            inventoryDetail.Inv_HD_ID      = invId;
            inventoryDetail.ProductId      = ProductionMasterViewModel.ProductId;
            inventoryDetail.TransactionQty = ProductionMasterViewModel.ProductionQuantity;
            inventoryDetail.AvailableQty   = ProductionMasterViewModel.ProductionQuantity;
            inventoryDetail.PO_Price       = ProductionMasterViewModel.ProductPrice / ProductionMasterViewModel.ProductionQuantity;

            unitOfWork.InventoryDetailRepository.Insert(inventoryDetail);
            unitOfWork.Save();



            //foreach (var items in productionDetailsViewModels)
            //{
            //    //InventoryDetail lst = new InventoryDetail();

            //    var ProductionQty = items.ItemQuantity;

            //    var inventoryQty = unitOfWork.InventoryDetailRepository.Get().Where(m => m.ItemId == items.ItemId).Select(k => k.TransactionQty).Sum();

            //    var updateqty = inventoryQty - ProductionQty;

            //    if (inventoryQty > ProductionQty)
            //    {
            //        //var jj = (from p in unitOfWork.InventoryDetailRepository.Get() join m in unitOfWork.InventoryMasterRepository.Get() on p.Inv_HD_ID equals m.Inv_HD_ID  where p.ItemId == items.ItemId && m.StoreId == ProductionMasterViewModel.StoreId select p).SingleOrDefault();

            //        var kk = unitOfWork.InventoryDetailRepository.Get().SingleOrDefault(b => b.ItemId == items.ItemId);
            //        //foreach (var f in jj)
            //        //{
            //        //    lst.Inv_Details_ID = f.Inv_Details_ID;
            //        //    lst.Inv_HD_ID = f.Inv_HD_ID;
            //        //    lst.ItemId = f.ItemId;
            //        //    lst.UnitId = f.UnitId;
            //        //    lst.MethodId = f.MethodId;
            //        //    lst.DateOfExpired = f.DateOfExpired;
            //        //    lst.DateOfNextMaintainance = f.DateOfNextMaintainance;
            //        //    lst.TransactionQty = inventoryQty - ProductionQty;

            //        //}
            //        kk.AvailableQty = updateqty;

            //        unitOfWork.Save();
            //    }


            //}
        }
Beispiel #9
0
        public Result GenerateImeiBatch(long userId, long projectId, string imeiCode)
        {
            IProduction iProductionSelect = new WCMS_DAL_Production();
            var         result            = new Result();

            try
            {
                var productionMasterInfo = _isSelectingCommon.ProductionMasterInfoByImei(imeiCode).FirstOrDefault();
                if (productionMasterInfo != null && productionMasterInfo.Passed == "Y")
                {
                    var isExists =
                        iProductionSelect.GetPackagingBatchInfo(new tblPackagingBatch()
                    {
                        MobileCode = productionMasterInfo.MobileCode
                    }).Any();


                    if (!isExists)
                    {
                        var packaginBatch = new tblPackagingBatch();

                        packaginBatch.ProjectId  = productionMasterInfo.ProjectId;
                        packaginBatch.LineId     = productionMasterInfo.LineId;
                        packaginBatch.MobileCode = productionMasterInfo.MobileCode;
                        packaginBatch.Imei1      = productionMasterInfo.Imei1;
                        packaginBatch.Imei2      = productionMasterInfo.Imei2;
                        packaginBatch.AddedBy    = userId;
                        packaginBatch.AddedDate  = DateTime.Now;
                        result.IsSuccess         = iProductionSelect.GenerateImeiBatch(packaginBatch);
                        if (result.IsSuccess)
                        {
                            var packagingBatchList = iProductionSelect.CountPackagingBatch(projectId, userId).ToList();

                            if (packagingBatchList.Count == 100)
                            {
                                var pckResult            = new Result();
                                var packageBatchList     = new List <tblPackagingBatch>();
                                var productionList       = new List <ProductionMaster>();
                                var packagingBatchNumber = PackagingRandomString();

                                foreach (var items in packagingBatchList)
                                {
                                    var packagingBatch   = new tblPackagingBatch();
                                    var productionMaster = new ProductionMaster();

                                    packagingBatch.MobileCode  = items.MobileCode;
                                    packagingBatch.Imei1       = items.Imei1;
                                    packagingBatch.Imei2       = items.Imei2;
                                    packagingBatch.SystemBatch = "PKG-" + packagingBatchNumber.Trim();

                                    packagingBatch.BatchCreatedBy   = userId;
                                    packagingBatch.BatchCreatedDate = DateTime.Now;

                                    packageBatchList.Add(packagingBatch);   //packBatchList

                                    //adding productonMaster
                                    productionMaster.MobileCode     = items.MobileCode;
                                    productionMaster.Imei1          = items.Imei1;
                                    productionMaster.Imei2          = items.Imei2;
                                    productionMaster.OQCBatchNumber = "PKG-" + packagingBatchNumber.Trim();
                                    productionList.Add(productionMaster);
                                }


                                pckResult.IsSuccess = iProductionSelect.UpdatePackagingBatchStatus(packageBatchList);


                                if (pckResult.IsSuccess)

                                {
                                    var rslt = new Result
                                    {
                                        IsSuccess = _iProductionInsert.UpdateQcStatusHistory(productionList)
                                    };
                                }
                            }
                        }
                    }
                    else
                    {
                        result.Message = "Already Exists ! duplicate IMEI ";
                        return(result);
                    }
                }


                else
                {
                    result.Message = "No data found with this IMEI / Not Passed ";
                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Beispiel #10
0
        public Result InsertAgingBatchQcInfo(List <ProductionMaster> productionAgingQc, string batchStatus, long userId, long lineId, long projectId)
        {
            IProduction iProductionSelect = new WCMS_DAL_Production();
            IProduction iProductionInsert = new WCMS_DAL_Production();
            var         result            = new Result();

            var batchnumber = "";

            try
            {
                //logic

                var productionList = new List <ProductionMaster>();
                foreach (var items in productionAgingQc)
                {
                    var production = new ProductionMaster();


                    var isExists = _isSelectingCommon.ProductionMasterInfo(new ProductionMaster {
                        MobileCode = items.MobileCode
                    }).Any();

                    //check if previously passed
                    var previousStatus = _isSelectingCommon.ProductionMasterInfo(new ProductionMaster {
                        MobileCode = items.MobileCode
                    }).FirstOrDefault();

                    //var previousStation = entities.ProductionMaster.FirstOrDefault(a => a.MobileCode == items.MobileCode);
                    //if (previousStatus != null && (isExists && previousStatus.Passed.ToUpper() == "N"))


                    if (previousStatus != null && (isExists && previousStatus.Passed.ToUpper() == "N") && previousStatus.QcStation != "AGQC")
                    {
                        result.Message = " Item Not Passed From Aesthetic QC Station. Item No:" + items.MobileCode + "";
                        return(result);
                    }
                    //if (previousStatus != null && (isExists && previousStatus.QcStation.Trim() != "ASTQC"))

                    if (previousStatus != null && (isExists) && (previousStatus.QcStation.Trim() != "ASTQC" && previousStatus.QcStation.Trim() != "AGQC") && items.QcStation.Trim() == "AGQC")


                    {
                        result.Message = "Item Not Checked In Aesthetic QC Station. Item No:" + items.MobileCode + "";
                        return(result);
                    }
                    if (previousStatus == null || !isExists)
                    {
                        result.Message = "Item Not Checked In Aesthetic QC Station. Item No:" + items.MobileCode + "";
                        return(result);
                    }

                    if (items.QcStation == "AGQC")

                    {
                        production.MobileCode = items.MobileCode;
                        production.QcStation  = items.QcStation;
                        production.Passed     = items.Passed.ToUpper();

                        if (items.Passed.ToUpper() == "Y")
                        {
                            production.AgingBatchNumber = items.AgingBatchNumber;
                        }
                        production.AgingBy = userId;
                        production.AgingAD = DateTime.Now;
                        production.Remarks = items.Remarks;
                        batchnumber        = items.AgingBatchNumber;
                        productionList.Add(production);
                    }


                    if (productionList.Count == productionAgingQc.Count)
                    {
                        result.IsSuccess = iProductionSelect.InsertAgingBatchQcInfo(productionList);


                        if (result.IsSuccess)

                        {
                            //insert into rework


                            foreach (var failItems in productionList)
                            {
                                if (failItems.Passed.ToUpper() == "N")
                                {
                                    production.AgingBatchNumber = "";
                                    var reresult = new Result();
                                    var rework   = new tblRework();
                                    rework.ProjectId     = projectId;
                                    rework.MobileCode    = failItems.MobileCode;
                                    rework.Issues        = failItems.Remarks;
                                    rework.FailedStation = failItems.QcStation;
                                    rework.Status        = "P";
                                    rework.AddedBy       = userId;
                                    rework.AddedDate     = DateTime.Now;

                                    reresult.IsSuccess = iProductionInsert.InsertFunctionalRework(rework);
                                }
                            }


                            var batchResults = new Result();
                            if (result.IsSuccess)
                            {
                                var batchInfo = new AgingBatchInfo();
                                batchInfo.BatchNo = batchnumber;

                                if (batchStatus.ToUpper() == "N")
                                {
                                    batchInfo.Status = "F";
                                }

                                if (batchStatus.ToUpper() == "Y")
                                {
                                    batchInfo.Status = "P";
                                }

                                batchResults.IsSuccess = iProductionInsert.UpdateBatchInfo(batchInfo);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result);
        }
Beispiel #11
0
        public bool UpdateQcStatusHistory(List <ProductionMaster> productionList)
        {
            foreach (var item in productionList)
            {
                _entity.Configuration.LazyLoadingEnabled = false;
                ProductionMaster productionMaster =
                    _entity.ProductionMaster.FirstOrDefault(x => x.MobileCode == item.MobileCode);


                if (productionMaster != null)
                {
                    if (item.Passed != null)
                    {
                        productionMaster.Passed = item.Passed;
                    }
                    if (item.QcStation != null)
                    {
                        productionMaster.QcStation = item.QcStation;
                    }
                    if (!string.IsNullOrEmpty(item.Imei1))
                    {
                        productionMaster.Imei1 = item.Imei1;
                    }
                    if (!string.IsNullOrEmpty(item.Imei2))
                    {
                        productionMaster.Imei2 = item.Imei2;
                    }
                    if (item.AddedBy != null)
                    {
                        productionMaster.AddedBy = item.AddedBy;
                    }
                    if (item.AddedDate != null)
                    {
                        productionMaster.AddedDate = item.AddedDate;
                    }
                    if (item.UpdatedBy != null)
                    {
                        productionMaster.UpdatedBy = item.UpdatedBy;
                    }
                    if (item.UpdatedDate != null)
                    {
                        productionMaster.UpdatedDate = item.UpdatedDate;
                    }
                    if (item.FinallyPassed != null)
                    {
                        productionMaster.FinallyPassed = item.FinallyPassed;
                    }
                    if (item.FinallyPassedBy != null)
                    {
                        productionMaster.FinallyPassedBy = item.FinallyPassedBy;
                    }
                    if (item.FinallyPassedTime != null)
                    {
                        productionMaster.FinallyPassedTime = item.FinallyPassedTime;
                    }

                    if (item.FunctionalBy != null)
                    {
                        productionMaster.FunctionalBy = item.FunctionalBy;
                    }
                    if (item.FunctionalAD != null)
                    {
                        productionMaster.FunctionalAD = item.FunctionalAD;
                    }
                    if (item.AestheticBy != null)
                    {
                        productionMaster.AestheticBy = item.AestheticBy;
                    }
                    if (item.AestheticAD != null)
                    {
                        productionMaster.AestheticAD = item.AestheticAD;
                    }

                    if (item.AgingBy != null)
                    {
                        productionMaster.AgingBy = item.AgingBy;
                    }
                    if (item.AgingAD != null)
                    {
                        productionMaster.AgingAD = item.AgingAD;
                    }

                    if (item.PackagingBy != null)
                    {
                        productionMaster.PackagingBy = item.PackagingBy;
                    }
                    if (item.PackagingAD != null)
                    {
                        productionMaster.PackagingAD = item.PackagingAD;
                    }

                    if (item.PackagingAstheticBy != null)
                    {
                        productionMaster.PackagingAstheticBy = item.PackagingAstheticBy;
                    }
                    if (item.PackagingAstheticAD != null)
                    {
                        productionMaster.PackagingAstheticAD = item.PackagingAstheticAD;
                    }
                    if (item.PackagingOQCBy != null)
                    {
                        productionMaster.PackagingOQCBy = item.PackagingOQCBy;
                    }
                    if (item.PackagingOQCAD != null)
                    {
                        productionMaster.PackagingOQCAD = item.PackagingOQCAD;
                    }
                    if (item.PackagingLineId != null)
                    {
                        productionMaster.PackagingLineId = item.PackagingLineId;
                    }

                    if (item.OQCBatchNumber != null)
                    {
                        productionMaster.OQCBatchNumber = item.OQCBatchNumber;
                    }

                    _entity.Entry(productionMaster).State = EntityState.Modified;
                    _entity.SaveChanges();
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }