private void IniData() { tvMain.Nodes.Clear(); TreeNode trNo = new TreeNode("↓ 开始"); trNo.ImageUrl = "~/Image/per.ico"; trNo.Value = "0"; tvMain.Nodes.Add(trNo); List <A_ProInfos> getAllPros = new List <A_ProInfos>(); A_ProInfosService prosSer = new A_ProInfosService(); if (Request["proId"] != null) { getAllPros = prosSer.GetListArray(string.Format(" pro_Id={0}", Request["proId"])); object obj = DBHelp.ExeScalar("select pro_Type from A_ProInfo where pro_Id=" + Request["proId"]); lblName.Text = obj.ToString(); } for (int i = 0; i < getAllPros.Count; i++) { TreeNode maintrNo = new TreeNode("↓ " + getAllPros[i].RoleName); maintrNo.ImageUrl = "~/Image/per.ico"; maintrNo.Value = getAllPros[i].ids.ToString(); tvMain.Nodes.Add(maintrNo); } TreeNode trNoLast = new TreeNode("结束"); trNoLast.ImageUrl = "~/Image/per.ico"; trNoLast.Value = "-1"; tvMain.Nodes.Add(trNoLast); tvMain.ExpandAll(); }
protected void btnSave_Click(object sender, EventArgs e) { if (lblPareId.Text.ToString() == "") { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('请选择一个上级审批角色名称!');"), true); return; } if (ddlRoles.SelectedItem.Text == "") { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('请选择审批角色名称!');"), true); return; } A_ProInfosService prosSer = new A_ProInfosService(); A_ProInfos prosModel = new A_ProInfos(); prosModel.a_Role_Id = Convert.ToInt32(ddlRoles.SelectedItem.Value); prosModel.pro_Id = Convert.ToInt32(Request["proId"]); prosModel.a_Index = 0; if (ViewState["state"].ToString() == "add") { List <A_ProInfos> getAllPros = new List <A_ProInfos>(); if (Request["proId"] != null) { getAllPros = prosSer.GetListArray(string.Format(" pro_Id={0}", Request["proId"])); } if (getAllPros.Count > 0) { if (Convert.ToInt32(lblPareId.Text) == 0) { getAllPros.Insert(0, prosModel); } else { for (int i = 0; i < getAllPros.Count; i++) { if (getAllPros[i].ids == Convert.ToInt32(lblPareId.Text)) { getAllPros.Insert(i + 1, prosModel); break; } } } } else { getAllPros.Insert(0, prosModel); } int ids = prosSer.addList(getAllPros); if (ids <= 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('添加失败!');"), true); return; } else { lblPareId.Text = ids.ToString(); lblParent.Text = "↓ " + ddlRoles.SelectedItem.Text; } } if (ViewState["state"].ToString() == "update") { string sql = string.Format(@"select count(*) from tb_EForm where toProsId=" + Convert.ToInt32(ViewState["proId"])); if (Convert.ToInt32(DBHelp.ExeScalar(sql)) > 0) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "a", string.Format("alert('修改失败,该信息正在被使用!');"), true); // base.ClientScript.RegisterStartupScript(base.GetType(), null, "<script>alert('修改失败,该信息正在被使用!');</script>"); return; } sql = string.Format(" update A_ProInfos set a_Role_Id={0} where ids={1}", ddlRoles.SelectedItem.Value, ViewState["proId"]); DBHelp.ExeCommand(sql); } IniData(); }