Exemple #1
0
        public IEnumerable <TruckViewModel> GetTruckForAutosuggestByType(string value, string type)
        {
            var truck = from a in _truckRepository.GetAllQueryable()
                        join b in _driverRepository.GetAllQueryable() on new { a.DriverC }
            equals new { b.DriverC } into t1
            from b in t1.DefaultIfEmpty()
            join c in _partnerRepository.GetAllQueryable() on new { a.PartnerMainC, a.PartnerSubC }
            equals new { c.PartnerMainC, c.PartnerSubC } into t2
            from c in t2.DefaultIfEmpty()
            where ((a.TruckC.Contains(value) || a.RegisteredNo.Contains(value)) &&
                   a.PartnerI == type && a.IsActive == "1"
                   )
            select new TruckViewModel()
            {
                TruckC       = a.TruckC,
                RegisteredNo = a.RegisteredNo,
                RegisteredD  = a.RegisteredD,
                DepC         = a.DepC,
                DriverC      = a.DriverC,
                DriverN      = b != null ? b.LastN + " " + b.FirstN : "",
                DriverFirstN = b != null ? b.FirstN : "",
                PartnerMainC = a.PartnerMainC,
                PartnerSubC  = a.PartnerSubC,
                PartnerN     = c != null ? c.PartnerN : "",
                AssistantC   = a.AssistantC,
                AssistantN   = ""
            };

            truck = truck.OrderBy("RegisteredNo asc");
            var truckList = truck.ToList();
            var count     = truckList.Count;

            for (var i = 0; i < count; i++)
            {
                string assC   = truckList[i].AssistantC;
                var    driver = _driverRepository.Query(p => p.DriverC == assC).FirstOrDefault();
                truckList[i].AssistantN = driver != null ? driver.LastN + " " + driver.FirstN : "";
            }
            return(truckList);
        }
Exemple #2
0
        public PartnerViewModel GetByInvoiceName(string value)
        {
            var partner = (from a in _partnerSettlementRepository.GetAllQueryable()
                           join b in _partnerRepository.GetAllQueryable() on new { a.PartnerMainC, a.PartnerSubC }
                           equals new { b.PartnerMainC, b.PartnerSubC }
                           where (b.PartnerN.Equals(value))
                           select new PartnerViewModel()
            {
                PartnerMainC = a.PartnerMainC,
                PartnerSubC = a.PartnerSubC,
            }).FirstOrDefault();

            return(partner);
        }
        public PartnerContractTariffPatternDatatable GetPartnerContractTariffPatternsForTable(int page, int itemsPerPage, string sortBy, bool reverse, string searchValue)
        {
            var patterns = (from p in _tariffPatternRepository.GetAllQueryable()
                            join c in _partnerRepository.GetAllQueryable() on p.PartnerMainC equals c.PartnerMainC
                            //join dp in _locationRepository.GetAllQueryable() on p.DepartureC equals dp.LocationC
                            //join ds in _locationRepository.GetAllQueryable() on p.DestinationC equals ds.LocationC
                            where p.PartnerSubC == c.PartnerSubC
                            select new PartnerContractTariffViewModel
            {
                PartnerMainC = p.PartnerMainC,
                PartnerSubC = p.PartnerSubC,
                PartnerN = c.PartnerN,
                ApplyD = p.ApplyD
                         //DepartureC = p.DepartureC,
                         //DepartureN = dp.LocationN,
                         //DestinationC = p.DestinationC,
                         //DestinationN = ds.LocationN
            }).Distinct().AsQueryable();

            // searching
            if (!string.IsNullOrWhiteSpace(searchValue))
            {
                searchValue = searchValue.ToLower();
                patterns    = patterns.Where(i => (i.PartnerN != null && i.PartnerN.ToLower().Contains(searchValue)) ||
                                             (i.PartnerMainC != null && i.PartnerMainC.ToLower().Contains(searchValue)) ||
                                             (i.PartnerSubC != null && i.PartnerSubC.ToLower().Contains(searchValue)));
            }

            // sorting, paging
            List <PartnerContractTariffViewModel> result = patterns.OrderBy(sortBy + (reverse ? " descending" : ""))
                                                           .Skip((page - 1) * itemsPerPage).Take(itemsPerPage).ToList();

            var datatable = new PartnerContractTariffPatternDatatable()
            {
                Data  = result,
                Total = result.Count()
            };

            return(datatable);
        }
        public PartnerPaymentViewModel GetPartnerPayment(string partnerMainC, string partnerSubC, DateTime partnerPaymentD, string paymentId)
        {
            //GetBalance
            //var balance = (from l in _partnerBalanceRepository.GetAllQueryable()
            //			   where l.PartnerMainC == partnerMainC &&
            //			   l.PartnerSubC == partnerSubC
            //			   group l by new { l.PartnerMainC, l.PartnerSubC } into s
            //			   select new
            //			   {
            //				   Amount = s.Sum(i => i.TotalAmount + i.TaxAmount - i.PaymentAmount),
            //			   }).FirstOrDefault();

            //var balanceAmount = balance != null ? balance.Amount : 0;

            var partner = (from c in _partnerRepository.GetAllQueryable()
                           where c.PartnerMainC == partnerMainC &&
                           c.PartnerSubC == partnerSubC
                           select new PartnerPaymentViewModel
            {
                PartnerMainC = partnerMainC,
                PartnerSubC = partnerSubC,
                PartnerN = c.PartnerN,
                PartnerPaymentD = partnerPaymentD,
                PaymentId = paymentId
            }).FirstOrDefault();

            if (partner == null)
            {
                return(null);
            }

            var partnerPayment = (from l in _partnerPaymentRepository.GetAllQueryable()
                                  join e in _employeeRepository.GetAllQueryable() on l.EntryClerkC equals e.EmployeeC into le
                                  from e in le.DefaultIfEmpty()
                                  where l.PartnerMainC == partnerMainC &&
                                  (l.PartnerSubC == partnerSubC) &&
                                  (l.PartnerPaymentD == partnerPaymentD) &&
                                  l.PaymentId == paymentId
                                  select new PartnerPaymentViewModel
            {
                Amount = l.Amount,
                Description = l.Description,
                EntryClerkC = l.EntryClerkC,
                EntryClerkN = e != null ? e.EmployeeLastN + " " + e.EmployeeFirstN : "",
                PaymentMethodI = l.PaymentMethodI
            }).FirstOrDefault();

            if (partnerPayment != null)
            {
                partner.ObjectI = "P";
                //partner.PreviousBalance = balanceAmount + partnerPayment.Amount;
                partner.Amount = partnerPayment.Amount;
                //partner.NextBalance = balanceAmount;
                partner.Description = partnerPayment.Description;
                partner.Status      = (int)FormStatus.Edit;
                //FindIndex
                //partner.PartnerPaymentIndex = FindIndex(partnerMainC, partnerSubC, partnerPaymentD, paymentId);
                partner.EntryClerkC    = partnerPayment.EntryClerkC;
                partner.EntryClerkN    = partnerPayment.EntryClerkN;
                partner.PaymentMethodI = partnerPayment.PaymentMethodI;
            }
            else
            {
                partner.ObjectI = "P";
                //partner.PreviousBalance = balanceAmount;
                partner.Amount = 0;
                //partner.NextBalance = balanceAmount;
                partner.Description = "";
                partner.Status      = (int)FormStatus.Add;
            }

            return(partner);
        }
        public ContractPartnerPatternDatatable GetContractPartnerPatternsForTable(int page, int itemsPerPage, string sortBy,
                                                                                  bool reverse, string custMainC, string custSubC, string departure, string destination, string contsizeI)
        {
            var patterns = (from p in _contractPartnerPatternRepository.GetAllQueryable()
                            join c in _partnerRepository.GetAllQueryable() on p.PartnerMainC equals c.PartnerMainC into pc
                            from c in pc.DefaultIfEmpty()
                            join d in _locationRepository.GetAllQueryable() on p.DepartureC equals d.LocationC into dp
                            from d in dp.DefaultIfEmpty()
                            join s in _locationRepository.GetAllQueryable() on p.DestinationC equals s.LocationC into ds
                            from s in ds.DefaultIfEmpty()
                            join cus in _customerRepository.GetAllQueryable() on new { p.CustomerMainC, p.CustomerSubC } equals new { cus.CustomerMainC, cus.CustomerSubC } into dt
                            from cus in dt.DefaultIfEmpty()
                            where p.PartnerSubC == c.PartnerSubC
                            select new ContractPartnerViewModel
            {
                PartnerMainC = p.PartnerMainC,
                PartnerSubC = p.PartnerSubC,
                PartnerN = c.PartnerN,
                ContainerSizeI = p.ContainerSizeI,
                ApplyD = p.ApplyD,
                DepartureC = p.DepartureC,
                DepartureN = d.LocationN,
                DestinationC = p.DestinationC,
                DestinationN = s.LocationN,
                UnitPrice = p.UnitPrice,
                CustomerMainC = p.CustomerMainC,
                CustomerSubC = p.CustomerSubC,
                CustomerN = cus.CustomerN,
                CalculateByTon = p.CalculateByTon,
            }).Distinct().AsQueryable();

            // searching
            if (!string.IsNullOrWhiteSpace(custMainC) & !string.IsNullOrWhiteSpace(custSubC))
            {
                patterns = patterns.Where(i => (i.PartnerN != null && i.PartnerMainC.Contains(custMainC) &&
                                                i.PartnerSubC.Contains(custSubC)));
            }

            if (!string.IsNullOrWhiteSpace(departure))
            {
                patterns = patterns.Where(i => (i.DepartureC != null && i.DepartureC.Contains(departure)));
            }

            if (!string.IsNullOrWhiteSpace(destination))
            {
                patterns = patterns.Where(i => (i.DestinationC != null && i.DestinationC.Contains(destination)));
            }

            if (!string.IsNullOrWhiteSpace(contsizeI))
            {
                patterns = patterns.Where(i => (i.ContainerSizeI != null && i.ContainerSizeI.Contains(contsizeI)) || contsizeI == "4");
            }

            // sorting, paging
            List <ContractPartnerViewModel> result =
                patterns.OrderBy(sortBy + (reverse ? " descending" : "")).Skip((page - 1) * itemsPerPage).Take(itemsPerPage).ToList();

            var datatable = new ContractPartnerPatternDatatable()
            {
                Data  = result,
                Total = patterns.Count()
            };

            return(datatable);
        }