Exemplo n.º 1
0
    private void DataPlay()
    {
        if (this.Request.QueryString["op"] != null)
        {
            this.txtop.Value = this.Request.QueryString["op"].ToString();           //新增还是修改

            //判断当前用户是否有保存的权限
            HyoaClass.Hyoa_global Hyoa_global = new HyoaClass.Hyoa_global();
            if (Hyoa_global.isHaveRole("Role9990", this.Session["hyuid"].ToString()))
            {
                this.btn_submit.Visible = true; //保存
            }
            else
            {
                this.btn_submit.Visible = false; //保存
            }
            //新文档
            if (this.Request.QueryString["op"] == "add")
            {
                //对部门ID处理开始start
                HyoaClass.Hyoa_dept Hyoa_dept = new HyoaClass.Hyoa_dept();
                DataTable dt;
                string lsdeptid;
                lsdeptid = "";
                //this.Response.Write("<script>alert('" + this.Request.QueryString["deptid"] + "')</script>");
                if (this.Request.QueryString["deptid"] == "")
                {
                    //部门ID为空,说明是第一级部门
                    dt = Hyoa_dept.GetFirstdeptsOrderByDeptid();
                    if (dt.Rows.Count > 0)
                    {
                        //判断当前部门是不是有数据的
                        lsdeptid = (System.Int32.Parse(dt.Rows[0]["hy_deptid"].ToString()) + 1).ToString();
                        if (lsdeptid.Length == 1)
                        {
                            this.hy_deptid.Text = "00" + lsdeptid;
                        }
                        else if (lsdeptid.Length == 2)
                        {
                            this.hy_deptid.Text = "0" + lsdeptid;
                        }
                        else
                        {
                            this.hy_deptid.Text = lsdeptid;
                        }
                    }
                    else
                    {
                        this.hy_deptid.Text = "001";
                    }

                }
                else
                {
                    //部门ID不为空,说明不是第一级部门
                    dt = Hyoa_dept.GetSubDeptsOrderByDeptid(this.Request.QueryString["deptid"].ToString());
                    if (dt.Rows.Count > 0)
                    {
                        //判断当前部门是不是有数据的
                        lsdeptid = (long.Parse(dt.Rows[0]["hy_deptid"].ToString()) + 1).ToString();
                        this.hy_deptid.Text = this.Request.QueryString["deptid"].ToString() + lsdeptid.Substring(lsdeptid.Length - 3, 3).ToString();
                    }
                    else
                    {
                        this.hy_deptid.Text = this.Request.QueryString["deptid"].ToString() + "001";
                    }
                }
                //对部门ID处理结束end

                this.hy_isenabled.Items.Insert(0, "是");
                this.hy_isenabled.Items.Insert(1, "否");
            }
            //旧文档
            if (this.Request.QueryString["op"] == "modify")
            {
                    this.txtdocid.Value = this.Request.QueryString["docid"].ToString();

                    HyoaClass.Hyoa_dept Hyoa_dept = new HyoaClass.Hyoa_dept();
                    DataTable dt = Hyoa_dept.Getdept(this.txtdocid.Value);
                    if (dt.Rows.Count > 0)
                    {
                        this.hy_deptid.Text = dt.Rows[0]["hy_deptid"].ToString();
                        this.hy_deptname.Text  = dt.Rows[0]["hy_deptname"].ToString();
                        this.hy_deptsort.Text = dt.Rows[0]["hy_deptsort"].ToString();
                        //this.Response.Write("<script>alert('" + dt.Rows[0]["hy_isenabled"].ToString() + "')</script>");

                        this.hy_isenabled.Items.Insert(0, "是");
                        this.hy_isenabled.Items.Insert(1, "否");
                        if (dt.Rows[0]["hy_isenabled"].ToString() == "是")
                            this.hy_isenabled.SelectedIndex = 0;
                        else
                            this.hy_isenabled.SelectedIndex = 1;
                    }
                    dt.Clear();
            }
        }
    }