Esempio n. 1
0
        public ActionResult SearchImport()
        {
            try
            {
                var table    = new StringBuilder();
                var datefrom = DateTime.ParseExact(Request["DateFrom"], "dd/MM/yyyy", null);
                var dateto   = DateTime.ParseExact(Request["DateTo"], "dd/MM/yyyy", null);
                var iService = new ImportService();
                var pService = new ProviderService();
                var tService = new StockService();
                var imports  = iService.GetExportByDate(datefrom, dateto);


                table.Append("<table id='table1' class='table1'>");
                table.Append("<thead>");
                table.Append("<tr>");
                table.Append("<th>Nhà cung cấp</th>");
                table.Append("<th>Ngày giờ</th>");
                table.Append("<th>Tên kho</th>");
                table.Append("</tr>");
                table.Append("</thead>");

                table.Append("<tbody>");
                foreach (var import in imports)
                {
                    var provider = pService.GetProviderById(import.ProviderId);
                    var stock    = tService.GetStockById(import.StockId);
                    table.Append("<tr>");
                    table.AppendFormat("<td>{0}</td>", provider.Name);
                    table.AppendFormat("<td>{0}</td>", import.CreatedDate.ToShortDateString());
                    table.AppendFormat("<td>{0}</td>", stock.Name);
                    table.Append("</tr>");
                }


                table.Append("</tbody>");
                table.Append("</table>");

                return(Json(new
                {
                    finish = true,
                    data = table.ToString()
                }));
            }
            catch (Exception e)
            {
                return(Json(new { finish = false, data = e.ToString() }));
            }
        }