Пример #1
0
        public ActionResult CountText(FormCollection formCollection)
        {
            string dateFirst = null;

            if (formCollection["inputDayFirst"] != "")
            {
                dateFirst = formCollection["inputDayFirst"];
            }
            string dateLast = null;

            if (formCollection["inputDayLast"] != "")
            {
                dateLast = formCollection["inputDayLast"];
            }
            Session["dateFirst"] = dateFirst;
            Session["dateLast"]  = dateLast;

            string idLoaiCongVan = null;

            if (formCollection["IDLoaiCongVan"] != "")
            {
                idLoaiCongVan = formCollection["IDLoaiCongVan"];
            }
            string idPhongBan = null;

            if (formCollection["IDPhongBan"] != "")
            {
                idPhongBan = formCollection["IDPhongBan"];
            }
            string idDonViGui = null;

            if (formCollection["IDDonViGui"] != "")
            {
                idDonViGui = formCollection["IDDonViGui"];
            }
            Session["IDLoaiCongVan"] = idLoaiCongVan;
            Session["IDPhongBan"]    = idPhongBan;
            Session["IDDonViGui"]    = idDonViGui;

            int countTextGo, countTextTo;

            if ((dateFirst == null && dateLast != null) || (dateFirst != null && dateLast == null))
            {
                var script = @"alert(""Vui lòng chọn đầy đủ thông tin ngày!!!"");";
                return(JavaScript(script));
            }
            if (dateFirst == null && dateLast == null)
            {
                countTextGo = _data.TimKiemCongVanDi_2(idPhongBan, idDonViGui, idLoaiCongVan).Count();
                countTextTo = _data.TimKiemCongVanDen_2(idPhongBan, idDonViGui, idLoaiCongVan).Count();
            }
            else
            {
                countTextGo = _data.TimKiemCongVanDi(DateTime.Parse(dateFirst), DateTime.Parse(dateLast), idPhongBan, idDonViGui, idLoaiCongVan).Count();
                countTextTo = _data.TimKiemCongVanDen(DateTime.Parse(dateFirst), DateTime.Parse(dateLast), idPhongBan, idDonViGui, idLoaiCongVan).Count();
            }

            var statistical = new Statistical()
            {
                CountTextTo = countTextTo,
                CountTextGo = countTextGo,
                SUM         = countTextTo + countTextGo
            };

            return(View(statistical));
        }