示例#1
0
        /// <summary>
        /// 获取指定userOperationId的useroperation对象
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <param name="userOperationId">主键值</param>
        /// <returns></returns>
        public override ResultModel Get(UserModel user, int userOperationId)
        {
            ResultModel result = new ResultModel();

            if(userOperationId<1)
            {
                result.Message = "序号不能小于1";
                return result;
            }

            List<SqlParameter> paras = new List<SqlParameter>();
            SqlParameter para = new SqlParameter("@UserOperationId",SqlDbType.Int,4);
            para.Value = userOperationId;
            paras.Add(para);

            SqlDataReader dr = null;

            try
            {
                dr = SqlHelper.ExecuteReader(SqlHelper.ConnectionStringUser, CommandType.StoredProcedure, "UserOperationGet", paras.ToArray());

                UserOperation useroperation = new UserOperation();

                if (dr.Read())
                {
                    int indexUserOperationId = dr.GetOrdinal("UserOperationId");
                    useroperation.UserOperationId = Convert.ToInt32(dr[indexUserOperationId]);

                    int indexAccId = dr.GetOrdinal("AccId");
                    if(dr["AccId"] != DBNull.Value)
                    {
                    useroperation.AccId = Convert.ToInt32(dr[indexAccId]);
                    }

                    int indexOperationTime = dr.GetOrdinal("OperationTime");
                    if(dr["OperationTime"] != DBNull.Value)
                    {
                    useroperation.OperationTime = Convert.ToDateTime(dr[indexOperationTime]);
                    }

                    int indexMenuId = dr.GetOrdinal("MenuId");
                    if(dr["MenuId"] != DBNull.Value)
                    {
                    useroperation.MenuId = Convert.ToInt32(dr[indexMenuId]);
                    }

                    int indexOperationDesc = dr.GetOrdinal("OperationDesc");
                    if(dr["OperationDesc"] != DBNull.Value)
                    {
                    useroperation.OperationDesc = Convert.ToString(dr[indexOperationDesc]);
                    }

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = useroperation;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch(Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
示例#2
0
        /// <summary>
        /// 获取useroperation集合
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <returns></returns>
        public override ResultModel Load(UserModel user)
        {
            ResultModel result = new ResultModel();
            try
            {
                DataTable dt = SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringUser,"UserOperationLoad",null,CommandType.StoredProcedure);

                List< UserOperation> userOperations = new List< UserOperation>();

                foreach(DataRow dr in dt.Rows)
                {
                    UserOperation useroperation = new UserOperation();
                    useroperation.UserOperationId = Convert.ToInt32(dr["UserOperationId"]);

                    if(dr["AccId"] != DBNull.Value)
                    {
                    useroperation.AccId = Convert.ToInt32(dr["AccId"]);
                    }
                    if(dr["OperationTime"] != DBNull.Value)
                    {
                    useroperation.OperationTime = Convert.ToDateTime(dr["OperationTime"]);
                    }
                    if(dr["MenuId"] != DBNull.Value)
                    {
                    useroperation.MenuId = Convert.ToInt32(dr["MenuId"]);
                    }
                    if(dr["OperationDesc"] != DBNull.Value)
                    {
                    useroperation.OperationDesc = Convert.ToString(dr["OperationDesc"]);
                    }
                    userOperations.Add(useroperation);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = userOperations;
            }
            catch(Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }