예제 #1
0
파일: CorpEmpDAL.cs 프로젝트: weiliji/NFMT
        /// <summary>
        /// 获取指定corpEmpId的corpemp对象
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <param name="corpEmpId">主键值</param>
        /// <returns></returns>
        public override ResultModel Get(UserModel user, int corpEmpId)
        {
            ResultModel result = new ResultModel();

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

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

            SqlDataReader dr = null;

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

                CorpEmp corpemp = new CorpEmp();

                if (dr.Read())
                {
                    int indexCorpEmpId = dr.GetOrdinal("CorpEmpId");
                    corpemp.CorpEmpId = Convert.ToInt32(dr[indexCorpEmpId]);

                    int indexEmpId = dr.GetOrdinal("EmpId");
                    if(dr["EmpId"] != DBNull.Value)
                    {
                    corpemp.EmpId = Convert.ToInt32(dr[indexEmpId]);
                    }

                    int indexCorpId = dr.GetOrdinal("CorpId");
                    if(dr["CorpId"] != DBNull.Value)
                    {
                    corpemp.CorpId = Convert.ToInt32(dr[indexCorpId]);
                    }

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = corpemp;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch(Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
예제 #2
0
파일: CorpEmpDAL.cs 프로젝트: weiliji/NFMT
        /// <summary>
        /// 获取corpemp集合
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <returns></returns>
        public override ResultModel Load(UserModel user)
        {
            ResultModel result = new ResultModel();
            try
            {
                DataTable dt = SqlHelper.ExecuteDataTable(SqlHelper.ConnectionStringUser,"CorpEmpLoad",null,CommandType.StoredProcedure);

                List< CorpEmp> corpEmps = new List< CorpEmp>();

                foreach(DataRow dr in dt.Rows)
                {
                    CorpEmp corpemp = new CorpEmp();
                    corpemp.CorpEmpId = Convert.ToInt32(dr["CorpEmpId"]);

                    if(dr["EmpId"] != DBNull.Value)
                    {
                    corpemp.EmpId = Convert.ToInt32(dr["EmpId"]);
                    }
                    if(dr["CorpId"] != DBNull.Value)
                    {
                    corpemp.CorpId = Convert.ToInt32(dr["CorpId"]);
                    }
                    corpEmps.Add(corpemp);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = corpEmps;
            }
            catch(Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }