/// <summary> /// 获得URL参数 /// </summary> private void GetUrlParameter() { if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != "") { this.CodeGroupID = NDConvert.ToInt64(Request.QueryString["ID"].ToString()); } }
/// <summary> /// 邦定GridView /// </summary> private void BindGridView() { long UserID = NDConvert.ToInt64(Session["UserID"]); //当前管理操作的中 DataSet ds = GetData(UserID.ToString()); DataTable dt = ds.Tables[1]; grid.DataSource = dt; grid.DataBind(); BindviewPage(NDConvert.ToInt32(ds.Tables[0].Rows[0][0].ToString())); for (int i = 0; i < grid.Rows.Count; i++) { long ID = NDConvert.ToInt64(grid.DataKeys[i]["SID"].ToString()); DataTable GetSurveyInfo = new SurveyManage_Layer().GetSurveyTable(ID.ToString(), UserID.ToString()); //编辑 //LinkButton objEdit = (LinkButton)grid.Rows[i].Cells[10].Controls[0]; //System.Web.UI.WebControls.Image image2 = new System.Web.UI.WebControls.Image(); //image2.Style.Add("margin", "0"); //image2.ImageUrl = "images/edit2.gif"; //objEdit.Text = "编辑"; //grid.Rows[i].Cells[10].Controls.AddAt(0, image2); } }
/// <summary> /// toolbar /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": int succeed = 0; for (int i = 0; i < grid.Rows.Count; i++) { CheckBox chkItem = (CheckBox)grid.Rows[i].FindControl("chkItem"); if (chkItem != null && chkItem.Checked == true) { this.FID = NDConvert.ToInt64(grid.DataKeys[i]["FID"].ToString()); MenuFunctionEntity entity = new MenuFunctionEntity(FID); entity.IsDeleted = true; new MenuFunctionRule().Update(entity); succeed++; } } if (succeed > 0) { BindGridView(); PageHelper.ShowMessage("删除成功!"); } break; } }
/// <summary> /// 部门下拉框 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void drpOUList_SelectedIndexChanged(object sender, EventArgs e) { if (drpOUList.SelectedIndex == 0) { drpChildList.Visible = false; } else { if (new OUQuery().IsOUParent(NDConvert.ToInt64(drpOUList.SelectedValue))) { drpChildList.Visible = true; BindOUList(NDConvert.ToInt64(drpOUList.SelectedValue)); } else { drpChildList.Visible = false; if (drpOUList.SelectedIndex != 0) { drpPersonList.Enabled = true; BindPerson(NDConvert.ToInt64(drpOUList.SelectedValue), 0); BindTreeView(); } else { drpPersonList.Enabled = false; tvRight.ClearAll(); } } } }
/// <summary> /// 获取url参数 /// </summary> public void LoadGetUrlPara() { if (!string.IsNullOrEmpty(Request.QueryString["userid"])) { UserID = NDConvert.ToInt64(Request.QueryString["userid"]); } }
/// <summary> /// 邦定人员 /// </summary> private void BindPerson(long OUID, int flag) { drpPersonList.Items.Clear(); DataTable dt = null; if (flag == 0) { if (OUID == 0) { dt = new UserQuery().GetRightOUUser(NDConvert.ToInt64(drpOUList.SelectedValue)); } else { dt = new UserQuery().GetRightOUUser(OUID); } } else { if (OUID == 0) { dt = new UserQuery().GetRightOUUser(NDConvert.ToInt64(drpChildList.SelectedValue)); } else { dt = new UserQuery().GetRightOUUser(OUID); } } NDHelperWebControl.LoadDropDownList(drpPersonList, dt, "UserName", "UserID", new ListItem("请选择", "0")); }
/// <summary> /// toolbar事件 /// 作者:姚东 /// 时间:20101025 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": string cid = ""; int count = 0; int num = 0; for (int i = 0; i < grid.Rows.Count; i++) { CheckBox chkItem = (CheckBox)grid.Rows[i].FindControl("chkItem"); if (chkItem != null && chkItem.Checked == true) { count++; cid = grid.DataKeys[i]["CID"].ToString(); SurveyClassEntity entity = new SurveyClassEntity(NDConvert.ToInt64(cid)); new SurveyClassRule().Delete(entity); } } if (count == this.grid.Rows.Count) { viewpage1.CurrentPageIndex = viewpage1.CurrentPageIndex == 1 ? 1 : viewpage1.CurrentPageIndex - 1; } BindGridView(); PageHelper.ShowMessage("停用成功!"); if (num > 0) { PageHelper.ShowExceptionMessage("部分(已审核、禁用)信息无法停用!"); } break; } }
public void initToolBar() { if (!IsPostBack) { long UserID = NDConvert.ToInt64(Session["UserID"]); //当前管理操作的中 if (UserID > 0) { int userType = ConvertInt(new SurveyManage_Layer().GetUserType(ConvertString(UserID))); if (userType == (int)CommonEnum.QSUserType.AdminUserType) { MenuItem Pass = new MenuItem(); Pass.Text = "审批通过"; Pass.Value = "Pass"; Pass.ImageUrl = "../web/Images/icon/accept.png"; MenuItem Invalid = new MenuItem(); Invalid.Text = "审批退回"; Invalid.Value = "Invalid"; Invalid.ImageUrl = "../web/Images/icon/arrow_undo.png"; this.toolbar.Items.Add(Pass); this.toolbar.Items.Add(Invalid); } else if (userType == (int)CommonEnum.QSUserType.CommonUserType) { } MenuItem ReInput = new MenuItem(); ReInput.Text = "重新提交审批"; ReInput.Value = "ReInput"; ReInput.ImageUrl = "../web/Images/icon/arrow_redo.jpg"; this.toolbar.Items.Add(ReInput); } } }
/// <summary> /// 数据行操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = NDConvert.ToInt32(e.CommandArgument); long ID = NDConvert.ToInt64(grid.DataKeys[rowIndex]["ID"].ToString()); ExchangeEntity entity = new ExchangeEntity(ID); switch (e.CommandName) { case "Status": //GiftsEntity entity = new GiftsEntity(GiftID); if (entity.Status == (int)CommonEnum.GiftExchangeStatus.ForExchange) { entity.Status = (int)CommonEnum.GiftExchangeStatus.HasExchange; entity.ExchangeTime = DateTime.Now; new ExchangeRule().Update(entity); new HuiYuanRule().UpdateRemainPoint(entity.HuiYuanGuid, entity.UsedPoint); PageHelper.ShowMessage("状态更改成功!"); BindGridView(); } break; case "View": PageHelper.WriteScript("window.open('../../Web/Gifts/ImagePhoto.aspx?ID=" + entity.GiftGuid + "');"); break; } }
/// <summary> /// toolbar事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": for (int i = 0; i < grid.Rows.Count; i++) { CheckBox chkItem = (CheckBox)grid.Rows[i].FindControl("chkItem"); if (chkItem != null && chkItem.Checked == true) { this.CodeDetailID = NDConvert.ToInt64(grid.DataKeys[i]["CodeDetailID"].ToString()); CodeDetailEntity entity = new CodeDetailEntity(CodeDetailID); entity.IsDeleted = true; new CodeDetailRule().Update(entity); } } this.CurOperation = (int)OperationEnum.INSERT; this.CodeDetailID = 0; txtCodeDetailName.Text = ""; txtCodeDetailValue.Text = ""; txtDetailMemo.Text = ""; BindGridView(); PageHelper.ShowMessage("删除成功!"); break; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { int RowIndex = NDConvert.ToInt32(e.CommandArgument.ToString()); this.CodeDetailID = NDConvert.ToInt64(grid.DataKeys[RowIndex].Values["CodeDetailID"].ToString()); CodeDetailEntity entity = new CodeDetailEntity(CodeDetailID); switch (e.CommandName) { case "Modify": txtCodeDetailName.Text = entity.CodeDetailName; txtCodeDetailValue.Text = entity.CodeDetailValue; txtDetailMemo.Text = entity.DetailMemo; this.CurOperation = (int)OperationEnum.UPDATE; break; case "Del": entity.IsDeleted = true; new CodeDetailRule().Update(entity); txtCodeDetailName.Text = ""; txtCodeDetailValue.Text = ""; txtDetailMemo.Text = ""; BindGridView(); this.CurOperation = (int)OperationEnum.INSERT; this.CodeDetailID = 0; PageHelper.ShowMessage("删除成功!"); break; } }
/// <summary> /// toolbar事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { long ID = 0; switch (e.Item.Value) { case "Delete": if (e.Item.Value == "Delete") { for (int i = 0; i < tvOU.CheckedNodes.Count; i++) { Infragistics.WebUI.UltraWebNavigator.Node tn = (Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[i]; if (tn.Nodes.Count > 0) { PageHelper.ShowExceptionMessage("选择删除的部门中不能包含有下级部门!"); return; } if (UserQuery.IsHavePerson(NDConvert.ToInt64(tn.DataKey.ToString()))) { PageHelper.ShowExceptionMessage("选择删除的部门中有人员,请先删除人员后再删除部门!"); return; } } for (int j = 0; j < tvOU.CheckedNodes.Count; j++) { Infragistics.WebUI.UltraWebNavigator.Node tn = (Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[j]; OUEntity entity = new OUEntity(NDConvert.ToInt64(tn.DataKey.ToString())); entity.UpdateDate = DateTime.Now; entity.IsDeleted = true; new OURule().Update(entity); } BindTreeView(); PageHelper.ShowMessage("删除成功!"); } break; case "Add": if (tvOU.CheckedNodes.Count > 0) { int tnLevel = ((Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[0]).Level; if (tnLevel >= 3) { PageHelper.ShowExceptionMessage("此处部门树视图只支持到4层!"); return; } ID = NDConvert.ToInt64(((Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[0]).DataKey.ToString()); } Page.ClientScript.RegisterStartupScript(this.GetType(), "add", "showModalWindow('OUDetailLY', '添加',600, 450, '../../web/SysManager/OUDetail.aspx?Operation=1&ID=' + " + ID + ");", true); break; case "Update": ID = NDConvert.ToInt64(((Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[0]).DataKey.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "update", "showModalWindow('OUDetailLY', '修改',600, 450, '../../web/SysManager/OUDetail.aspx?Operation=2&ID=' + " + ID + ");", true); break; } }
/// <summary> /// 保存用户设置的权限 /// </summary> private void Save() { long UserID = NDConvert.ToInt64(drpPersonList.SelectedValue); new RightQuery().DeleteUserRight(UserID); UserEntity Pentity = new UserEntity(UserID); new MenuFunctionRightQuery().DeleteUserMenuFunctionRight(UserID); Node node = null; RightEntity entity = null; MenuFunctionRightEntity mfEntity = null; for (int i = 0; i < tvRight.CheckedNodes.Count; i++) { node = (Node)tvRight.CheckedNodes[i]; switch (node.Level) { case 0: case 1: entity = new RightEntity(); entity.UserID = UserID; entity.MenuID = NDConvert.ToInt64(node.DataKey.ToString()); new RightRule().Add(entity); break; case 2: if (MenuQuery.IsHaveChileMenu(NDConvert.ToInt64(node.Parent.DataKey.ToString()))) //判断是否有子菜单,如有有子菜单说明本层是菜单,如果没有则是菜单功能项 { entity = new RightEntity(); entity.UserID = UserID; entity.MenuID = NDConvert.ToInt64(node.DataKey.ToString()); new RightRule().Add(entity); } else { mfEntity = new MenuFunctionRightEntity(); mfEntity.FID = NDConvert.ToInt64(node.DataKey.ToString()); mfEntity.UserID = UserID; mfEntity.MenuID = NDConvert.ToInt64(node.Parent.DataKey.ToString()); new MenuFunctionRightRule().Add(mfEntity); } break; case 3: mfEntity = new MenuFunctionRightEntity(); mfEntity.FID = NDConvert.ToInt64(node.DataKey.ToString()); mfEntity.UserID = UserID; mfEntity.MenuID = NDConvert.ToInt64(node.Parent.DataKey.ToString()); new MenuFunctionRightRule().Add(mfEntity); break; } } }
/// <summary> /// toolbar事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": long ID = 0; int count = 0; bool hasValidData = false; for (int i = 0; i < grid.Rows.Count; i++) { CheckBox chkItem = (CheckBox)grid.Rows[i].FindControl("chkItem"); if (chkItem != null && chkItem.Checked == true) { count++; ID = NDConvert.ToInt64(grid.DataKeys[i]["ID"].ToString()); ExchangeEntity entity = new ExchangeEntity(ID); if (entity.Status == (int)CommonEnum.GiftExchangeStatus.ForExchange) { hasValidData = true; //更新礼品兑换状态 entity.Status = (int)CommonEnum.GiftExchangeStatus.HasDrop; new ExchangeRule().Update(entity); //更新会员积分 PointEntity pointEntity = new PointEntity(entity.HuiYuanGuid); pointEntity.RemainPoint += entity.UsedPoint; new PointRule().Update(pointEntity); //更新礼品余量 GiftsEntity giftsEntity = new GiftsEntity(entity.GiftGuid); giftsEntity.RemainAmount += 1; new GiftsRule().Update(giftsEntity); } } } if (count == this.grid.Rows.Count) { viewpage1.CurrentPageIndex = viewpage1.CurrentPageIndex == 1 ? 1 : viewpage1.CurrentPageIndex - 1; } BindGridView(); if (hasValidData) { PageHelper.ShowMessage("操作成功!"); } else { PageHelper.ShowExceptionMessage("不能对该记录进行取消操作!"); } break; } }
/// <summary> /// 检查代码名称是否已经存在 /// </summary> /// <returns></returns> public static bool IsExisitCode(long MenuID, string FCode) { string sql = "SELECT COUNT(*) FROM UT_SYS_MenuFunction WHERE IsDeleted = 0 AND MenuID = " + MenuID + " AND FCode = '" + FCode + "'"; DataTable dt = NDDBAccess.Fill(sql); if (NDConvert.ToInt64(dt.Rows[0][0].ToString()) > 0) { return(true); } return(false); }
/// <summary> /// 获得URL参数 /// 作者:姚东 /// 时间:20101027 /// </summary> private void GetUrlParameter() { if (Request.QueryString["Operation"] != null && Request.QueryString["Operation"] != "") { this.CurOperation = NDConvert.ToInt32(Request.QueryString["Operation"].ToString()); } if (Request.QueryString["ID"] != null && Request.QueryString["ID"] != "") { this.CID = NDConvert.ToInt64(Request.QueryString["ID"]); } }
/// <summary> /// 获得本地部门ID /// </summary> /// <returns></returns> public static long GetOUIDLocal(string DeptID) { string sql = "SELECT OUID FROM UT_SYS_OU WHERE IsDeleted = 0 AND OUDeptID = '" + DeptID + "' ORDER BY SortIndex"; DataTable dt = NDDBAccess.Fill(sql); if (dt.Rows.Count > 0) { return(NDConvert.ToInt64(dt.Rows[0][0].ToString())); } return(0); }
/// <summary> /// 数据行操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = NDConvert.ToInt32(e.CommandArgument); long ID = NDConvert.ToInt64(grid.DataKeys[rowIndex]["SID"].ToString()); SurveyTableEntity entity = new SurveyTableEntity(ID); int count = 0; switch (e.CommandName) { case "SurveyName": string urlAnswer = string.Format("ClientPs.aspx?SID={0}&AnswerGUID={1}", ID, ConvertString(grid.DataKeys[rowIndex]["AnswerGUID"])); PageHelper.WriteScript(string.Format("window.open('{0}');", urlAnswer)); if (count == this.grid.Rows.Count) { viewpage1.CurrentPageIndex = viewpage1.CurrentPageIndex == 1 ? 1 : viewpage1.CurrentPageIndex - 1; } BindGridView(); break; case "TempPage": BindGridView(); break; case "Statistics": BindGridView(); break; case "Options": BindGridView(); break; case "Editer": BindGridView(); break; case "DeleteAnswer": //int count = 0; string AnswerGuid = ConvertString(grid.DataKeys[rowIndex]["AnswerGUID"]); //new AnswerManager_Layer().DeleteAnswer(AnswerGuid); //彻底删除答卷 int ReturnNum = new AnswerManager_Layer().SetApprovalStaus("3", AnswerGuid); new AnswerManager_Layer().UpdateAnswerNum(ReturnNum, ID.ToString()); if (count == this.grid.Rows.Count) { viewpage1.CurrentPageIndex = viewpage1.CurrentPageIndex == 1 ? 1 : viewpage1.CurrentPageIndex - 1; } BindGridView(); break; } }
/// <summary> /// 获得URL参数 /// </summary> private void GetUrlParameter() { if (Request.QueryString["OUID"] != null && Request.QueryString["OUID"] != "") { this.OUID = NDConvert.ToInt64(Request.QueryString["OUID"].ToString()); } else { this.OUID = SessionState.OUID; } hidOUID.Value = this.OUID.ToString(); }
/// <summary> /// 查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnQuery_Click(object sender, EventArgs e) { if (!CheckData()) { PageHelper.ShowExceptionMessage(hidInfo.Value); return; } this.OUID = NDConvert.ToInt64(drpOU.SelectedValue); BindGridView(); }
protected void drpChildList_SelectedIndexChanged(object sender, EventArgs e) { if (drpChildList.SelectedIndex != 0) { drpPersonList.Enabled = true; BindPerson(NDConvert.ToInt64(drpChildList.SelectedValue), 1); BindTreeView(); } else { drpPersonList.Enabled = false; tvRight.ClearAll(); } }
/// <summary> /// 绑定树状结构 /// </summary> private void BindTreeView() { tvMenu.ClearAll(); DataTable dt = null; Infragistics.WebUI.UltraWebNavigator.Node tn1; Infragistics.WebUI.UltraWebNavigator.Node tn2; Infragistics.WebUI.UltraWebNavigator.Node tn3; //一层 dt = new MenuQuery().GetMenuTop(); tn1 = new Infragistics.WebUI.UltraWebNavigator.Node(); tn1.Text = "系统菜单"; tn1.DataKey = "0"; tn1.CheckBox = Infragistics.WebUI.UltraWebNavigator.CheckBoxes.False; for (int i = 0; i < dt.Rows.Count; i++) { tn2 = new Infragistics.WebUI.UltraWebNavigator.Node(); tn2.Text = dt.Rows[i]["MenuName"].ToString(); tn2.DataKey = dt.Rows[i]["MenuID"].ToString(); tn2.CheckBox = Infragistics.WebUI.UltraWebNavigator.CheckBoxes.True; if (dt.Rows[i]["IsDisplay"].ToString() == "0") { tn2.Style.Font.Bold = true; } //tn2.TargetUrl = "javascript:window.parent.frames['Code'].location.href = 'Code.aspx?ID=" + tn2.DataKey.ToString() + "';"; tn1.Nodes.Add(tn2); //二层 DataTable dtChild = new MenuQuery().GetMenuChild(NDConvert.ToInt64(dt.Rows[i]["MenuID"].ToString())); for (int j = 0; j < dtChild.Rows.Count; j++) { tn3 = new Infragistics.WebUI.UltraWebNavigator.Node(); tn3.Text = dtChild.Rows[j]["MenuName"].ToString(); tn3.DataKey = dtChild.Rows[j]["MenuID"].ToString(); tn3.CheckBox = Infragistics.WebUI.UltraWebNavigator.CheckBoxes.True; if (dtChild.Rows[j]["IsDisplay"].ToString() == "False") { tn3.Style.ForeColor = System.Drawing.Color.Blue; } tn3.TargetUrl = "javascript:window.parent.frames['MenuFunction'].location.href = 'MenuFunction.aspx?ID=" + tn3.DataKey.ToString() + "';"; tn2.Nodes.Add(tn3); } } tvMenu.Nodes.Add(tn1); tvMenu.ExpandAll(); }
/// <summary> /// 更新 /// </summary> private void Update() { OUEntity entity = new OUEntity(this.OUID); entity.OUParentID = NDConvert.ToInt64(drpOUList.SelectedValue); entity.OUType = 1; entity.OUName = txtOUName.Text.Trim(); entity.Description = txtDescriptipn.Text.Trim(); if (entity.SortIndex == 0) { entity.SortIndex = OUQuery.GetMaxSortIndex(); } entity.UpdateDate = DateTime.Now; new OURule().Update(entity); }
public void TransferPage() { try { DataTable dt = new UserQuery().GetUserByUserID(NDConvert.ToString(UserID)); if (dt.Rows.Count > 0) { UserEntity entity = new UserEntity(NDConvert.ToInt64(dt.Rows[0]["UserID"].ToString())); if (entity.Status == 2) //锁定 { PageHelper.ShowExceptionMessage("此用户已经被锁定,无法登陆,请与管理员联系!"); return; } switch (entity.UserType) { case (int)CommonEnum.UserType.Admin: SessionState.UserType = CommonEnum.UserType.Admin; SessionState.IsAdmin = true; break; case (int)CommonEnum.UserType.InnerUser: SessionState.UserType = CommonEnum.UserType.InnerUser; SessionState.IsAdmin = false; break; default: SessionState.UserType = CommonEnum.UserType.InnerUser; SessionState.IsAdmin = false; break; } SessionState.UserID = entity.UserID; SessionState.UserName = entity.UserName; SessionState.Account = entity.Account; SessionState.OUID = entity.OUID; OUEntity OUEntity = new OUEntity(entity.OUID); SessionState.OUType = OUEntity.OUType; SessionState.OUName = OUEntity.OUName; Response.Redirect("Platform/MainWeb/root.aspx"); } } catch (Exception ex) { PageHelper.ShowExceptionMessage(ex); } }
/// <summary> /// toolbar事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { long ID = 0; switch (e.Item.Value) { case "Delete": if (e.Item.Value == "Delete") { int succeed = 0; string CodeGroupNames = ""; for (int j = 0; j < tvOU.CheckedNodes.Count; j++) { Infragistics.WebUI.UltraWebNavigator.Node tn = (Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[j]; long CodeGroupID = NDConvert.ToInt64(tn.DataKey.ToString()); CodeGroupEntity entity = new CodeGroupEntity(CodeGroupID); if (!CodeQuery.IsExistCode(CodeGroupID)) { entity.IsDeleted = true; new CodeGroupRule().Update(entity); succeed++; } else { CodeGroupNames += "[" + entity.CodeGroupName + "]"; } } if (succeed > 0) { BindTreeView(); PageHelper.ShowMessage("删除成功!"); } if (CodeGroupNames != "") { string msgErr = "代码组名称为" + CodeGroupNames + "的记录不可删除!\\n\\n" + "可先删除代码组中包含的代码记录后再删除该代码组!"; PageHelper.ShowExceptionMessage(msgErr); } } break; case "Update": ID = NDConvert.ToInt64(((Infragistics.WebUI.UltraWebNavigator.Node)tvOU.CheckedNodes[0]).DataKey.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "更新", "showModalWindow('CodeGroupEditLY', '修改',750, 220, '../../web/SysManager/CodeGroupEdit.aspx?Operation=2&ID=' + " + ID + ");", true); break; } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { long ThisCodeID = NDConvert.ToInt64(grid.DataKeys[e.Row.RowIndex].Values["CodeID"].ToString()); if (CodeDetailQuery.IsExistCodeDetail(ThisCodeID)) { e.Row.Cells[0].Enabled = false; e.Row.Cells[5].Enabled = false; } else { e.Row.Cells[5].Attributes.Add("onclick", "return confirm('确定要删除此记录吗?');"); } } }
/// <summary> /// toolbar事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": int succeed = 0; string CodeNames = ""; for (int i = 0; i < grid.Rows.Count; i++) { CheckBox chkItem = (CheckBox)grid.Rows[i].FindControl("chkItem"); if (chkItem != null && chkItem.Checked == true) { this.CodeID = NDConvert.ToInt64(grid.DataKeys[i]["CodeID"].ToString()); CodeEntity entity = new CodeEntity(CodeID); if (!CodeDetailQuery.IsExistCodeDetail(CodeID)) { entity.IsDeleted = true; new CodeRule().Update(entity); succeed++; } else { CodeNames += "[" + entity.CodeName + "]"; } } } this.CurOperation = (int)OperationEnum.INSERT; this.CodeID = 0; txtCodeName.Text = ""; txtCodeValue.Text = ""; txtMemo.Text = ""; if (succeed > 0) { BindGridView(); PageHelper.ShowMessage("删除成功!"); } if (CodeNames != "") { string msgErr = "代码名称为" + CodeNames + "的记录存在子记录,不可删除!\\n\\n" + "可先删除代码子记录后再删除相应代码!"; PageHelper.ShowExceptionMessage(msgErr); } break; } }
/// <summary> /// 邦定GridView /// </summary> private void BindGridView() { long UserID = NDConvert.ToInt64(Session["UserID"]); //当前管理操作的中 DataSet ds = GetData(); DataTable dt = ds.Tables[1]; grid.DataSource = dt; grid.DataBind(); BindviewPage(NDConvert.ToInt32(ds.Tables[0].Rows[0][0].ToString())); for (int i = 0; i < grid.Rows.Count; i++) { string name = grid.Rows[i].Cells[1].Text; if (name.Length > 8) { grid.Rows[i].Cells[1].Text = Truncate(name, 13, "..."); grid.Rows[i].Cells[1].ToolTip = name; } string ageRange = grid.Rows[i].Cells[3].Text; if (ageRange.Length > 8) { grid.Rows[i].Cells[3].Text = Truncate(ageRange, 13, "..."); grid.Rows[i].Cells[3].ToolTip = ageRange; } string consultContent = grid.Rows[i].Cells[9].Text; if (consultContent.Length > 9) { grid.Rows[i].Cells[9].Text = Truncate(consultContent, 15, "..."); grid.Rows[i].Cells[9].ToolTip = consultContent; } string opinionContent = grid.Rows[i].Cells[10].Text; if (opinionContent.Length > 9) { grid.Rows[i].Cells[10].Text = Truncate(opinionContent, 15, "..."); grid.Rows[i].Cells[10].ToolTip = opinionContent; } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { int RowIndex = NDConvert.ToInt32(e.CommandArgument.ToString()); this.CodeID = NDConvert.ToInt64(grid.DataKeys[RowIndex].Values["CodeID"].ToString()); CodeEntity entity = new CodeEntity(CodeID); switch (e.CommandName) { case "Children": Page.ClientScript.RegisterStartupScript(this.GetType(), "CodeDetail", "showModalWindow('CodeDetailLY','子代码信息',600, 560,'../../Web/SysManager/CodeDetail.aspx?CodeID=" + this.CodeID + "');", true); break; case "Modify": txtCodeName.Text = entity.CodeName; txtCodeValue.Text = entity.CodeValue; txtMemo.Text = entity.Memo; this.CurOperation = (int)OperationEnum.UPDATE; break; case "Del": if (!CodeDetailQuery.IsExistCodeDetail(this.CodeID)) { entity.IsDeleted = true; new CodeRule().Update(entity); PageHelper.ShowMessage("删除成功!"); BindGridView(); } else { string msgErr = "该代码存在子记录,不可删除!\\n\\n" + "可先删除代码子记录后再删除该代码!"; PageHelper.ShowExceptionMessage(msgErr); } txtCodeName.Text = ""; txtCodeValue.Text = ""; txtMemo.Text = ""; this.CurOperation = (int)OperationEnum.INSERT; this.CodeID = 0; break; } }
/// <summary> /// toolbar /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void toolbar_MenuItemClick(object sender, MenuEventArgs e) { switch (e.Item.Value) { case "Delete": if (e.Item.Value == "Delete") { for (int j = 0; j < tvMenu.CheckedNodes.Count; j++) { Infragistics.WebUI.UltraWebNavigator.Node tn = (Infragistics.WebUI.UltraWebNavigator.Node)tvMenu.CheckedNodes[j]; MenuEntity entity = new MenuEntity(NDConvert.ToInt64(tn.DataKey.ToString())); entity.IsDeleted = true; new MenuRule().Update(entity); } BindTreeView(); PageHelper.ShowMessage("删除成功!"); } break; case "Add": this.MenuID = 0; if (tvMenu.CheckedNodes.Count != 0) { this.MenuID = NDConvert.ToInt64(((Infragistics.WebUI.UltraWebNavigator.Node)tvMenu.CheckedNodes[0]).DataKey.ToString()); } MenuEntity entity1 = new MenuEntity(this.MenuID); if (entity1.ParentMenuID != 0) { PageHelper.ShowExceptionMessage("此菜单下不能再添加子菜单!"); return; } Page.ClientScript.RegisterStartupScript(this.GetType(), "新增", "showModalWindow('MenuDetailLY', '新增',750, 220, '../../web/SysManager/MenuDetail.aspx?Operation=1&ID=' + " + this.MenuID + ");", true); break; case "Update": this.MenuID = NDConvert.ToInt64(((Infragistics.WebUI.UltraWebNavigator.Node)tvMenu.CheckedNodes[0]).DataKey.ToString()); Page.ClientScript.RegisterStartupScript(this.GetType(), "更新", "showModalWindow('MenuDetailLY', '修改',750, 220, '../../web/SysManager/MenuDetail.aspx?Operation=2&ID=' + " + this.MenuID + ");", true); break; } }