Ejemplo n.º 1
0
        public PartialViewResult IndexPartialView(DateTime?fromdate, DateTime?todate,
                                                  int?customerId, string customerName, int?salerId, string salerName,
                                                  int?accountantId, string accountantName, int?status, int?areaId, string areaName, int?currentPageIndex)
        {
            if (string.IsNullOrEmpty(areaName))
            {
                areaId = 0;
            }

            if (string.IsNullOrEmpty(customerName))
            {
                customerId = 0;
            }
            if (string.IsNullOrEmpty(salerName))
            {
                salerId = 0;
            }
            if (string.IsNullOrEmpty(accountantName))
            {
                accountantId = 0;
            }
            if (fromdate == null)
            {
                fromdate = SystemConstant.MIN_DATE;
            }
            else
            {
                ViewBag.FromDate = DateTime.Parse(fromdate.ToString()).ToString("dd/MM/yyyy");
            }

            if (todate == null)
            {
                todate = SystemConstant.MAX_DATE;
            }
            else
            {
                ViewBag.toDate = DateTime.Parse(todate.ToString()).ToString("dd/MM/yyyy");
            }
            if (!(bool)Session["IsAdmin"] && !(bool)Session["IsAccounting"])
            {
                salerId = Convert.ToInt32(Session["UserId"]);
            }
            if (!(bool)Session["IsAdmin"] && !(bool)Session["IsAccounting"])
            {
                accountantId = Convert.ToInt32(Session["UserId"]);
            }
            var ctx  = new SmsContext();
            var list = ctx.SP_GET_HOA_DON_BH(fromdate, todate, Convert.ToInt32(customerId), customerName,
                                             Convert.ToInt32(salerId), salerName, Convert.ToInt32(accountantId), accountantName, Convert.ToInt32(status),
                                             Convert.ToInt32(areaId), areaName).OrderByDescending(uh => uh.NGAY_BAN).Take(SystemConstant.MAX_ROWS).ToList <SP_GET_HOA_DON_BH_Result>();
            var AllValue = ctx.SP_GET_VALUE_ALL_HOA_DON(fromdate, todate, Convert.ToInt32(customerId), customerName,
                                                        Convert.ToInt32(salerId), salerName, Convert.ToInt32(accountantId), accountantName, Convert.ToInt32(status),
                                                        Convert.ToInt32(areaId), areaName).FirstOrDefault();
            HoaDonBHModel model     = new HoaDonBHModel();
            int           pageSize  = SystemConstant.ROWS;
            int           pageIndex = currentPageIndex == null ? 1 : (int)currentPageIndex;

            model.HoaDonList = list.ToPagedList(pageIndex, pageSize);
            model.PageCount  = list.Count;
            model.AllValue   = AllValue;

            ViewBag.customerName   = customerName;
            ViewBag.salerName      = salerName;
            ViewBag.accountantName = accountantName;
            ctx.Dispose();
            return(PartialView("IndexPartialView", model));
        }