public string Export_Import_post(HttpContext context) { // try // { FileInfo file = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + context.Request["file"]); DataTable dt = NPOIHelper.ImportFromExcel(file.FullName).Tables[0]; //DataView dv = dt.DefaultView; //dv.Sort = "财务编号 ASC"; SqlQuery[] querys = new SqlQuery[dt.Rows.Count]; int i = 0; DateTime importTime = DateTime.Now; foreach (DataRow dr in dt.Rows) { const string insertSql = @" "; } int rows = IocObject.GetDao().ExecuteNonQuery(querys); if (rows < 0) { rows = 0; } return("{result:true,message:'导入完成,共导入" + rows.ToString() + "条!'}"); /* } * catch (Exception exc) * { * return "{result:false,message:'"+exc.Message+"!'}"; * }*/ }
public DataTable GetQueryView(string queryName, Hashtable hash, int pageSize, int currentPageIndex, out int totalCount) { DataBaseAccess db = IocObject.GetDao(); string query = this.GetConfigByQueryName(queryName).Query; string queryTotal = this.GetConfigByQueryName(queryName).Total; //添加分页参数 if (hash != null) { foreach (DictionaryEntry o in hash) { if (reg.IsMatch(o.Value.ToString())) { throw new ArgumentException("含有不安全的查询!"); } } hash.Add("page_start", currentPageIndex <= 0?0:(currentPageIndex - 1) * pageSize); hash.Add("page_end", (currentPageIndex) * pageSize); hash.Add("page_size", pageSize); //格式化 query = query.Template(hash); // throw new Exception(query + "/" + currentPageIndex+"/"+pageSize); if (!String.IsNullOrEmpty(queryTotal)) { queryTotal = queryTotal.Template(hash); } } //获取分页结果 DataTable dataTable = db.GetDataSet(query, hash).Tables[0]; //获取统计数据 if (!String.IsNullOrEmpty(queryTotal)) { object data = db.ExecuteScalar(queryTotal, hash); int.TryParse(data.ToString(), out totalCount); } else { totalCount = dataTable.Rows.Count; } return(dataTable); }