Example #1
0
        /// <summary>
        ///  增加一条数据
        /// </summary>
        public bool Add(DutyInfo model,out int DutyID)
        {
            string procName = "OA_SP_SM_Duty_ADD";
            LogBuilder log = new LogBuilder();
            MssqlDatabase Mssql = null;
            #region 日志信息
            log.Desc = "添加职务";

            log.Method = MethodBase.GetCurrentMethod().Name;
            log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DutyInfo", model);
            #endregion
             DutyID = 0;
            try
            {
                Mssql = new MssqlDatabase();
            int rowsAffected;
            SqlParameter[] parameters = {
                    new SqlParameter("@DutyID", SqlDbType.Int,4),
                    new SqlParameter("@DutyName", SqlDbType.VarChar,50),
                    new SqlParameter("@DepID", SqlDbType.Int,4),
                    new SqlParameter("@Remark", SqlDbType.VarChar,200),
                    new SqlParameter("@State", SqlDbType.Int,4),
                    new SqlParameter("@Created", SqlDbType.DateTime),
                    new SqlParameter("@Creator", SqlDbType.Int,4)};
            parameters[0].Direction = ParameterDirection.Output;
            parameters[1].Value = model.DutyName;
            parameters[2].Value = model.DepID;
            parameters[3].Value = model.Remark;
            parameters[4].Value = model.State;
            parameters[5].Value = model.Created;
            parameters[6].Value = model.Creator;

             Mssql.ExecuteProc(procName, parameters, out rowsAffected);
                if (rowsAffected > 0)
                {
                    if (parameters[0] != null)
                    {
                        DutyID = (int)parameters[0].Value;
                        log.Append("DutyID", DutyID, ParamDirection.OUT);
                    }
                }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return DutyID > 0;
        }
Example #2
0
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int DutyID)
        {
            string procName = "OA_SP_SM_Duty_Delete";
            LogBuilder log = new LogBuilder();
            MssqlDatabase Mssql = null;
            #region 日志信息
            log.Desc = "删除职位";

            log.Method = MethodBase.GetCurrentMethod().Name;
            log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DutyID", DutyID);
            #endregion

            try
            {
                Mssql = new MssqlDatabase();
            int rowsAffected=0;
            SqlParameter[] parameters = {
                    new SqlParameter("@DutyID", SqlDbType.Int,4)
            };
            parameters[0].Value = DutyID;

            Mssql.ExecuteProc(procName, parameters, out rowsAffected);
            if (rowsAffected > 0)
            {
                return true;
            }

            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return false;
        }
Example #3
0
        /// <summary>
        /// 查询职位列表
        /// </summary>
        /// <param name="pageSize"></param>
        /// <param name="pageIndex"></param>
        /// <param name="totalRows"></param>
        /// <param name="ParentID">上级ID</param>
        /// <returns></returns>
        public IList<DutyInfo> GetList(int pageSize, int pageIndex, out int totalRows)
        {
            List<DutyInfo> DutyList = null;
            DutyInfo ui = null;
            totalRows = 0;
            string procName = "OA_SP_SM_Duty_GetList";
            MssqlDatabase Mssql = null;
            LogBuilder log = new LogBuilder();
            try
            {
                Mssql = new MssqlDatabase();
                #region 日志信息
                log.Desc = "查询职位列表";

                log.Method = MethodBase.GetCurrentMethod().Name;
                log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
                log.StroreProcedure = procName;

                log.Append("PageSize", pageSize.ToString());
                log.Append("PageIndex", pageIndex.ToString());

                #endregion

                SqlParameter[] param ={

                  Mssql.MakeInParam("@PageSize", SqlDbType.Int,4, pageSize),
                  Mssql.MakeInParam("@PageIndex", SqlDbType.Int,4,pageIndex),

                  Mssql.MakeOutParam("@TotalRows",SqlDbType.Int,4)
                };
                DataTable dt = null;
                Mssql.ExecuteProc(procName, param, out dt);
                totalRows = SqlComponents.ReaderGetInt32(param[3].Value);

                log.Append("TotalRows", totalRows.ToString(), ParamDirection.INOUT);

                if (dt != null && dt.Rows.Count > 0)
                {
                    DutyList = new List<DutyInfo>();
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        ui = new DutyInfo();
                        ui.RowId = SqlComponents.ReaderGetInt32(dt.Rows[i]["rowid"]);
                        ui.DepID = SqlComponents.ReaderGetInt32(dt.Rows[i]["DepID"]);
                        ui.DutyID = SqlComponents.ReaderGetInt32(dt.Rows[i]["DutyID"]);
                        ui.State = SqlComponents.ReaderGetInt32(dt.Rows[i]["State"]);
                        ui.DutyName = SqlComponents.ReaderGetString(dt.Rows[i]["DutyName"]);
                        ui.Remark = SqlComponents.ReaderGetString(dt.Rows[i]["Remark"]);
                        DutyList.Add(ui);
                    }
                }
                return DutyList;
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return null;
        }
Example #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public DutyInfo GetDutyInfo(int DutyID)
        {
            DutyInfo model = null;
            string procName = "OA_SP_SM_Duty_GetModel";
            LogBuilder log = new LogBuilder();
            MssqlDatabase Mssql = null;
            #region 日志信息
            log.Desc = "获取职位信息";

            log.Method = MethodBase.GetCurrentMethod().Name;
            log.Path = MethodBase.GetCurrentMethod().DeclaringType.FullName;
            log.StroreProcedure = procName;

            log.Append("DutyID", DutyID);
            #endregion

            try
            {
                Mssql = new MssqlDatabase();
            SqlParameter[] parameters = {
                    new SqlParameter("@DutyID", SqlDbType.Int,4)
            };
            parameters[0].Value = DutyID;

            DataTable dt = Mssql.ExecuteProcDt(procName, parameters);
            if (dt != null && dt.Rows.Count > 0)
            {
                DataRow dr = dt.Rows[0];
                model = new DutyInfo();
                model.DutyID = DutyID;
                model.DutyName = SqlComponents.ReaderGetString(dr["DutyName"]);
                model.DepID = SqlComponents.ReaderGetInt32(dr["DepID"]);
                model.Remark = SqlComponents.ReaderGetString(dr["Remark"]);
                model.State = SqlComponents.ReaderGetInt32(dr["State"]);
                return model;
            }
            }
            catch (Exception ex)
            {
                log.Exception = ex.ToString();
                log.Error();
            }
            finally
            {
                log.Debug();
                if (Mssql != null)
                {
                    Mssql.Close();
                }
            }
            return null;
        }
Example #5
0
 public UserDAL()
 {
     Mssql = new MssqlDatabase();
 }
Example #6
0
 public DepartmentDAL()
 {
     Mssql = new MssqlDatabase();
 }