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); } } }
public PackingHeaderViewModel GetPackingHeaderViewModel(int id) { PackingHeaderViewModel packingheader = (from H in db.PackingHeader join B in db.Persons on H.BuyerId equals B.PersonID into BuyerTable from BuyerTab in BuyerTable.DefaultIfEmpty() join B in db.Persons on H.JobWorkerId equals B.PersonID into JobWorkerTable from JobWorkerTab in JobWorkerTable.DefaultIfEmpty() join D in db.DocumentType on H.DocTypeId equals D.DocumentTypeId into DocumentTypeTable from DocumentTypeTab in DocumentTypeTable.DefaultIfEmpty() join Div in db.Divisions on H.DivisionId equals Div.DivisionId into DivisionTable from DivisionTab in DivisionTable.DefaultIfEmpty() join S in db.Site on H.SiteId equals S.SiteId into SiteTable from SiteTab in SiteTable.DefaultIfEmpty() join G in db.Godown on H.GodownId equals G.GodownId into GodownTable from GodownTab in GodownTable.DefaultIfEmpty() join Du in db.Units on H.DealUnitId equals Du.UnitId into DeliveryUnitTable from DeliveryUnitTab in DeliveryUnitTable.DefaultIfEmpty() where H.PackingHeaderId == id select new PackingHeaderViewModel { PackingHeaderId = H.PackingHeaderId, DocTypeName = DocumentTypeTab.DocumentTypeName, DocDate = H.DocDate, DocNo = H.DocNo, BuyerId = H.BuyerId, DocTypeId = H.DocTypeId, BuyerName = BuyerTab.Name, JobWorkerId = H.JobWorkerId.Value, JobWorkerName = JobWorkerTab.Name, DivisionId = H.DivisionId, DivisionName = DivisionTab.DivisionName, SiteId = H.SiteId, SiteName = SiteTab.SiteName, GodownId = H.GodownId, GodownName = GodownTab.GodownName, DealUnitId = H.DealUnitId, DealUnitName = DeliveryUnitTab.UnitName, BaleNoPattern = H.BaleNoPattern, ShipMethodId = H.ShipMethodId, Remark = H.Remark, Status = H.Status, CreatedBy = H.CreatedBy, CreatedDate = H.CreatedDate, ModifiedBy = H.ModifiedBy, ModifiedDate = H.ModifiedDate, LockReason = H.LockReason, TotalQty = H.PackingLines.Sum(m => m.Qty), DecimalPlaces = (from o in H.PackingLines join prod in db.Product on o.ProductId equals prod.ProductId join u in db.Units on prod.UnitId equals u.UnitId select u.DecimalPlaces).Max(), }).FirstOrDefault(); return(packingheader); }