コード例 #1
0
ファイル: CashInAllotDetailDAL.cs プロジェクト: weiliji/NFMT
        /// <summary>
        /// 获取fun_cashinallotdetail集合
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <returns></returns>
        public override ResultModel Load(UserModel user)
        {
            ResultModel result = new ResultModel();
            try
            {
                DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, "Fun_CashInAllotDetailLoad", null, CommandType.StoredProcedure);

                List<CashInAllotDetail> cashInAllotDetails = new List<CashInAllotDetail>();

                foreach (DataRow dr in dt.Rows)
                {
                    CashInAllotDetail cashinallotdetail = new CashInAllotDetail();
                    cashinallotdetail.DetailId = Convert.ToInt32(dr["DetailId"]);

                    if (dr["CashInId"] != DBNull.Value)
                    {
                        cashinallotdetail.CashInId = Convert.ToInt32(dr["CashInId"]);
                    }
                    if (dr["AllotId"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotId = Convert.ToInt32(dr["AllotId"]);
                    }
                    if (dr["AllotBala"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotBala = Convert.ToDecimal(dr["AllotBala"]);
                    }
                    if (dr["DetailStatus"] != DBNull.Value)
                    {
                        cashinallotdetail.DetailStatus = (Common.StatusEnum)Enum.Parse(typeof(Common.StatusEnum), dr["DetailStatus"].ToString());
                    }
                    if (dr["AllotType"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotType = Convert.ToInt32(dr["AllotType"]);
                    }
                    if (dr["CreatorId"] != DBNull.Value)
                    {
                        cashinallotdetail.CreatorId = Convert.ToInt32(dr["CreatorId"]);
                    }
                    if (dr["CreateTime"] != DBNull.Value)
                    {
                        cashinallotdetail.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
                    }
                    if (dr["LastModifyId"] != DBNull.Value)
                    {
                        cashinallotdetail.LastModifyId = Convert.ToInt32(dr["LastModifyId"]);
                    }
                    if (dr["LastModifyTime"] != DBNull.Value)
                    {
                        cashinallotdetail.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]);
                    }
                    cashInAllotDetails.Add(cashinallotdetail);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = cashInAllotDetails;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }
コード例 #2
0
ファイル: CashInAllotDetailDAL.cs プロジェクト: weiliji/NFMT
        public ResultModel Load(UserModel user,int allotId,StatusEnum status = StatusEnum.已生效)
        {
            ResultModel result = new ResultModel();
            try
            {
                string cmdText = string.Format("select * from dbo.Fun_CashInAllotDetail where AllotId ={0} and DetailStatus >={1}",allotId,(int)status);
                DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, cmdText, null, CommandType.Text);

                List<CashInAllotDetail> cashInAllotDetails = new List<CashInAllotDetail>();

                foreach (DataRow dr in dt.Rows)
                {
                    CashInAllotDetail cashinallotdetail = new CashInAllotDetail();
                    cashinallotdetail.DetailId = Convert.ToInt32(dr["DetailId"]);

                    if (dr["CashInId"] != DBNull.Value)
                    {
                        cashinallotdetail.CashInId = Convert.ToInt32(dr["CashInId"]);
                    }
                    if (dr["AllotId"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotId = Convert.ToInt32(dr["AllotId"]);
                    }
                    if (dr["AllotBala"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotBala = Convert.ToDecimal(dr["AllotBala"]);
                    }
                    if (dr["DetailStatus"] != DBNull.Value)
                    {
                        cashinallotdetail.DetailStatus = (Common.StatusEnum)Enum.Parse(typeof(Common.StatusEnum), dr["DetailStatus"].ToString());
                    }
                    if (dr["AllotType"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotType = Convert.ToInt32(dr["AllotType"]);
                    }
                    if (dr["CreatorId"] != DBNull.Value)
                    {
                        cashinallotdetail.CreatorId = Convert.ToInt32(dr["CreatorId"]);
                    }
                    if (dr["CreateTime"] != DBNull.Value)
                    {
                        cashinallotdetail.CreateTime = Convert.ToDateTime(dr["CreateTime"]);
                    }
                    if (dr["LastModifyId"] != DBNull.Value)
                    {
                        cashinallotdetail.LastModifyId = Convert.ToInt32(dr["LastModifyId"]);
                    }
                    if (dr["LastModifyTime"] != DBNull.Value)
                    {
                        cashinallotdetail.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]);
                    }
                    cashInAllotDetails.Add(cashinallotdetail);
                }
                result.AffectCount = dt.Rows.Count;
                result.Message = "获取列表成功";
                result.ResultStatus = 0;
                result.ReturnValue = cashInAllotDetails;
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }

            return result;
        }
コード例 #3
0
ファイル: CashInAllotDetailDAL.cs プロジェクト: weiliji/NFMT
        /// <summary>
        /// 获取指定detailId的fun_cashinallotdetail对象
        /// </summary>
        /// <param name="user">当前操作用户</param>
        /// <param name="detailId">主键值</param>
        /// <returns></returns>
        public override ResultModel Get(UserModel user, int detailId)
        {
            ResultModel result = new ResultModel();

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

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

            SqlDataReader dr = null;

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

                CashInAllotDetail cashinallotdetail = new CashInAllotDetail();

                if (dr.Read())
                {
                    int indexDetailId = dr.GetOrdinal("DetailId");
                    cashinallotdetail.DetailId = Convert.ToInt32(dr[indexDetailId]);

                    int indexCashInId = dr.GetOrdinal("CashInId");
                    if (dr["CashInId"] != DBNull.Value)
                    {
                        cashinallotdetail.CashInId = Convert.ToInt32(dr[indexCashInId]);
                    }

                    int indexAllotId = dr.GetOrdinal("AllotId");
                    if (dr["AllotId"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotId = Convert.ToInt32(dr[indexAllotId]);
                    }

                    int indexAllotBala = dr.GetOrdinal("AllotBala");
                    if (dr["AllotBala"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotBala = Convert.ToDecimal(dr[indexAllotBala]);
                    }

                    int indexDetailStatus = dr.GetOrdinal("DetailStatus");
                    if (dr["DetailStatus"] != DBNull.Value)
                    {
                        cashinallotdetail.DetailStatus = (Common.StatusEnum)Enum.Parse(typeof(Common.StatusEnum), dr[indexDetailStatus].ToString());
                    }

                    int indexAllotType = dr.GetOrdinal("AllotType");
                    if (dr["AllotType"] != DBNull.Value)
                    {
                        cashinallotdetail.AllotType = Convert.ToInt32(dr[indexAllotType]);
                    }

                    int indexCreatorId = dr.GetOrdinal("CreatorId");
                    if (dr["CreatorId"] != DBNull.Value)
                    {
                        cashinallotdetail.CreatorId = Convert.ToInt32(dr[indexCreatorId]);
                    }

                    int indexCreateTime = dr.GetOrdinal("CreateTime");
                    if (dr["CreateTime"] != DBNull.Value)
                    {
                        cashinallotdetail.CreateTime = Convert.ToDateTime(dr[indexCreateTime]);
                    }

                    int indexLastModifyId = dr.GetOrdinal("LastModifyId");
                    if (dr["LastModifyId"] != DBNull.Value)
                    {
                        cashinallotdetail.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]);
                    }

                    int indexLastModifyTime = dr.GetOrdinal("LastModifyTime");
                    if (dr["LastModifyTime"] != DBNull.Value)
                    {
                        cashinallotdetail.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]);
                    }

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = cashinallotdetail;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }