예제 #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 IEnumerable <ProdOrderLine> GetPurchOrProdLineForMaterialPlan(int MaterialPlanLineId, int PurchOrProdDocTypeId)
 {
     return(from p in db.ProdOrderLine
            join H in db.ProdOrderHeader on p.ProdOrderHeaderId equals H.ProdOrderHeaderId into ProdOrderHeaderTable
            from ProdOrderHeaderTab in ProdOrderHeaderTable.DefaultIfEmpty()
            where p.MaterialPlanLineId == MaterialPlanLineId && ProdOrderHeaderTab.DocTypeId == PurchOrProdDocTypeId
            select p
            );
 }