/// <summary> /// 这个事件会在渲染每一行前调用,因此改变了列的属性,那么渲染每一行时此列的属性都发生了变化 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Grid1_PreRowDataBound(object sender, FineUI.GridPreRowEventArgs e) { LinkButtonField lbfAction1 = Grid1.FindColumn("lbfAction1") as LinkButtonField; LinkButtonField lbfAction2 = Grid1.FindColumn("lbfAction2") as LinkButtonField; CheckBoxField cbxAtSchool = Grid1.FindColumn("cbxAtSchool") as CheckBoxField; if (e.RowIndex < 5) { cbxAtSchool.Enabled = true; lbfAction1.Enabled = true; lbfAction2.Enabled = true; } else { cbxAtSchool.Enabled = false; lbfAction1.Enabled = false; lbfAction2.Enabled = false; } // 如果绑定到 DataTable,那么这里的 DataItem 就是 DataRowView HyperLinkField linkField = Grid1.Columns[4] as HyperLinkField; DataRowView row = e.DataItem as DataRowView; if (row != null) { linkField.DataTextFormatString = "{0} (" + row["EntranceYear"].ToString() + ")"; } }
//RDFNew.Module.Admin.Flow.Flow_DeployD Tmp_DALD=null ; protected void Grid1_PreRowDataBound(object sender, FineUI.GridPreRowEventArgs e) { //LinkButtonField lkbDeploy = Grid1.FindColumn("lkbSubmit") as LinkButtonField; //lkbDeploy.Enabled =false ; //DataRowView row = e.DataItem as DataRowView; //if (row != null) //{ // DS.XBPM.API.ProcessInstance ins = App_Com.FlowHelper.Engine.GetExecutionService().FindProcessInstance(row.Row["InstanceID"].ToString()); // if (ins != null) // { // string[] curActNames = ins.FindActiveExecutionNames(); // for (int j = 0; j < curActNames.Length; j++) // { // string act = curActNames[j]; // if (Tmp_DALD == null) // Tmp_DALD = new RDFNew.Module.Admin.Flow.Flow_DeployD(); // string owner = Tmp_DALD.GetActivityOwner(ins.DeploymentId, ins.ProcessName, act); // if (owner.ToUpper() == "APPLICANT" && row.Row["CrtBy"].ToString() == App_Com.Sys_User.GetUserInfo("UserID")) // { // lkbDeploy.Enabled = true; // break; // } // if (owner == App_Com.Sys_User.GetUserInfo("UserID")) // { // lkbDeploy.Enabled = true; // break; // } // } // } //} }
/// <summary> /// 添加子节点 /// </summary> /// <param name="dt"></param> /// <param name="node"></param> /// <param name="nodeid"></param> public int AddNode(DataTable dt, FineUI.TreeNode node, string nodeid) { //筛选出当前节点下面的子节点 var childdt = DataTableHelper.GetFilterData(dt, BranchTable.ParentId, nodeid, BranchTable.Sort, "Asc"); //判断是否有节点存在 if (childdt.Rows.Count > 0) { foreach (DataRow item in childdt.Rows) { //bool ispage = int.Parse(item[MenuInfo.Columns.MenuInfo_IsMenu].ToString()) == 0 ? false : true; var tnode = new FineUI.TreeNode(); //设置节点名称 tnode.Text = item[BranchTable.Name].ToString(); //设置节点ID tnode.NodeID = item[BranchTable.Id].ToString(); //是否自动扩大 tnode.Expanded = true; //if (!TreeMenu.Nodes.Contains(tnode)) node.Nodes.Add(tnode); //递归添加子节点 int count = AddNode(dt, tnode, item[BranchTable.Id].ToString()); //判断当前节点是否为最终节点 if (count == 0) { tnode.Leaf = true; } tnode.EnableClickEvent = true; } } return childdt.Rows.Count; }
protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "Action1" || e.CommandName == "Action2") { labResult.Text = String.Format("你点击了第 {0} 行,第 {1} 列,行命令是 {2}", e.RowIndex + 1, e.ColumnIndex + 1, e.CommandName); } }
/// <summary> /// Grid点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e) { GridRow gr = Grid1.Rows[e.RowIndex]; //获取主键ID var id = ConvertHelper.Cint0(gr.DataKeys[0].ToString()); //获取在线用户实体 var model = OnlineUsersBll.GetInstence().GetModelForCache(id); if (model == null) return; switch (e.CommandName) { case "GetOut": //从在线表中删除用户 OnlineUsersBll.GetInstence().UserExit(this, model.UserHashKey); //刷新当前页面 FineUI.PageContext.Refresh(); break; case "ManagerColumn": Window1.IFrameUrl = "../../Employees/ManagerView.aspx?Id=" + model.Manager_Id + "&" + MenuInfoBll.GetInstence().PageUrlEncryptStringNoKey(model.Manager_Id + ""); Window1.Hidden = false; break; case "LoginLog": Window1.IFrameUrl = "LoginLogList.aspx?Id=" + model.Manager_Id + "&" + MenuInfoBll.GetInstence().PageUrlEncryptStringNoKey(model.Manager_Id + ""); Window1.Hidden = false; break; case "UserLog": Window1.IFrameUrl = "UseLogList.aspx?Id=" + model.Manager_Id + "&" + MenuInfoBll.GetInstence().PageUrlEncryptStringNoKey(model.Manager_Id + ""); Window1.Hidden = false; break; } }
protected void Grid1_Sort(object sender, FineUI.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortField = e.SortField; BindGrid(); }
protected void gridStatistic3_RowDataBound(object sender, FineUI.GridRowEventArgs e) { if (e.DataItem != null) { Ticket ticket = e.DataItem as Ticket; IList<ActivityTicketAssign> listTa = ta.GetActivityAssignForTicket(ticket.ProductCode).ToList(); int Amount = 0; foreach (var ata in listTa) { Amount += ata.SoldAmount; } ticketSolidTotal += Amount; Literal laSolidAmount = gridStatistic3.Rows[e.RowIndex].FindControl("laTicketSolidAmount") as Literal; laSolidAmount.Text = Amount.ToString(); Literal laCheckAmount = gridStatistic3.Rows[e.RowIndex].FindControl("laTicketCheckAmount") as Literal; int checkAmount = 0; IList<TicketAssign> listTicketAssign = bllOd.GetTaForIdCardInActivity(ta.ActivityCode, ticket.Id); foreach (var item in listTicketAssign) { checkAmount++; } ticketCheckTotal += checkAmount; laCheckAmount.Text = checkAmount.ToString(); } }
/// <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> /// 绑定菜单下拉列表——只显示所有可以显示的菜单(IsMenu) /// </summary> public void BandDropDownListShowMenu(Page page, FineUI.DropDownList ddl) { //在内存中筛选记录 var dt = DataTableHelper.GetFilterData(GetDataTable(), string.Format("{0}={1}", MenuInfoTable.IsMenu, 0), MenuInfoTable.Depth + ", " + MenuInfoTable.Sort); try { //整理出有层次感的数据 dt = DataTableHelper.DataTableTidyUp(dt, MenuInfoTable.Id, MenuInfoTable.ParentId, 0); ddl.EnableSimulateTree = true; //显示值 ddl.DataTextField = MenuInfoTable.Name; //显示key ddl.DataValueField = MenuInfoTable.Id; //数据层次 ddl.DataSimulateTreeLevelField = MenuInfoTable.Depth; //绑定数据源 ddl.DataSource = dt; ddl.DataBind(); ddl.SelectedIndex = 0; ddl.Items.Insert(0, new FineUI.ListItem("请选择菜单", "0")); ddl.SelectedValue = "0"; } catch (Exception e) { // 记录日志 CommonBll.WriteLog("", e); } }
protected void authorityGrid_RowDataBound(object sender, FineUI.GridRowEventArgs e) { var chkAuthority = authorityGrid.Rows[e.RowIndex].FindControl("chkAuthority") as System.Web.UI.WebControls.CheckBoxList; dynamic row = e.DataItem as dynamic; if (row != null) { var id = row.Id; chkAuthority.DataSource = permissions.Where(m => m.ModuleId == id).ToList(); chkAuthority.DataValueField = "Id"; chkAuthority.DataTextField = "Name"; chkAuthority.DataBind(); foreach (System.Web.UI.WebControls.ListItem item in chkAuthority.Items) { var itemId = item.Value; if (currentPermissions.Exists(m => m.Id == itemId)) { item.Selected = true; } else { item.Selected = false; } } } }
protected void Grid1_Sort(object sender, FineUI.GridSortEventArgs e) { Grid1.SortDirection = e.SortDirection; Grid1.SortColumnIndex = e.ColumnIndex; BindGrid(); }
protected void itemlist_RowClick(object sender, FineUI.GridRowClickEventArgs e) { object[] rowDataKeys = itemlist.DataKeys[e.RowIndex]; if (rowDataKeys.Length < 1) return; var list = SerNoCaller.Calr_ConsignmentOrder.Get(" select * from T_ERP_ConsignmentOrder where CheckNo = @0 ", rowDataKeys[1].ToString()); Ords.DataSource = list; Ords.DataBind(); }
protected void Grid1_PageIndexChange(object sender, FineUI.GridPageEventArgs e) { SyncSelectedRowIndexArrayToHiddenField(); Grid1.PageIndex = e.NewPageIndex; UpdateSelectedRowIndexArray(); }
protected void gridTicketOwner_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "select") { Session["OwnerTicket"] = (gridTicketOwner.DataKeys[e.RowIndex][0] + "," + gridTicketOwner.DataKeys[e.RowIndex][1] + "," + gridTicketOwner.DataKeys[e.RowIndex][2]); lblOwnerScenic.Text = gridTicketOwner.DataKeys[e.RowIndex][2].ToString() + "-" + gridTicketOwner.DataKeys[e.RowIndex][1].ToString(); } }
protected void gridOwner_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "select") { Session["OwnerScenic"] = gridOwner.DataKeys[e.RowIndex][0]; lblOwnerScenic.Text = gridOwner.DataKeys[e.RowIndex][0].ToString(); } }
protected void WindowAdj_Close(object sender, FineUI.WindowCloseEventArgs e) { if (Users == null) { SetSession(); return; } BindGrid("WareName", "DESC"); }
protected void Grid1_RowDataBound(object sender, FineUI.GridRowEventArgs e) { // 行绑定后,确定应该选择哪一行 Dept dept = e.DataItem as Dept; if (dept != null && _deptID == dept.ID) { _selectedRowIndex = e.RowIndex; } }
protected void Window1_Close(object sender, FineUI.WindowCloseEventArgs e) { Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls"); Response.ContentType = "application/excel"; Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write(GetGridTableHtml(Grid1, e.CloseArgument.Split('#'))); Response.End(); }
protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "Action1" || e.CommandName == "Action2") { object[] keys = Grid1.DataKeys[e.RowIndex]; labResult.Text = String.Format("你点击了第 {0} 行,第 {1} 列,行命令是 {2}", e.RowIndex + 1, e.ColumnIndex + 1, e.CommandName) + "<br />" + String.Format("当前行数据 - 编号:{0},姓名:{1}", keys[0], keys[1]); } }
protected void itemlist_PageIndexChange(object sender, FineUI.GridPageEventArgs e) { if (Users == null) { SetSession(); return; } itemlist.PageIndex = e.NewPageIndex; BindGrid("CreateDate", "DESC"); }
public void InitIconList(FineUI.RadioButtonList iconList) { string[] icons = new string[] { "tag_yellow", "tag_red", "tag_purple", "tag_pink", "tag_orange", "tag_green", "tag_blue" }; foreach (string icon in icons) { string value = String.Format("~/icon/{0}.png", icon); string text = String.Format("<img style=\"vertical-align:bottom;\" src=\"{0}\" /> {1}", ResolveUrl(value), icon); iconList.Items.Add(new RadioItem(text, value)); } }
protected void Tree1_NodeCheck(object sender, FineUI.TreeCheckEventArgs e) { if (e.Checked) { Tree1.CheckAllNodes(e.Node.Nodes); } else { Tree1.UncheckAllNodes(e.Node.Nodes); } }
protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "Delete") { int rowID = Convert.ToInt32(Grid1.DataKeys[e.RowIndex][0]); DeleteRowByID(rowID); BindGrid(); Alert.ShowInTop("删除数据成功!(表格数据已重新绑定)"); } }
protected void Grid1_PreRowDataBound(object sender, FineUI.GridPreRowEventArgs e) { User user = e.DataItem as User; // 不能删除超级管理员 if (user.Name == "admin") { FineUI.LinkButtonField deleteField = Grid1.FindColumn("deleteField") as FineUI.LinkButtonField; deleteField.Enabled = false; deleteField.ToolTip = "不能删除超级管理员!"; } }
protected void gridTicketList_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "delete") { int ticketid = Convert.ToInt32(gridTicketList.DataKeys[e.RowIndex][0]); Ticket childT = bllTicket.GetTicket(ticketid); (CurrentTicket as TicketUnion).TicketList.Remove(childT); bllTicket.SaveOrUpdateTicket(CurrentTicket); bindTicketUnion(); // bllScenicTicket.Delete(scenicId, ticketId); } }
protected void Grid1_RowCommand(object sender, FineUI.GridCommandEventArgs e) { if (e.CommandName == "CheckBox1") { CheckBoxField checkField = (CheckBoxField)Grid1.FindColumn(e.ColumnIndex); bool checkState = checkField.GetCheckedState(e.RowIndex); Alert.ShowInTop(String.Format("你点击了第 {0} 行,第 {1} 列,选中状态:{2}", e.RowIndex + 1, e.ColumnIndex + 1, checkState)); } else if (e.CommandName == "Action1" || e.CommandName == "Action2") { Alert.ShowInTop(String.Format("你点击了第 {0} 行,第 {1} 列,行命令是 {2}", e.RowIndex + 1, e.ColumnIndex + 1, e.CommandName)); } }
/// <summary> /// 绑定下拉列表 /// </summary> public void BandDropDownList(Page page, FineUI.DropDownList ddl) { //显示值 ddl.DataTextField = UploadTypeTable.Name; //显示key ddl.DataValueField = UploadTypeTable.Id; //绑定数据源 ddl.DataSource = GetDataTable(); ddl.DataBind(); ddl.Items.Insert(0, new FineUI.ListItem("请选择上传类型", "0")); ddl.SelectedValue = "0"; }
/// <summary> /// 这个事件会在渲染每一行后调用,此时 Values 属性保存了每一项渲染后的 HTML 片段 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Grid1_RowDataBound(object sender, FineUI.GridRowEventArgs e) { // e.DataItem -> System.Data.DataRowView 或者自定义类 // e.RowIndex -> 当前行序号(从 0 开始) // e.Values -> 当前行每一列渲染后的 HTML 片段 //object a = Grid1.DataKeys[e.RowIndex][0]; DataRowView row = e.DataItem as DataRowView; if (row != null) { e.Values[4] = String.Format("{0} ({1})", e.Values[4], row["EntranceYear"]); } }
/// <summary> /// 从隐藏字段中获取选择的全部ID列表 /// </summary> /// <param name="hfSelectedIDS"></param> /// <returns></returns> public List<int> GetSelectedIDsFromHiddenField(FineUI.HiddenField hfSelectedIDS) { JArray idsArray = new JArray(); string currentIDS = hfSelectedIDS.Text.Trim(); if (!String.IsNullOrEmpty(currentIDS)) { idsArray = JArray.Parse(currentIDS); } else { idsArray = new JArray(); } return new List<int>(idsArray.ToObject<int[]>()); }
/// <summary> /// 绑定菜单下拉列表——只显示一级菜单 /// </summary> public void BandDropDownList(Page page, FineUI.DropDownList ddl) { var dt = DataTableHelper.GetFilterData(GetDataTable(), MenuInfoTable.ParentId, "0", MenuInfoTable.Sort, "desc"); //显示值 ddl.DataTextField = MenuInfoTable.Name; //显示key ddl.DataValueField = MenuInfoTable.Id; //绑定数据源 ddl.DataSource = dt; ddl.DataBind(); ddl.Items.Insert(0, new FineUI.ListItem("请选择菜单", "0")); ddl.SelectedValue = "0"; }