Exemple #1
0
        public string GetTabDeptQ(int DEPT_ID, string DEPT_NAME)
        {
            string AppendStr = string.Empty;
            DepartmentDAL dal = new DepartmentDAL();
            Model.Power.Account.DepartmentModel deptModel = new ShineKJ.Model.Power.Account.DepartmentModel();
            if (DEPT_ID == 1 || DEPT_NAME=="")
            {
                return "1=1";
            }
            else
            {
                string RetDeptQ = string.Empty;
                System.Text.StringBuilder strSql = new StringBuilder();
                strSql = strSql.Append("SELECT * FROM  View_tab_DeptQ");
                if (DEPT_ID != 0)
                {
                    strSql.Append(" where DEPT_NAME IS NOT NULL AND DeptID=" + DEPT_ID);
                }
                DataSet ds = DbHelperSQL.Query(strSql.ToString());//跨部门数量
                DataSet dsAllDept = Querys("");//找到所有部门的数量

                if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
                {
                    AppendStr = "DeptName in (";
                    RetDeptQ = "'" + DEPT_NAME + "'";
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        if (RetDeptQ != "")
                            RetDeptQ = RetDeptQ + ",'" + ds.Tables[0].Rows[i]["DEPT_NAME"].ToString() + "'";
                        else
                            RetDeptQ = RetDeptQ + "'" + ds.Tables[0].Rows[i]["DEPT_NAME"].ToString() + "'";
                    }
                    if (ds.Tables[0].Rows.Count == dsAllDept.Tables[0].Rows.Count)
                    {
                        return "1=1";
                    }
                    //如果超过一定数目,那么就用NOT IN
                    if (ds.Tables[0].Rows.Count > dsAllDept.Tables[0].Rows.Count - 120)
                    {
                        DataSet dsNotInDept = Querys(" and DEPT_NAME IS NOT NULL AND DEPT_NAME NOT IN (" + RetDeptQ + ")");
                        RetDeptQ = "";
                        AppendStr = "DeptName not in (";
                        for (int i = 0; i < dsNotInDept.Tables[0].Rows.Count; i++)
                        {
                            if (RetDeptQ != "")
                                RetDeptQ = RetDeptQ + ",'" + dsNotInDept.Tables[0].Rows[i]["DEPT_NAME"].ToString() + "'";
                            else
                                RetDeptQ = RetDeptQ + "'" + dsNotInDept.Tables[0].Rows[i]["DEPT_NAME"].ToString() + "'";
                        }
                    }

                }
                else
                {
                    DeptDal deptdal = new DeptDal();
                    ds = deptdal.QueryChildDept(DEPT_ID);
                    for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                    {
                        AppendStr = "DeptName in (";
                        if (RetDeptQ != "")
                            RetDeptQ = RetDeptQ + ",'" + ds.Tables[0].Rows[i]["DEPT_NAME"].ToString() + "'";
                        else
                            RetDeptQ = RetDeptQ + "'" + ds.Tables[0].Rows[i]["DEPT_NAME"].ToString() + "'";
                    }
                }
                return AppendStr + RetDeptQ + ")";
            }
        }
Exemple #2
0
 /// <summary>
 /// 加载部门信息列表
 /// </summary>
 /// <returns></returns>
 public DataSet Query()
 {
     DeptDal dal = new DeptDal();
       return dal.Query();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Request.QueryString["BeginTime"] != null && Request.QueryString["EndTime"] != null)
            {
                txtInWellTime.Text = Request.QueryString["BeginTime"].ToString();
                txtEndTime.Text = Request.QueryString["EndTime"].ToString();

            }
            else
            {
                txtInWellTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
                txtEndTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
            }
            if (Session["User_Account"] == null || Session["User_Account"].ToString() == "")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "success", "<script>window.alert('请登录!');window.parent.parent.location.href='../../default.aspx';</script>");
                return;
            }

            //txtEndTime.Text = DateTime.Now.ToString("yyyy-MM-dd");
            //默认显示上月的统计数据

            DeptDal dal = new DeptDal();

            DataSet ds = new DataSet();
            if (Session["DEPT_ID"].ToString() == "1")
            {
                ds = dalDept.Querys(" order by DEPT_NAME ");

            }
            else
            {
                ds = dalDept.TabDeptQuerys(" DeptID=" + Session["DEPT_ID"].ToString() + " and DEPT_ID IN (SELECT DEPT_ID FROM Department)  ORDER BY DEPT_NAME");

            }
            //DataSet ds = dal.Query();
            fillDept(ddlDept, "DEPT_NAME", "DEPT_ID", ds);
            BindInterval();
            BindGridView(1, 80);

        }
    }