public async Task<ActionResult> popUpSearch(string keywordId, string keywordSearch, int maxRows, int pageStart)
        {
            string sql = "WITH cte AS ( ";
            sql += "SELECT ROW_NUMBER() OVER(ORDER BY poId) AS rn, ";
            sql += "a.poId, a.poDate, b.vendorID, b.vendorName, a.poUrgent ";
            sql += "FROM [dbo].[PurchaseOrderHeaders] a WITH(NOLOCK) ";
            sql += "INNER JOIN [dbo].[Vendors] b ON b.vendorID = a.vendorId ";
            sql += "WHERE a.poId NOT IN (SELECT poId FROM [dbo].[PurchaseReceives])	AND a.proposedStatus = 1";
            if (keywordId != string.Empty && keywordSearch != string.Empty && !keywordId.Contains("a.poDate"))
            {
                sql += "AND " + keywordId + " LIKE  '%" + keywordSearch + "%' ";
            }
            else
            {
                sql += "AND " + keywordId + keywordSearch;
            }
            sql += ") ";
            sql += "SELECT * FROM cte ";
            string sqlAll = sql;
            sql += "WHERE rn BETWEEN " + ((pageStart * maxRows) - (maxRows - 1)) + " AND " + (pageStart * maxRows);

            DataTable dataAll = con.executeReader(sqlAll);
            ViewBag.totalRows = dataAll.Rows.Count;
            ViewBag.currentPage = pageStart;

            DataTable popUp = con.executeReader(sql);
            var model = new purchaseOrderHeader();
            if (popUp != null)
            {
                foreach (DataRow dr in popUp.Rows)
                {
                    var editor = new purchaseOrderHeader.POpopUp()
                    {
                        poId = dr["poId"].ToString(),
                        poDate = Convert.ToDateTime(dr["poDate"].ToString()),
                        vendorId = dr["vendorId"].ToString(),
                        vendorName = dr["vendorName"].ToString(),
                        poUrgent = dr["poUrgent"].ToString(),
                    };
                    model.PopUpPO.Add(editor);
                }
                ViewBag.POPopUp = model.PopUpPO.ToList();
            }

            return PartialView("_PartialPagePopUpPOSearchSub");
        }
Esempio n. 2
0
        public async Task<ActionResult> LoadPopUpPO(string poId)
        {
            var x = db.purchaseOrderHeaders
                    .Join(db.vendors, a => a.vendorId, b => b.vendorID, (a, b) => new { a, b })
                                        .Select(c => new { c.a.poId, c.a.poDate, c.a.vendorId, c.b.vendorName, c.a.poUrgent }).ToList();
            if(poId != string.Empty)
               x = db.purchaseOrderHeaders.Where(po=>po.poId == poId)
                   .Join(db.vendors, a => a.vendorId, b => b.vendorID, (a, b) => new { a, b })
                    .Select(c => new { c.a.poId, c.a.poDate, c.a.vendorId, c.b.vendorName, c.a.poUrgent }).ToList();

            var model = new purchaseOrderHeader();
            foreach(var y in x as IEnumerable<Models.purchaseOrderHeader.POpopUp>)
            {
                var editor = new purchaseOrderHeader.POpopUp()
                {
                    poId = y.poId,
                    poDate = y.poDate,
                    vendorId = y.vendorId,
                    vendorName = y.vendorName,
                    poUrgent = y.poUrgent
                };
                model.PopUpPO.Add(editor);
            }
            ViewBag.PopUpPO = model.PopUpPO.ToList();
            return PartialView("~/Views/Shared/_PartialPagePopUpPO.cshtml");
        }
        public ActionResult Approval(string id)
        {
            if (acm.cekSession() == false)
                return RedirectToAction("Logout", "Account");

            lvm = Session["sessionUserLogin"] as LoginViewModel.userLogin;

            ViewBag.ApprovalAuth = false;
            foreach (string b in lvm.listAuthorize as List<string>)
            {
                string[] auth = b.Split('_');
                if (auth[0].ToString() == "A1")
                    if (b.Contains((Url.Action("")).Replace("/", "")))
                    {
                        ViewBag.ApprovalAuth = true;
                    }
            }
            if (ViewBag.ApprovalAuth == false && lvm.isAdmin == true)
                ViewBag.ApprovalAuth = true;

            if (ViewBag.ApprovalAuth == false && lvm.isAdmin == false)
                return RedirectToAction("NotAuthorized", "Account", new { menu = Url.Action().ToString() });

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            purchaseReceive purchasereceive = db.purchaseReceives.Find(id);
            if (purchasereceive == null)
            {
                return HttpNotFound();
            }

            var popUp = db.purchaseOrderHeaders.AsNoTracking().Where(x => !db.purchaseReceives.Any(y => y.poId == x.poId))
                                .Join(db.vendors, a => a.vendorId, b => b.vendorID, (a, b) => new { a, b })
                                .Select(c => new { c.a.poId, c.a.poDate, c.b.vendorID, c.b.vendorName, c.a.poUrgent }).ToList();
            var aa = db.purchaseReceives.Where(x => x.receiveNo == "RCV").ToList();
            var model = new purchaseOrderHeader();
            for (int i = 0; i < popUp.Count; i++)
            {
                var editor = new purchaseOrderHeader.POpopUp()
                {
                    poId = popUp[i].poId,
                    poDate = popUp[i].poDate,
                    vendorId = popUp[i].vendorID,
                    vendorName = popUp[i].vendorName,
                    poUrgent = popUp[i].poUrgent
                };
                model.PopUpPO.Add(editor);
            }
            ViewBag.POPopUp = model.PopUpPO.ToList();

            loadRCV(purchasereceive.receiveNo);
            return View(purchasereceive);
        }
        // GET: /PurchaseReceive/Delete/5
        public ActionResult Delete(string id)
        {
            if (acm.cekSession() == false)
                return RedirectToAction("Logout", "Account");

            lvm = Session["sessionUserLogin"] as LoginViewModel.userLogin;
            if (acm.cekValidation(Url.Action().ToString()) == false && lvm.isAdmin == false)
                return RedirectToAction("NotAuthorized", "Account", new { menu = Url.Action().ToString() });

            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            purchaseReceive purchasereceive = db.purchaseReceives.Find(id);
            if (purchasereceive == null)
            {
                return HttpNotFound();
            }

            var popUp = db.purchaseOrderHeaders.AsNoTracking().Where(x => !db.purchaseReceives.Any(y => y.poId == x.poId))
                                .Join(db.vendors, a => a.vendorId, b => b.vendorID, (a, b) => new { a, b })
                                .Select(c => new { c.a.poId, c.a.poDate, c.b.vendorID, c.b.vendorName, c.a.poUrgent }).ToList();
            var aa = db.purchaseReceives.Where(x => x.receiveNo == "RCV").ToList();
            var model = new purchaseOrderHeader();
            for (int i = 0; i < popUp.Count; i++)
            {
                var editor = new purchaseOrderHeader.POpopUp()
                {
                    poId = popUp[i].poId,
                    poDate = popUp[i].poDate,
                    vendorId = popUp[i].vendorID,
                    vendorName = popUp[i].vendorName,
                    poUrgent = popUp[i].poUrgent
                };
                model.PopUpPO.Add(editor);
            }
            ViewBag.POPopUp = model.PopUpPO.ToList();

            loadRCV(purchasereceive.receiveNo);
            return View(purchasereceive);
        }
        // GET: /PurchaseReceive/Create
        public ActionResult Create()
        {
            if (acm.cekSession() == false)
                return RedirectToAction("Logout", "Account");

            lvm = Session["sessionUserLogin"] as LoginViewModel.userLogin;
            if (acm.cekValidation(Url.Action().ToString()) == false && lvm.isAdmin == false)
                return RedirectToAction("NotAuthorized", "Account", new { menu = Url.Action().ToString() });

            var popUp = db.purchaseOrderHeaders.AsNoTracking().Where(x => !db.purchaseReceives.Any(y => y.poId == x.poId) && x.proposedStatus == true && x.approvedStatus == true)
                                .Join(db.vendors, a => a.vendorId, b => b.vendorID, (a, b) => new { a, b })
                                .Select(c => new { c.a.poId, c.a.poDate, c.b.vendorID, c.b.vendorName, c.a.poUrgent}).ToList();

            var aa = db.purchaseReceives.Where(x => x.receiveNo == "RCV").ToList();

            var model = new purchaseOrderHeader();
            for (int i = 0; i < popUp.Count; i++)
            {
                var editor = new purchaseOrderHeader.POpopUp()
                {
                    poId = popUp[i].poId,
                    poDate = popUp[i].poDate,
                    vendorId = popUp[i].vendorID,
                    vendorName = popUp[i].vendorName,
                    poUrgent = popUp[i].poUrgent
                };
                model.PopUpPO.Add(editor);
            }
            ViewBag.POPopUp = model.PopUpPO.ToList();
            ViewBag.totalRows = model.PopUpPO.Count;

            return View();
        }