예제 #1
0
        public ActionResult Index(int?page)
        {
            int pageIndex = PagingHelper.GetPageIndex(page);

            BatchOrderTemplateSearchModel q = new BatchOrderTemplateSearchModel();

            IBatchOrderTemplateService bot = new BatchOrderTemplateService(Settings.Default.db);

            IPagedList <BatchOrderTemplate> bots = bot.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            return(View(bots));
        }
예제 #2
0
        public ActionResult Search([Bind(Include = "OrderNr, PartNr, Type, Remark1")] BatchOrderTemplateSearchModel q)
        {
            int pageIndex = 0;

            int.TryParse(Request.QueryString.Get("page"), out pageIndex);
            pageIndex = PagingHelper.GetPageIndex(pageIndex);

            IBatchOrderTemplateService bot = new BatchOrderTemplateService(Settings.Default.db);

            IPagedList <BatchOrderTemplate> bots = bot.Search(q).ToPagedList(pageIndex, Settings.Default.pageSize);

            ViewBag.Query = q;

            return(View("Index", bots));
        }
예제 #3
0
        public void Export([Bind(Include = "OrderNr, PartNr, Type, Remark1")] BatchOrderTemplateSearchModel q)
        {
            IBatchOrderTemplateService bots = new BatchOrderTemplateService(Settings.Default.db);

            List <BatchOrderTemplate> bot = bots.Search(q).ToList();

            ViewBag.Query = q;

            MemoryStream ms = new MemoryStream();

            using (StreamWriter sw = new StreamWriter(ms, Encoding.UTF8))
            {
                List <string> head = new List <string> {
                    " No.", "OrderNr", "PartNr", "BatchQuantity", "Type", "Bundle", "CreatedAt", "UpdatedAt", "Operator", "Remark1", "Remark2", "Action"
                };
                sw.WriteLine(string.Join(Settings.Default.csvDelimiter, head));
                for (var i = 0; i < bot.Count; i++)
                {
                    List <string> ii = new List <string>();
                    ii.Add((i + 1).ToString());
                    ii.Add(bot[i].orderNr);
                    ii.Add(bot[i].partNr);
                    ii.Add(bot[i].batchQuantity.ToString());
                    ii.Add(bot[i].type.ToString());
                    ii.Add(bot[i].bundle.ToString());
                    ii.Add(bot[i].createdAt.ToString());
                    ii.Add(bot[i].updatedAt.ToString());
                    ii.Add(bot[i].@operator);
                    ii.Add(bot[i].remark1);
                    ii.Add(bot[i].remark2);
                    ii.Add("");
                    sw.WriteLine(string.Join(Settings.Default.csvDelimiter, ii.ToArray()));
                }
                //sw.WriteLine(max);
            }
            var filename    = "BatchOrderTemplate" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv";
            var contenttype = "text/csv";

            Response.Clear();
            Response.ContentEncoding = Encoding.UTF8;
            Response.ContentType     = contenttype;
            Response.AddHeader("content-disposition", "attachment;filename=" + filename);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.BinaryWrite(ms.ToArray());
            Response.End();
        }