/// <summary> /// 绑定Grid表格,并实现分页 /// </summary> /// <param name="grid">表格控件</param> /// <param name="pageIndex">第几页</param> /// <param name="pageSize">每页显示记录数量</param> /// <param name="wheres">查询条件</param> /// <param name="sorts">排序</param> public override void BindGrid(FineUI.Grid grid, int pageIndex = 0, int pageSize = 0, List <ConditionHelper.SqlqueryCondition> wheres = null, List <string> sorts = null) { //用于统计执行时长(耗时) var swatch = new Stopwatch(); swatch.Start(); try { // 1.设置总项数 grid.RecordCount = GetRecordCount(wheres); // 2.如果不存在记录,则清空Grid表格 if (grid.RecordCount == 0) { grid.Rows.Clear(); // 查询并绑定到Grid grid.DataBind(); grid.AllowPaging = false; } else { //3.查询并绑定到Grid grid.DataSource = GetDataTable(false, 0, null, pageIndex, pageSize, wheres, sorts); grid.DataBind(); } } catch (Exception e) { // 记录日志 CommonBll.WriteLog("获取用户操作日志表记录时出现异常", e); } // 统计结束 swatch.Stop(); // 计算查询数据库使用时间,并存储到Session里,以便UI显示 HttpContext.Current.Session["SpendingTime"] = (swatch.ElapsedMilliseconds / 1000.00).ToString(); }
/// <summary> /// 绑定Grid表格,使用内存分页,显示有层次感 /// </summary> /// <param name="grid">表格控件</param> /// <param name="parentValue">父Id值</param> /// <param name="wheres">查询条件</param> /// <param name="sorts">排序</param> /// <param name="parentId">父Id</param> public override void BindGrid(FineUI.Grid grid, int parentValue, List <ConditionFun.SqlqueryCondition> wheres = null, List <string> sorts = null, string parentId = "ParentId") { //用于统计执行时长(耗时) var swatch = new Stopwatch(); swatch.Start(); try { // 查询数据库 var dt = GetDataTable(false, 0, null, 0, 0, wheres, sorts); // 对查询出来的记录进行层次处理 grid.DataSource = DataTableHelper.DataTableTidyUp(dt, "Id", parentId, parentValue); // 查询并绑定到Grid grid.DataBind(); } catch (Exception e) { // 记录日志 CommonBll.WriteLog("绑定表格时出现异常", e); } //统计结束 swatch.Stop(); //计算查询数据库使用时间,并存储到Session里,以便UI显示 HttpContext.Current.Session["SpendingTime"] = (swatch.ElapsedMilliseconds / 1000.00).ToString(); }
/// <summary> /// 绑定菜单下拉列表——只显示一级菜单 /// </summary> public void BandMenuInfoList1(Page page, FineUI.Grid grid) { //在内存中筛选记录 var dt1 = DataTableHelper.GetFilterData(GetDataTable(), string.Format("{0}={1} or {2} = {3}", MenuInfoTable.IsMenu, 1, MenuInfoTable.IsMenu, 0), MenuInfoTable.Depth + ", " + MenuInfoTable.Sort); //var dt2 = DataTableHelper.GetFilterData(GetDataTable(), string.Format("{0} in {1}", MenuInfoTable.Id, _PagePower), MenuInfoTable.Depth + ", " + MenuInfoTable.Sort); try { //整理出有层次感的数据 // dt_2 = DataTableHelper.DataTableTidyUp(dt2, MenuInfoTable.Id, MenuInfoTable.ParentId, 0); grid.DataSource = DataTableHelper.DataTableTidyUp(dt1, MenuInfoTable.Id, MenuInfoTable.ParentId, 0); grid.DataBind(); //grid2.DataSource = dt_2; //grid2.DataBind(); //grid3.DataSource = dt3; //grid3.DataBind(); } catch (Exception e) { // 记录日志 CommonBll.WriteLog("", e); } }
/// <summary> /// 绑定Grid表格,使用内存分页,显示有层次感 /// </summary> /// <param name="grid">表格控件</param> /// <param name="parentValue">父Id值</param> /// <param name="wheres">查询条件</param> /// <param name="sorts">排序</param> /// <param name="parentId">父Id</param> public override void BindGrid(FineUI.Grid grid, int parentValue, List <ConditionHelper.SqlqueryCondition> wheres = null, List <string> sorts = null, string parentId = "ParentId") { //用于统计执行时长(耗时) var swatch = new Stopwatch(); swatch.Start(); try { // 查询数据库 var dt = GetDataTable(false, 0, null, 0, 0, wheres, sorts); // 1.设置总项数 grid.RecordCount = dt == null ? 0 : dt.Rows.Count; // 2.如果不存在记录,则清空Grid表格 if (grid.RecordCount == 0) { grid.Rows.Clear(); // 查询并绑定到Grid grid.DataBind(); grid.AllowPaging = false; } else { // 对查询出来的记录进行层次处理 grid.DataSource = DataTableHelper.DataTableTidyUp(dt, "Id", parentId, parentValue); // 查询并绑定到Grid grid.DataBind(); grid.AllowPaging = true; } } catch (Exception e) { // 记录日志 CommonBll.WriteLog("绑定表格时出现异常", e); } //统计结束 swatch.Stop(); //计算查询数据库使用时间,并存储到Session里,以便UI显示 HttpContext.Current.Session["SpendingTime"] = (swatch.ElapsedMilliseconds / 1000.00).ToString(); }
/// <summary> /// 绑定菜单下拉列表——显示所有的数据 /// </summary> public void BandGrid(Page page, FineUI.Grid Grid1, int ret, string orddep_id) { //在内存中筛选记录 try { DataTable dt = (DataTable)SPs.Get_ORDER_DEP01_SHOP(ret, orddep_id).ExecuteDataTable(); Grid1.DataSource = dt; Grid1.DataBind(); } catch (Exception e) { // 记录日志 CommonBll.WriteLog("", e); } }
/// <summary> /// 绑定菜单下拉列表——只显示所有可以显示的菜单(IsMenu) /// </summary> public void BandPagePowerSignPublicList(Page page, FineUI.Grid grid) { //在内存中筛选记录 string.Format("{0}={1}", BranchTable.IsMenu, 0) var dt = DataTableHelper.GetFilterData(GetDataTable(), string.Format("{0} is not null", PagePowerSignPublicTable.Id), PagePowerSignPublicTable.Id); try { grid.DataSource = dt; grid.DataBind(); } catch (Exception e) { // 记录日志 CommonBll.WriteLog("", e); } }
/// <summary> /// 绑定菜单下拉列表——只显示所有可以显示的菜单(IsMenu) /// </summary> public void BandDropDownListShowMenu3(Page page, FineUI.Grid grid3, string PagePower, string ControlPower) { //在内存中筛选记录 var dt = DataTableHelper.GetFilterData(GetDataTable(), string.Format("{0}={1} or {2} = {3}", MenuInfoTable.IsMenu, 1, MenuInfoTable.IsMenu, 0), MenuInfoTable.Depth + ", " + MenuInfoTable.Sort); try { //整理出有层次感的数据 var dt3 = DataTableHelper.DataTableTidyUp2(dt, MenuInfoTable.Id, MenuInfoTable.ParentId, 0, PagePower); grid3.DataSource = dt3; grid3.DataBind(); } catch (Exception e) { // 记录日志 CommonBll.WriteLog("", e); } }
public void BindOrderGrid(string st, string et, int type, string shop_name, string shop_id, FineUI.Grid grid) { DataTable da; try { DataSet dsCom = null; dsCom = (DataSet)SPs.Get_Purchase00(st, et, shop_id, type).ExecuteDataSet(); if (dsCom.Tables.Count > 0) { da = dsCom.Tables[0].Copy(); grid.DataSource = da; grid.DataBind(); } else { da = new DataTable(); } } catch { da = new DataTable(); } }
public static void upload(System.Web.UI.WebControls.FileUpload FileUpload1, FineUI.Grid grid) { bool fileOK = true; //文件的上传路径 string path = HttpContext.Current.Server.MapPath("~/ExperimentTen/res/Import/"); //判断上传文件夹是否存在,若不存在,则创建 if (!Directory.Exists(path)) { //创建文件夹 Directory.CreateDirectory(path); } if (FileUpload1.HasFile) { //允许上传的类型 //string[] allowExtesions = { ".doc", ".xls", ".rar", ".zip", ".ppt" }; //for (int i = 0; i < allowExtesions.Length; i++) //{ // if (fileExtesion == allowExtesions[i]) // { // //文件格式正确 允许上传 // fileOK = true; // } //} string name = FileUpload1.FileName; // 获得上传文件的名字. int size = FileUpload1.PostedFile.ContentLength; // 文件大小. if (size > (1000000 * 1024)) { fileOK = false; // Label2.Text = "文件过大"; } string type = FileUpload1.PostedFile.ContentType;// 文件类型. // 获取上传文件的类型(后缀) string fileExtesion = System.IO.Path.GetExtension(FileUpload1.FileName).ToLower(); //string type2 = name.Substring(name.LastIndexOf(".") + 1);// LastIndexOf()最后一个索引位置匹配.Substring()里面的+1是重载. if (fileOK) { try { Random ranNum = new Random(); // 在1和1000之间的随机正整数 // int num = ranNum.Next(1, 1000); // 获取当前时间 string newname = System.DateTime.Now.ToString("yyyyMMddHHmm"); // 声明文件名,防止重复 newname = newname + name + fileExtesion; string ipath = HttpContext.Current.Server.MapPath("~/ExperimentTen/res/Import/") + "\\" + newname; // 取得根目录下面的upimg目录的路径. string fpath = HttpContext.Current.Server.MapPath("~/ExperimentTen/res/Import/") + "\\" + newname; string wpath = "~/ExperimentTen/res/Import/\\" + newname; // 获得虚拟路径 if (fileExtesion == ".jpg" || fileExtesion == ".gif" || fileExtesion == ".bmp" || fileExtesion == ".png") { FileUpload1.SaveAs(ipath); // 保存方法,参数是一个地址字符串. // Image1.ImageUrl = wpath; // Label1.Text = "你传的文件名是:" + name + "<br>文件大小为:" + size + "字节<br>文件类型是:" + type + // "<br>后缀是:" + fileExtesion + "<br>实际路径是:" + ipath + "<br>虚拟路径是:" + fpath; // Image1.Visible = true; // fileUrl.Text = ipath; } else { // Image1.Visible = false; FileUpload1.SaveAs(fpath); // Label1.Text = "你传的文件名是:" + name + "<br>文件大小为:" + size + "字节<br>文件类型是:" + type + // "<br>后缀是:" + fileExtesion + "<br>实际路径是:" + ipath + "<br>虚拟路径是:" + fpath; // fileUrl.Text = fpath; } // FileUpload1.PostedFile.SaveAs(path + newname); //Session["filename"] = newname; // Label2.Text = "上传成功"; // fileName.Text = name; // filesize.Text = size.ToString(); DataTable dt = new DataTable(); dt = NPOI_EXCEL.ExcelToDataTable(ipath, true); grid.DataSource = dt; grid.DataBind(); //lab_upload.Text = "上传成功"; } catch (Exception ex) { // Label2.Text = "上传失败"; throw ex; } } } else { //尚未选择文件 // Label2.Text = "尚未选择任何文件,请选择文件"; return; } }