department_select_chk.aspx.cs
资源名称:web.rar [点击查看]
上传用户:xrffrp
上传日期:2022-03-25
资源大小:22155k
文件大小:8k
源码类别:
OA系统
开发平台:
ASP/ASPX
- using System;
- using System.Data;
- using System.Configuration;
- using System.Collections;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- using System.Data.SqlClient;
- public partial class web_personnel_department_department_select_chk : System.Web.UI.Page
- {
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!IsPostBack)
- {
- this.AddTable();
- }
- }
- protected void AddTable()
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- ArrayList ids = new ArrayList();
- ArrayList names = new ArrayList();
- SqlCommand cmd = new SqlCommand("select id, code, name from OA_DEPARTMENT where last_id=1 order by sequence, code", conn);
- SqlDataReader dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ids.Add(dr["id"].ToString());
- names.Add(dr["code"].ToString() + dr["name"].ToString());
- }
- dr.Close();
- for (int i = 0; i < ids.Count; i++)
- {
- TableRow tr1 = new TableRow();
- tr1.BorderWidth = Unit.Pixel(1);
- TableCell td1 = new TableCell();
- td1.Width = Unit.Pixel(150);
- tr1.HorizontalAlign = HorizontalAlign.Left;
- CheckBox cb = new CheckBox();
- cb.ID = "chk" + ids[i].ToString();
- cb.Text = names[i].ToString();
- cb.InputAttributes["parent"] = "1";
- cb.InputAttributes["value"] = ids[i].ToString();
- cb.InputAttributes["onclick"] = "check(" + ids[i] + ")";
- td1.Controls.Add(cb);
- tr1.Cells.Add(td1);
- td1.BorderWidth = Unit.Pixel(1);
- ArrayList ids1 = new ArrayList();
- ArrayList names1 = new ArrayList();
- cmd = new SqlCommand("select id, code, name from OA_DEPARTMENT where last_id=" + ids[i] + " order by sequence, code", conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ids1.Add(dr["id"].ToString());
- names1.Add(dr["code"].ToString() + dr["name"].ToString());
- }
- dr.Close();
- Table tb1 = new Table();
- TableCell td2 = new TableCell();
- td2.BorderWidth = Unit.Pixel(1);
- td2.Width = Unit.Pixel(750);
- for (int j = 0; j < ids1.Count; j++)
- {
- TableRow tr2 = new TableRow();
- TableCell td3 = new TableCell();
- td3.BorderWidth = Unit.Pixel(1);
- td3.Width = Unit.Pixel(200);
- tr2.HorizontalAlign = HorizontalAlign.Left;
- cb = new CheckBox();
- cb.InputAttributes["parent"] = ids[i].ToString();
- cb.InputAttributes["value"] = ids1[j].ToString();
- cb.InputAttributes["onclick"] = "check(" + ids1[j] + ")";
- cb.ID = "chk" + ids1[j].ToString();
- cb.Text = names1[j].ToString();
- td3.Controls.Add(cb);
- tr2.Cells.Add(td3);
- ArrayList ids2 = new ArrayList();
- ArrayList names2 = new ArrayList();
- cmd = new SqlCommand("select id, code, name from OA_DEPARTMENT where last_id=" + ids1[j] + " order by sequence, code", conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ids2.Add(dr["id"].ToString());
- names2.Add(dr["code"].ToString() + dr["name"].ToString());
- }
- dr.Close();
- Table tb2 = new Table();
- TableCell td5 = new TableCell();
- td5.BorderWidth = Unit.Pixel(1);
- td5.Width = Unit.Pixel(500);
- for (int k = 0; k < ids2.Count; k++)
- {
- TableRow tr3 = new TableRow();
- TableCell td4 = new TableCell();
- td4.BorderWidth = Unit.Pixel(1);
- td4.Width = Unit.Pixel(220);
- tr3.HorizontalAlign = HorizontalAlign.Left;
- cb = new CheckBox();
- cb.InputAttributes["parent"] = ids1[j].ToString();
- cb.InputAttributes["value"] = ids2[k].ToString();
- cb.InputAttributes["onclick"] = "check(" + ids2[k] + ")";
- cb.ID = "chk" + ids2[k].ToString();
- cb.Text = names2[k].ToString();
- td4.Controls.Add(cb);
- tr3.Cells.Add(td4);
- tb2.Rows.Add(tr3);
- ArrayList ids3 = new ArrayList();
- ArrayList names3 = new ArrayList();
- cmd = new SqlCommand("select id, code, name from OA_DEPARTMENT where last_id=" + ids2[k] + " order by sequence, code", conn);
- dr = cmd.ExecuteReader();
- while (dr.Read())
- {
- ids3.Add(dr["id"].ToString());
- names3.Add(dr["code"].ToString() + dr["name"].ToString());
- }
- dr.Close();
- TableCell td6 = new TableCell();
- td6.VerticalAlign = VerticalAlign.Top;
- Table tb3 = new Table();
- for (int l = 0; l < ids3.Count; l++)
- {
- TableRow tr4 = new TableRow();
- TableCell td7 = new TableCell();
- td7.BorderWidth = Unit.Pixel(1);
- td7.Width = Unit.Pixel(280);
- td7.VerticalAlign = VerticalAlign.Top;
- tr3.HorizontalAlign = HorizontalAlign.Left;
- cb = new CheckBox();
- cb.InputAttributes["parent"] = ids2[k].ToString();
- cb.InputAttributes["value"] = ids3[l].ToString();
- cb.InputAttributes["onclick"] = "check(" + ids3[l] + ")";
- cb.ID = "chk" + ids3[l].ToString();
- cb.Text = names3[l].ToString();
- td7.Controls.Add(cb);
- tr4.Cells.Add(td7);
- tb3.Rows.Add(tr4);
- }
- td6.Controls.Add(tb3);
- tr3.Cells.Add(td6);
- }
- td5.Controls.Add(tb2);
- tr2.Cells.Add(td5);
- tb1.Rows.Add(tr2);
- }
- td2.Controls.Add(tb1);
- tr1.Cells.Add(td2);
- TblDepartment.Rows.Add(tr1);
- }
- conn.Close();
- }
- protected void BtnOk_Click(object sender, EventArgs e)
- {
- string names = "";
- if (!DepartmentIds.Value.Equals(""))
- {
- SqlConnection conn = dbConnection.getConnection();
- conn.Open();
- string[] ids = DepartmentIds.Value.Split(new char[] { ',' });
- for (int i = 0; i < ids.Length; i++)
- {
- SqlCommand cmd = new SqlCommand("select code, name from OA_DEPARTMENT where id="+ids[i], conn);
- SqlDataReader dr = cmd.ExecuteReader();
- if (dr.Read())
- {
- names = names + dr["code"].ToString() + dr["name"].ToString() + ";";
- }
- dr.Close();
- }
- conn.Close();
- }
- Response.Write("<script language='javascript'>");
- Response.Write("opener.document.all.LblDepartments.innerText = '"+names.Substring(0, names.Length-1)+"';");
- Response.Write("opener.document.all.DepartmentIds.value = '"+DepartmentIds.Value+"';");
- Response.Write("self.close();");
- Response.Write("</script>");
- }
- }