示例#1
0
        public List <PRQChemFrgnPurcOrdr> GetOrderInformationForLOV()
        {
            var Orders = (from o in _context.PRQ_ChemFrgnPurcOrdr.AsEnumerable()
                          where o.RecordStatus == "CNF" & o.OrderState == "RNG" & o.OrderCategory == "FPO"

                          from s1 in _context.Sys_Supplier.Where(x => x.SupplierID == o.SupplierID).DefaultIfEmpty()

                          join sa in _context.Sys_SupplierAddress.Where(x => x.IsActive && !x.IsDelete) on o.SupplierID equals sa.SupplierID into SupplierAddress
                          from sa2 in SupplierAddress.DefaultIfEmpty()

                          from s2 in _context.Sys_Supplier.Where(x => x.SupplierID == o.LocalAgent).DefaultIfEmpty()

                          join la in _context.Sys_SupplierAddress.Where(x => x.IsActive && !x.IsDelete) on o.LocalAgent equals la.SupplierID into LocalAgentAddress
                          from la2 in LocalAgentAddress.DefaultIfEmpty()

                          from s3 in _context.Sys_Supplier.Where(x => x.SupplierID == o.ForeignAgent).DefaultIfEmpty()

                          join fa in _context.Sys_SupplierAddress.Where(x => x.IsActive && !x.IsDelete) on o.ForeignAgent equals fa.SupplierID into ForeignAgentAddress
                          from fa2 in ForeignAgentAddress.DefaultIfEmpty()
                          orderby o.OrderID descending
                          select new PRQChemFrgnPurcOrdr
            {
                OrderID = o.OrderID,
                OrderNo = o.OrderNo,
                OrderTo = DalCommon.ReturnOrderTo(o.OrderTo),
                OrderDate = (Convert.ToDateTime(o.OrderDate)).ToString("dd'/'MM'/'yyyy"),
                OrderType = DalCommon.ReturnOrderType(o.OrderType),

                SupplierID = Convert.ToInt32((s1 == null ? null : (s1.SupplierID).ToString())),
                SupplierName = (s1 == null ? null : s1.SupplierName),
                SupplierCode = (s1 == null ? null : s1.SupplierCode),
                SupplierAddress = (sa2 == null? null: sa2.Address),
                SupplierContactNumber = (sa2 == null ? null : sa2.ContactNumber),


                LocalAgent = Convert.ToInt32((la2 == null ? null : (la2.SupplierID).ToString())),
                LocalAgentName = (s2 == null ? null : s2.SupplierName),
                LocalAgentCode = (s2 == null ? null : s2.SupplierCode),
                LocalAgentAddress = (la2 == null ? null : la2.Address),
                LocalAgentContactNumber = (la2 == null ? null : la2.ContactNumber),

                ForeignAgent = Convert.ToInt32((s3 == null ? null : (s3.SupplierID).ToString())),
                ForeignAgentName = (s3 == null ? null : s3.SupplierName),
                ForeignAgentCode = (s3 == null ? null : s3.SupplierCode),
                ForeignAgentAddress = (fa2 == null ? null : fa2.Address),
                ForeignAgentContactNumber = (fa2 == null ? null : fa2.ContactNumber),

                OrderNote = o.OrderNote
            }).ToList();

            return(Orders);
        }