Exemplo n.º 1
0
        public Result UpdateBatchInfo(AgingBatchInfo batchInfo)
        {
            IProduction iProductionSelect = new WCMS_DAL_Production();
            var         result            = new Result();

            using (
                var transaction = new TransactionScope(TransactionScopeOption.Required,
                                                       ApplicationState.TransactionOptions))
                try
                {
                    result.IsSuccess = iProductionSelect.UpdateBatchInfo(batchInfo);

                    if (result.IsSuccess)
                    {
                        transaction.Complete();
                    }
                    else
                    {
                        transaction.Dispose();
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            return(result);
        }
Exemplo n.º 2
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);
        }