Ejemplo n.º 1
0
        public ActionResult NeverLogin(int? page, string searchTerm = null)
        {
            int pageNumber = (page ?? 1);
            var auditorList = _context.Users.OrderByDescending(s => s.LastLogin).
                Where(
                    p =>
                        (searchTerm == null || p.UserName.StartsWith(searchTerm)) &&
                        (p.LastLogin.Equals(p.OsysDateTime)));
            var indexViewModel = new List<UserReportModel1>();
            foreach (var n in auditorList)
            {
                if (n.Status == MyEnums.StatusOptions.Approved)
                {
                    var model = new UserReportModel1
                    {
                        Fullnames = n.FirstName +' '+ n.LastName,
                        Username = n.UserName,
                        CreatedOn = n.OsysDateTime,
                        Email = n.Email,
                        PhoneNumber = n.PhoneNumber,
                        Country = n.Country,
                        Enabled = n.Enabled,
                        StatusOptions = true

                    };
                    indexViewModel.Add(model);
                }
                else
                {
                    var model = new UserReportModel1
                    {
                        Fullnames = n.FirstName +' '+ n.LastName,
                        Username = n.UserName,
                        CreatedOn = n.OsysDateTime,
                        Email = n.Email,
                        PhoneNumber = n.PhoneNumber,
                        Country = n.Country,
                        Enabled = n.Enabled,
                        StatusOptions = false

                    };
                    indexViewModel.Add(model);
                }
            }
            _getVals.LogAudit(User.Identity.GetUserName(), "Viewed", Request.UserHostName, "Viewed Last Login Report ",
                "ISA", "UserManagement");
            return View(indexViewModel.ToPagedList(pageNumber, pageSize));
        }
        public PartialViewResult SelectSalesOrder(int? page, string searchOrderNo, string searchCustomer, string searchEmail)
        {
            bool bStatus = false;
            int pageIndex = 0;
            int pageSize = PageSize;
            int nHas = 0;
            Customers customer = null;
            SalesOrder salesorder = null;

            IQueryable<SalesOrder> qrySalesOrder = null;
            IQueryable<CustomersContactAddress> qryAddress = null;

            List<int> customerIdsList = new List<int>();
            List<SalesOrder> SalesOrderList = new List<SalesOrder>();

            if (string.IsNullOrEmpty(searchOrderNo) && string.IsNullOrEmpty(searchCustomer) && string.IsNullOrEmpty(searchEmail))
            {
                qrySalesOrder = db.SalesOrders.OrderBy(slor => slor.SalesOrderNo);
                if (qrySalesOrder.Count() > 0)
                {
                    foreach (var item in qrySalesOrder)
                    {
                        bStatus = VerifyInvoiceSalesOrder(item);
                        if (bStatus == false)
                        {
                            SalesOrderList.Add(item);
                        }
                    }
                }
            }
            else
            {
                if (!string.IsNullOrEmpty(searchEmail))
                {
                    ViewBag.SearchEmail = searchEmail;

                    qryAddress = db.CustomersContactAddresses.Where(ctad => ctad.Email.StartsWith(searchEmail));
                    if (qryAddress.Count() > 0)
                    {
                        foreach (var item in qryAddress)
                        {
                            nHas = Convert.ToInt32(item.CustomerId);
                            if (nHas > 0)
                            {
                                customerIdsList.Add(nHas);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(searchCustomer))
                {
                    ViewBag.SearchCustomer = searchCustomer;

                    qryAddress = db.CustomersContactAddresses.Where(ctad => ctad.CompanyName.StartsWith(searchCustomer));
                    if (qryAddress.Count() > 0)
                    {
                        foreach (var item in qryAddress)
                        {
                            nHas = Convert.ToInt32(item.CustomerId);
                            if (nHas > 0)
                            {
                                customerIdsList.Add(nHas);
                            }
                        }
                    }
                }

                if (customerIdsList.Count > 0)
                {
                    foreach (var itemCustomer in customerIdsList)
                    {
                        qrySalesOrder = db.SalesOrders.Where(slor => slor.CustomerId == itemCustomer).OrderBy(slor => slor.SalesOrderNo);
                        if (qrySalesOrder.Count() > 0)
                        {
                            foreach (var item in qrySalesOrder)
                            {
                                SalesOrderList.Add(item);
                            }
                        }
                    }
                }

                if (!string.IsNullOrEmpty(searchOrderNo))
                {
                    ViewBag.SearchOrderNo = searchOrderNo;

                    qrySalesOrder = db.SalesOrders.Where(slor => slor.SalesOrderNo.StartsWith(searchOrderNo)).OrderBy(slor => slor.SalesOrderNo);
                    if (qrySalesOrder.Count() > 0)
                    {
                        foreach (var item in qrySalesOrder)
                        {
                            SalesOrderList.Add(item);
                        }
                    }

                }
            }

            //Set the page
            if (page == null)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(page);
            }

            var onePageOfData = SalesOrderList.ToPagedList(pageIndex, pageSize);
            ViewBag.OnePageOfData = onePageOfData;
            return PartialView(SalesOrderList.ToPagedList(pageIndex, pageSize));
        }
Ejemplo n.º 3
0
 public ActionResult LastLogin(int? page, string searchTerm = null)
 {
     int pageNumber = (page ?? 1);
     var auditorList = _context.Users.OrderByDescending(s => s.LastLogin).
         Where(p => searchTerm == null || p.UserName.StartsWith(searchTerm));
     var indexViewModel = new List<UserReportModel>();
     foreach (var n in auditorList)
     {
         var mygroup = _repository.Find<Group>(n.GroupId);
         //var days = n.LastLogin.Subtract(DateTime.Now).Days;
         var days = DateTime.Now.Subtract(n.LastLogin).Days;
         var model = new UserReportModel
         {
             Fullnames = n.FirstName +' '+ n.LastName,
             Username = n.UserName,
             Lastlogin = n.LastLogin,
             DaysLastLogin = days,
             Enabled = n.Enabled,
             StatusOptions = n.Status
         };
         indexViewModel.Add(model);
     }
     _getVals.LogAudit(User.Identity.GetUserName(), "Viewed", Request.UserHostName, "Viewed Last Login Report ",
         "ISA", "UserManagement");
     return View(indexViewModel.ToPagedList(pageNumber, pageSize));
 }
        public PartialViewResult InvoiceList(int? page)
        {
            int pageIndex = 0;
            int pageSize = PageSize;

            TimelyDepotContext db01 = new TimelyDepotContext();

            InvoiceList theinvoicelist = null;
            List<InvoiceList> invoiceList = new List<InvoiceList>();

            var qrySalesOrder = db.CustomersContactAddresses.Join(db.Invoices, ctad => ctad.CustomerId, slod => slod.CustomerId, (ctad, slod)
                => new { ctad, slod }).OrderBy(cact => cact.slod.SalesOrderId);
            if (qrySalesOrder.Count() > 0)
            {
                foreach (var item in qrySalesOrder)
                {
                    theinvoicelist = new InvoiceList();
                    theinvoicelist.InvoiceId = item.slod.InvoiceId;
                    theinvoicelist.InvoiceNo = item.slod.InvoiceNo;
                    theinvoicelist.SODate = item.slod.ShipDate;
                    theinvoicelist.CustomerNo = GetCustomerDataInvoice(db01, item.ctad.CustomerId.ToString());
                    theinvoicelist.CompanyName = item.ctad.CompanyName;
                    theinvoicelist.PurchaseOrderNo = item.slod.PurchaseOrderNo;
                    theinvoicelist.SalesOrderNo = item.slod.SalesOrderNo;
                    theinvoicelist.PaymentAmount = GetInvoiceAmount(db01, item.slod.InvoiceId);

                    invoiceList.Add(theinvoicelist);
                }
            }

            //Set the page
            if (page == null)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(page);
            }

            var onePageOfData = invoiceList.ToPagedList(pageIndex, pageSize);
            ViewBag.OnePageOfData = onePageOfData;
            return PartialView(invoiceList.ToPagedList(pageIndex, pageSize));
        }
        //
        // GET: /Invoice/
        public ActionResult Index(int? page, string searchItem, string ckActive, string ckCriteria)
        {
            bool bHasData = true;
            int nYear = 0;
            int nMonth = 0;
            int nDay = 0;
            int pageIndex = 0;
            int pageSize = PageSize;
            string[] szFecha = null;
            DateTime dFecha = DateTime.Now;
            IQueryable<Invoice> qryInvoice = null;

            List<Invoice> InvoiceList = new List<Invoice>();
            if (string.IsNullOrEmpty(searchItem) || searchItem == "0")
            {
                //qryItem = db.ITEMs.OrderBy(it => it.ItemID);
                ViewBag.ckActiveHlp = "true";
                ViewBag.ckCriteriaHlp = "invoice";
                ViewBag.CurrentDate = dFecha.ToString("yyyy/MM/dd");
                bHasData = false;

                if (searchItem == "0")
                {
                    ViewBag.SearchItem = searchItem;
                    bHasData = true;

                    if (ckCriteria == "invoice")
                    {
                        if (ckActive == "true")
                        {
                            qryInvoice = db.Invoices.OrderBy(vd => vd.InvoiceNo);
                        }
                        else
                        {
                            qryInvoice = db.Invoices.OrderBy(vd => vd.InvoiceNo);
                        }
                    }
                }
            }
            else
            {
                ViewBag.SearchItem = searchItem;
                ViewBag.ckActiveHlp = ckActive;
                ViewBag.ckCriteriaHlp = ckCriteria;

                if (ckCriteria == "invoice")
                {
                    if (ckActive == "true")
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.InvoiceNo.StartsWith(searchItem)).OrderBy(vd => vd.InvoiceNo);
                    }
                    else
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.InvoiceNo.StartsWith(searchItem)).OrderBy(vd => vd.InvoiceNo);
                    }
                }

                if (ckCriteria == "salesorder")
                {
                    if (ckActive == "true")
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.SalesOrderNo.StartsWith(searchItem)).OrderBy(vd => vd.SalesOrderNo);
                    }
                    else
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.SalesOrderNo.StartsWith(searchItem)).OrderBy(vd => vd.SalesOrderNo);
                    }
                }

                if (ckCriteria == "shippeddate")
                {
                    szFecha = searchItem.Split('/');
                    if (szFecha != null)
                    {
                        nYear = Convert.ToInt32(szFecha[0]);
                        nMonth = Convert.ToInt32(szFecha[1]);
                        nDay = Convert.ToInt32(szFecha[2]);
                        dFecha = new DateTime(nYear, nMonth, nDay);
                    }

                    if (ckActive == "true")
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.ShipDate >= dFecha).OrderBy(vd => vd.SalesOrderNo);
                    }
                    else
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.ShipDate >= dFecha).OrderBy(vd => vd.SalesOrderNo);
                    }
                }

                if (ckCriteria == "customerpo")
                {
                    if (ckActive == "true")
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.PurchaseOrderNo.StartsWith(searchItem)).OrderBy(vd => vd.PurchaseOrderNo);
                    }
                    else
                    {
                        qryInvoice = db.Invoices.Where(vd => vd.PurchaseOrderNo.StartsWith(searchItem)).OrderBy(vd => vd.PurchaseOrderNo);
                    }
                }

                if (ckCriteria == "customername")
                {
                    if (ckActive == "true")
                    {
                        var qryMainContact = db.Invoices.Join(db.CustomersContactAddresses, ctc => ctc.CustomerId, cus => cus.CustomerId, (ctc, cus)
                             => new { ctc, cus }).Where(Nctcs => Nctcs.cus.CompanyName.StartsWith(searchItem)).OrderBy(Nctcs => Nctcs.cus.CompanyName);
                        if (qryMainContact.Count() > 0)
                        {
                            foreach (var item in qryMainContact)
                            {
                                InvoiceList.Add(item.ctc);
                            }
                        }
                    }
                    else
                    {
                        var qryMainContact = db.Invoices.Join(db.CustomersContactAddresses, ctc => ctc.CustomerId, cus => cus.CustomerId, (ctc, cus)
                             => new { ctc, cus }).Where(Nctcs => Nctcs.cus.CompanyName.StartsWith(searchItem)).OrderBy(Nctcs => Nctcs.cus.CompanyName);
                        if (qryMainContact.Count() > 0)
                        {
                            foreach (var item in qryMainContact)
                            {
                                InvoiceList.Add(item.ctc);
                            }
                        }
                    }
                    bHasData = false;
                }
            }

            if (bHasData)
            {
                if (qryInvoice != null)
                {
                    if (qryInvoice.Count() > 0)
                    {
                        foreach (var item in qryInvoice)
                        {
                            InvoiceList.Add(item);
                        }
                    }

                }
            }
            //Set the page
            if (page == null)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(page);
            }

            var onePageOfData = InvoiceList.ToPagedList(pageIndex, pageSize);
            ViewBag.OnePageOfData = onePageOfData;
            return View(InvoiceList.ToPagedList(pageIndex, pageSize));
            //return View(db.Invoices.ToList());
        }
        public PartialViewResult GetSalesDetailsSRC(int? page, string salesorderid)
        {
            TimelyDepotContext db01 = new TimelyDepotContext();

            int pageIndex = 0;
            int pageSize = PageSize;
            pageSize = 10;
            int nSalesOrderid = Convert.ToInt32(salesorderid);
            string szSalesOredidHlp = "";
            string szShipped = "";

            IQueryable<InvoiceDetail> qrysalesdetails = null;
            IQueryable<ImprintMethods> qryImprint = null;

            InvoiceDetail setupcharge = null;
            InvoiceDetail runcharge = null;
            InvoiceDetailSRC salesorderdetailSRC = null;
            ShipmentDetails shipped = null;

            List<InvoiceDetailSRC> salesdetailsList = new List<InvoiceDetailSRC>();
            List<KeyValuePair<string, string>> listSelector = new List<KeyValuePair<string, string>>();

            //qrysalesdetails = db.SalesOrderDetails.Where(sldt => sldt.SalesOrderId == nSalesOrderid).OrderBy(sldt => sldt.Sub_ItemID).ThenBy(sldt => sldt.ItemOrder);
            qrysalesdetails = db.InvoiceDetails.Where(sldt => sldt.InvoiceId == nSalesOrderid && sldt.ItemID != "").OrderBy(sldt => sldt.ItemPosition).ThenBy(sldt => sldt.ItemOrder);
            if (qrysalesdetails.Count() > 0)
            {
                foreach (var item in qrysalesdetails)
                {
                    salesorderdetailSRC = new InvoiceDetailSRC();
                    salesorderdetailSRC.BackOrderQuantity = item.BackOrderQuantity;
                    salesorderdetailSRC.Description = item.Description;
                    salesorderdetailSRC.Id = item.Id;
                    salesorderdetailSRC.ImprintMethod = item.ImprintMethod;
                    salesorderdetailSRC.ItemID = item.ItemID;
                    salesorderdetailSRC.ItemOrder = item.ItemOrder;
                    salesorderdetailSRC.ItemPosition = item.ItemPosition;
                    salesorderdetailSRC.Logo = item.Logo;
                    salesorderdetailSRC.Quantity = item.Quantity;
                    salesorderdetailSRC.SalesOrderId = item.InvoiceId;
                    salesorderdetailSRC.ShipQuantity = item.ShipQuantity;
                    salesorderdetailSRC.Sub_ItemID = item.Sub_ItemID;
                    salesorderdetailSRC.Tax = item.Tax;
                    salesorderdetailSRC.UnitPrice = item.UnitPrice;
                    salesorderdetailSRC.QuantitySC = 0;
                    salesorderdetailSRC.UnitPricSRC = 0;
                    salesorderdetailSRC.QuantityRC = 0;
                    salesorderdetailSRC.UnitPriceRC = 0;

                    //Set Up Charge
                    szSalesOredidHlp = string.Format("Set up Charge {0} {1}", salesorderdetailSRC.SalesOrderId.ToString(), salesorderdetailSRC.ItemID);
                    setupcharge = db01.InvoiceDetails.Where(stup => stup.InvoiceId == item.InvoiceId && stup.Description == szSalesOredidHlp).FirstOrDefault<InvoiceDetail>();
                    if (setupcharge != null)
                    {
                        salesorderdetailSRC.QuantitySC = setupcharge.Quantity;
                        salesorderdetailSRC.UnitPricSRC = setupcharge.UnitPrice;
                    }
                    //Run Charge
                    szSalesOredidHlp = string.Format("Run Charge {0} {1}", salesorderdetailSRC.SalesOrderId.ToString(), salesorderdetailSRC.ItemID);
                    runcharge = db01.InvoiceDetails.Where(stup => stup.InvoiceId == item.InvoiceId && stup.Description == szSalesOredidHlp).FirstOrDefault<InvoiceDetail>();
                    if (runcharge != null)
                    {
                        salesorderdetailSRC.QuantityRC = runcharge.Quantity;
                        salesorderdetailSRC.UnitPriceRC = runcharge.UnitPrice;
                    }

                    salesdetailsList.Add(salesorderdetailSRC);

                    //Get the shipped items
                    shipped = db01.ShipmentDetails.Where(shpdtl => shpdtl.DetailId == item.Id).FirstOrDefault<ShipmentDetails>();
                    if (shipped != null)
                    {
                        if (string.IsNullOrEmpty(szShipped))
                        {
                            szShipped = string.Format("lkshiped_{0}", item.Id);
                        }
                        else
                        {
                            szShipped = string.Format("{0};lkshiped_{1}", szShipped ,item.Id);
                        }
                    }

                }
            }
            ViewBag.SalesOrderId = salesorderid;
            if (!string.IsNullOrEmpty(szShipped))
            {
                ViewBag.ShippedItems = szShipped;
            }

            //Get the imprint methods
            qryImprint = db.ImprintMethods.OrderBy(trd => trd.Description);
            if (qryImprint.Count() > 0)
            {
                foreach (var item in qryImprint)
                {
                    listSelector.Add(new KeyValuePair<string, string>(item.Description, item.Description));
                }
            }
            SelectList imprintlist = new SelectList(listSelector, "Key", "Value");
            ViewBag.ImprintList = imprintlist;

            //Set the page
            if (page == null)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(page);
            }

            var onePageOfData = salesdetailsList.ToPagedList(pageIndex, pageSize);
            ViewBag.OnePageOfData = onePageOfData;
            return PartialView(salesdetailsList.ToPagedList(pageIndex, pageSize));
        }
        public PartialViewResult GetSalesDetails(int? page, string salesorderid)
        {
            int pageIndex = 0;
            int pageSize = PageSize;
            pageSize = 10;
            int nSalesOrderid = Convert.ToInt32(salesorderid);

            IQueryable<InvoiceDetail> qrysalesdetails = null;

            List<InvoiceDetail> salesdetailsList = new List<InvoiceDetail>();

            //qrysalesdetails = db.SalesOrderDetails.Where(sldt => sldt.SalesOrderId == nSalesOrderid).OrderBy(sldt => sldt.Sub_ItemID).ThenBy(sldt => sldt.ItemOrder);
            qrysalesdetails = db.InvoiceDetails.Where(sldt => sldt.InvoiceId == nSalesOrderid).OrderBy(sldt => sldt.ItemPosition).ThenBy(sldt => sldt.ItemOrder);
            if (qrysalesdetails.Count() > 0)
            {
                foreach (var item in qrysalesdetails)
                {
                    salesdetailsList.Add(item);
                }
            }
            ViewBag.SalesOrderId = salesorderid;

            //Set the page
            if (page == null)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(page);
            }

            var onePageOfData = salesdetailsList.ToPagedList(pageIndex, pageSize);
            ViewBag.OnePageOfData = onePageOfData;
            return PartialView(salesdetailsList.ToPagedList(pageIndex, pageSize));
        }
        public PartialViewResult AddDetail(string searchitem, string itemOrder, int? page, int salesorderid = 0, int itemPos = 0)
        {
            int pageIndex = 0;
            int pageSize = PageSize;
            pageSize = 15;

            IQueryable<SUB_ITEM> qrysubitem = null;

            List<SUB_ITEM> subitemList = new List<SUB_ITEM>();

            if (string.IsNullOrEmpty(searchitem))
            {
                qrysubitem = db.SUB_ITEM.OrderBy(sbit => sbit.Sub_ItemID);
            }
            else
            {
                ViewBag.SearchItem = searchitem;
                qrysubitem = db.SUB_ITEM.Where(sbit => sbit.Sub_ItemID.StartsWith(searchitem)).OrderBy(sbit => sbit.Sub_ItemID);
            }

            if (qrysubitem.Count() > 0)
            {
                foreach (var item in qrysubitem)
                {
                    subitemList.Add(item);
                }
            }

            ViewBag.SalesOrderId = salesorderid;
            ViewBag.ItemPos = itemPos;
            ViewBag.ItemOrder = itemOrder;

            //Set the page
            if (page == null)
            {
                pageIndex = 1;
            }
            else
            {
                pageIndex = Convert.ToInt32(page);
            }

            var onePageOfData = subitemList.ToPagedList(pageIndex, pageSize);
            ViewBag.OnePageOfData = onePageOfData;

            return PartialView(subitemList.ToPagedList(pageIndex, pageSize));
        }