コード例 #1
0
ファイル: DepartmentBLL.cs プロジェクト: dalinhuang/128Web
        /// <summary>
        /// ��ȡ��ǰ���Ŷ���
        /// </summary>
        /// <param name="iDeptID">��ȡ���ű��</param>
        /// <returns></returns>
        public DepartmentModel Department_GetModel(int iDeptID)
        {
            string strsql = "select * from Department where DEPT_ID=" + iDeptID.ToString();
            ShineKJ.DAL.KJ128.DataBaseDAL databasedal = new ShineKJ.DAL.KJ128.DataBaseDAL();
            DataSet ds = databasedal.ExecSql(strsql);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                DepartmentModel model = new DepartmentModel();

                DataRow dr = ds.Tables[0].Rows[0];
                model.DEPT_FUNC = dr["DEPT_FUNC"].ToString();
                model.DEPT_ID = int.Parse(dr["DEPT_ID"].ToString());
                model.DEPT_NAME = dr["DEPT_NAME"].ToString();
                model.DEPT_NO = dr["DEPT_NO"].ToString();
                model.DEPT_PARENT = int.Parse(dr["DEPT_PARENT"].ToString());
                model.FAX_NO = dr["FAX_NO"].ToString();
                model.LEADER1 = dr["LEADER1"].ToString();
                model.LEADER2 = dr["LEADER2"].ToString();
                model.MANAGER = dr["MANAGER"].ToString();
                model.TEL_NO = dr["TEL_NO"].ToString();
                return model;
            }
            else
                return null;
        }
コード例 #2
0
ファイル: DepartmentDAL.cs プロジェクト: dalinhuang/128Web
        /// <summary>
        /// 新建部门
        /// </summary>
        /// <param name="model">部门</param>
        /// <returns></returns>
        public int Department_Insert(DepartmentModel model)
        {
            SqlParameter[] paras =
                {
                    new SqlParameter("@DEPT_NO",SqlDbType.NVarChar,50),
                    new SqlParameter("@DEPT_NAME",SqlDbType.NVarChar,50),
                    new SqlParameter("@TEL_NO",SqlDbType.NVarChar,50),
                    new SqlParameter("@FAX_NO",SqlDbType.NVarChar,50),
                    new SqlParameter("@DEPT_PARENT",SqlDbType.Int),
                    new SqlParameter("@MANAGER",SqlDbType.NVarChar),
                    new SqlParameter("@LEADER1",SqlDbType.NVarChar),
                    new SqlParameter("@LEADER2",SqlDbType.NVarChar),
                    new SqlParameter("@DEPT_FUNC",SqlDbType.NVarChar)
                };

            paras[0].Value = model.DEPT_NO;
            paras[1].Value = model.DEPT_NAME;
            paras[2].Value = model.TEL_NO;
            paras[3].Value = model.FAX_NO;
            paras[4].Value = model.DEPT_PARENT;
            paras[5].Value = model.MANAGER;
            paras[6].Value = model.LEADER1;
            paras[7].Value = model.LEADER2;
            paras[8].Value = model.DEPT_FUNC;

            try
            {
                int iReturn;
                int i = DbHelperSQL.RunProcedure("Department_Insert", paras, out iReturn);
                return iReturn;
            }
            catch
            {
                return -1;
            }
        }
コード例 #3
0
ファイル: DepartmentBLL.cs プロジェクト: dalinhuang/128Web
 /// <summary>
 /// �޸IJ���
 /// </summary>
 /// <param name="model">����</param>
 /// <returns></returns>
 public int Department_Update(DepartmentModel model)
 {
     return dal.Department_Update(model);
 }
コード例 #4
0
ファイル: DepartmentBLL.cs プロジェクト: dalinhuang/128Web
 /// <summary>
 /// �½�����
 /// </summary>
 /// <param name="model">����</param>
 /// <returns></returns>
 public int Department_Insert(DepartmentModel model)
 {
     return dal.Department_Insert(model);
 }
コード例 #5
0
ファイル: DepartmentDAL.cs プロジェクト: dalinhuang/128Web
        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 + ")";
            }
        }