예제 #1
0
        bool JobOrderEvents__beforeLineSaveBylkDataValidation(object sender, JobEventArgs EventArgs, ref ApplicationDbContext db)
        {
            var JobOrder = (from H in db.JobOrderHeader
                            join D in db.DocumentType on H.DocTypeId equals D.DocumentTypeId into DocumentTypeTable
                            from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty()
                            where H.JobOrderHeaderId == EventArgs.DocId
                            select new { DocTypeName = DocumentTypeTab.DocumentTypeName, Status = H.Status }).FirstOrDefault();

            if (JobOrder.DocTypeName == "Weaving Order" || JobOrder.DocTypeName == "Weaving Finished Order" && JobOrder.Status != 0)
            {
                var Temp = (from L in db.JobOrderLine
                            join Pol in db.ProdOrderLine on L.ProdOrderLineId equals Pol.ProdOrderLineId into ProdOrderLineTable
                            from ProdOrderLineTab in ProdOrderLineTable.DefaultIfEmpty()
                            join Poh in db.ProdOrderHeader on ProdOrderLineTab.ProdOrderHeaderId equals Poh.ProdOrderHeaderId into ProdOrderHeaderTable
                            from ProdOrderHeaderTab in ProdOrderHeaderTable.DefaultIfEmpty()
                            join H in db.JobOrderHeader on ProdOrderHeaderTab.ReferenceDocId equals H.JobOrderHeaderId into JobOrderHeaderTable
                            from JobOrderHeaderTab in JobOrderHeaderTable.DefaultIfEmpty()
                            where JobOrderHeaderTab.JobOrderHeaderId == EventArgs.DocId
                            select new { JobOrderHeaderId = JobOrderHeaderTab.JobOrderHeaderId }).FirstOrDefault();

                if (Temp != null)
                {
                    if (Temp.JobOrderHeaderId != null)
                    {
                        throw new Exception("Branch has already issued Weaving Order.You can't add new record.");
                    }
                }
            }

            return(true);
        }
예제 #2
0
        public JobOrderDetail GetJobOrderDetail(int JobOrderLineId)
        {
            var temp = (from L in _unitOfWork.Repository <ViewJobOrderBalance>().Instance
                        join Dl in _unitOfWork.Repository <JobOrderLine>().Instance on L.JobOrderLineId equals Dl.JobOrderLineId into JobOrderLineTable
                        from JobOrderLineTab in JobOrderLineTable.DefaultIfEmpty()
                        join Dh in _unitOfWork.Repository <JobOrderHeader>().Instance on L.JobOrderHeaderId equals Dh.JobOrderHeaderId into JobOrderHeaderTable
                        from JobOrderHeaderTab in JobOrderHeaderTable.DefaultIfEmpty()
                        where L.JobOrderLineId == JobOrderLineId
                        select new JobOrderDetail
            {
                JobOrderHeaderDocNo = L.JobOrderNo,
                ProductId = L.ProductId,
                ProductName = L.Product.ProductName,
                Dimension1Id = L.Dimension1Id,
                Dimension1Name = L.Dimension1.Dimension1Name,
                Dimension2Id = L.Dimension2Id,
                Dimension2Name = L.Dimension2.Dimension2Name,
                MachineId = JobOrderHeaderTab.MachineId,
                MachineName = JobOrderHeaderTab.Machine.ProductName,
                Qty = L.BalanceQty,
                BalanceQty = L.BalanceQty,
                LotNo = JobOrderLineTab.LotNo,
                UnitId = JobOrderLineTab.UnitId
            }).FirstOrDefault();

            return(temp);
        }
예제 #3
0
        public void CreateJobReceiveAtBranch(int JobReceiveHeaderId)
        {
            JobReceiveHeader JobReceiveHeader = new JobReceiveHeaderService(_unitOfWork).Find(JobReceiveHeaderId);

            int SisteConcernSiteId = (from H in db.JobReceiveHeader
                                      join p in db.Persons on H.JobWorkerId equals p.PersonID into JobWorkerTable
                                      from JobWorkerTab in JobWorkerTable.DefaultIfEmpty()
                                      join s in db.Site on JobWorkerTab.PersonID equals s.PersonId into SiteTable
                                      from SiteTab in SiteTable.DefaultIfEmpty()
                                      where H.JobReceiveHeaderId == JobReceiveHeaderId
                                      select new
            {
                SiteId = SiteTab.SiteId
            }).FirstOrDefault().SiteId;

            if (SisteConcernSiteId != null && SisteConcernSiteId != 0)
            {
                var Temp = (from L in db.JobReceiveLine
                            join H in db.JobReceiveHeader on L.JobReceiveHeaderId equals H.JobReceiveHeaderId into JobReceiveHeaderTable
                            from JobReceiveHeaderTab in JobReceiveHeaderTable.DefaultIfEmpty()
                            join P in db.ProductUidSiteDetail on L.ProductUidId equals P.ProductUIDId into ProductUidTable
                            from ProductUidTab in ProductUidTable.DefaultIfEmpty()
                            join Joh in db.JobOrderHeader on ProductUidTab.GenDocId equals Joh.JobOrderHeaderId into JobOrderHeaderTable
                            from JobOrderHeaderTab in JobOrderHeaderTable.DefaultIfEmpty()
                            where L.JobReceiveHeaderId == JobReceiveHeaderId
                            group new { JobReceiveHeaderTab, JobOrderHeaderTab } by new { JobOrderHeaderTab.JobWorkerId } into Results
                            select new
                {
                    DocDate = Results.Max(i => i.JobReceiveHeaderTab.DocDate),
                    DivisionId = Results.Max(i => i.JobReceiveHeaderTab.DivisionId),
                    ProcessId = Results.Max(i => i.JobReceiveHeaderTab.ProcessId),
                    JobWorkerId = Results.Key.JobWorkerId,
                    Remark = Results.Max(i => i.JobReceiveHeaderTab.Remark)
                }).ToList();

                foreach (var SisterConcernJobReceiveHeader in Temp)
                {
                    JobReceiveHeader Header = new JobReceiveHeader();
                    Header.DocTypeId      = new DocumentTypeService(_unitOfWork).Find(TransactionDoctypeConstants.WeavingBazar).DocumentTypeId;
                    Header.DocDate        = SisterConcernJobReceiveHeader.DocDate;
                    Header.DocNo          = "1";
                    Header.DivisionId     = SisterConcernJobReceiveHeader.DivisionId;
                    Header.SiteId         = SisteConcernSiteId;
                    Header.ProcessId      = SisterConcernJobReceiveHeader.ProcessId;
                    Header.JobWorkerId    = SisterConcernJobReceiveHeader.JobWorkerId;
                    Header.JobReceiveById = 1;
                    Header.GodownId       = 1;
                    Header.Remark         = SisterConcernJobReceiveHeader.Remark;
                    Header.CreatedBy      = User.Identity.Name;
                    Header.CreatedDate    = DateTime.Now;
                    Header.ModifiedBy     = User.Identity.Name;
                    Header.ModifiedDate   = DateTime.Now;

                    new JobReceiveHeaderService(_unitOfWork).Create(Header);
                }
            }
        }
예제 #4
0
        public ComboBoxResult GetJobOrderLine(int Ids)
        {
            var JobOrderLine = (from L in _unitOfWork.Repository <JobOrderLine>().Instance
                                join H in _unitOfWork.Repository <JobOrderHeader>().Instance on L.JobOrderHeaderId equals H.JobOrderHeaderId into JobOrderHeaderTable
                                from JobOrderHeaderTab in JobOrderHeaderTable.DefaultIfEmpty()
                                where L.JobOrderLineId == Ids
                                select new ComboBoxResult
            {
                id = L.JobOrderLineId.ToString(),
                text = JobOrderHeaderTab.DocNo
            }).FirstOrDefault();

            return(JobOrderLine);
        }
예제 #5
0
        public RecipeLineViewModel GetStockLine(int id)
        {
            var temp = (from p in _StockLineRepository.Instance
                        join H  in _unitOfWork.Repository <JobOrderHeader>().Instance on p.StockHeaderId equals H.StockHeaderId into JobOrderHeaderTable from JobOrderHeaderTab in JobOrderHeaderTable.DefaultIfEmpty()
                        join Se in _unitOfWork.Repository <StockLineExtended>().Instance on p.StockLineId equals Se.StockLineId into StockLineExtendedTable
                        from StockLineExtendedTab in StockLineExtendedTable.DefaultIfEmpty()
                        where p.StockLineId == id
                        select new RecipeLineViewModel
            {
                ProductId = p.ProductId,
                Qty = p.Qty,
                Remark = p.Remark,
                StockHeaderId = p.StockHeaderId,
                JobOrderHeaderId = JobOrderHeaderTab.JobOrderHeaderId,
                StockLineId = p.StockLineId,
                ProductName = p.Product.ProductName,
                LockReason = p.LockReason,
                DyeingRatio = StockLineExtendedTab.DyeingRatio,
                TestingQty = StockLineExtendedTab.TestingQty,
                DocQty = StockLineExtendedTab.DocQty,
                ExcessQty = StockLineExtendedTab.ExcessQty,
                Rate = p.Rate,
                Amount = p.Amount,
                UnitId = p.Product.UnitId,
                UnitName = p.Product.Unit.UnitName,
                UnitDecimalPlaces = p.Product.Unit.DecimalPlaces,
            }).FirstOrDefault();



            return(temp);
        }