Exemplo n.º 1
0
        public ResultModel GetDetailByContractId(UserModel user, int contractId)
        {
            ResultModel result = new ResultModel();

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

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

            SqlDataReader dr = null;

            try
            {
                string cmdText = string.Format("select * from dbo.Con_ContractDetail where ContractId ={0}", contractId);

                dr = SqlHelper.ExecuteReader(this.ConnectString, CommandType.Text, cmdText, paras.ToArray());

                ContractDetail contractdetail = new ContractDetail();

                if (dr.Read())
                {
                    int indexContractDetailId = dr.GetOrdinal("ContractDetailId");
                    contractdetail.ContractDetailId = Convert.ToInt32(dr[indexContractDetailId]);

                    int indexContractId = dr.GetOrdinal("ContractId");
                    if (dr["ContractId"] != DBNull.Value)
                    {
                        contractdetail.ContractId = Convert.ToInt32(dr[indexContractId]);
                    }

                    int indexDiscountBase = dr.GetOrdinal("DiscountBase");
                    if (dr["DiscountBase"] != DBNull.Value)
                    {
                        contractdetail.DiscountBase = Convert.ToInt32(dr[indexDiscountBase]);
                    }

                    int indexDiscountType = dr.GetOrdinal("DiscountType");
                    if (dr["DiscountType"] != DBNull.Value)
                    {
                        contractdetail.DiscountType = Convert.ToInt32(dr[indexDiscountType]);
                    }

                    int indexDiscountRate = dr.GetOrdinal("DiscountRate");
                    if (dr["DiscountRate"] != DBNull.Value)
                    {
                        contractdetail.DiscountRate = Convert.ToDecimal(dr[indexDiscountRate]);
                    }

                    int indexDelayType = dr.GetOrdinal("DelayType");
                    if (dr["DelayType"] != DBNull.Value)
                    {
                        contractdetail.DelayType = Convert.ToInt32(dr[indexDelayType]);
                    }

                    int indexDelayRate = dr.GetOrdinal("DelayRate");
                    if (dr["DelayRate"] != DBNull.Value)
                    {
                        contractdetail.DelayRate = Convert.ToDecimal(dr[indexDelayRate]);
                    }

                    int indexMoreOrLess = dr.GetOrdinal("MoreOrLess");
                    if (dr["MoreOrLess"] != DBNull.Value)
                    {
                        contractdetail.MoreOrLess = Convert.ToDecimal(dr[indexMoreOrLess]);
                    }

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

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

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

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

                    result.AffectCount = 1;
                    result.Message = "读取成功";
                    result.ResultStatus = 0;
                    result.ReturnValue = contractdetail;
                }
                else
                {
                    result.Message = "读取失败或无数据";
                    result.AffectCount = 0;
                }
            }
            catch (Exception ex)
            {
                result.Message = ex.Message;
            }
            finally
            {
                if (dr != null)
                    dr.Dispose();
            }
            return result;
        }
Exemplo n.º 2
0
        public override IModel CreateModel(SqlDataReader dr)
        {
            ContractDetail contractdetail = new ContractDetail();

            int indexContractDetailId = dr.GetOrdinal("ContractDetailId");
            contractdetail.ContractDetailId = Convert.ToInt32(dr[indexContractDetailId]);

            int indexContractId = dr.GetOrdinal("ContractId");
            if (dr["ContractId"] != DBNull.Value)
            {
                contractdetail.ContractId = Convert.ToInt32(dr[indexContractId]);
            }

            int indexDiscountBase = dr.GetOrdinal("DiscountBase");
            if (dr["DiscountBase"] != DBNull.Value)
            {
                contractdetail.DiscountBase = Convert.ToInt32(dr[indexDiscountBase]);
            }

            int indexDiscountType = dr.GetOrdinal("DiscountType");
            if (dr["DiscountType"] != DBNull.Value)
            {
                contractdetail.DiscountType = Convert.ToInt32(dr[indexDiscountType]);
            }

            int indexDiscountRate = dr.GetOrdinal("DiscountRate");
            if (dr["DiscountRate"] != DBNull.Value)
            {
                contractdetail.DiscountRate = Convert.ToDecimal(dr[indexDiscountRate]);
            }

            int indexDelayType = dr.GetOrdinal("DelayType");
            if (dr["DelayType"] != DBNull.Value)
            {
                contractdetail.DelayType = Convert.ToInt32(dr[indexDelayType]);
            }

            int indexDelayRate = dr.GetOrdinal("DelayRate");
            if (dr["DelayRate"] != DBNull.Value)
            {
                contractdetail.DelayRate = Convert.ToDecimal(dr[indexDelayRate]);
            }

            int indexMoreOrLess = dr.GetOrdinal("MoreOrLess");
            if (dr["MoreOrLess"] != DBNull.Value)
            {
                contractdetail.MoreOrLess = Convert.ToDecimal(dr[indexMoreOrLess]);
            }

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

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

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

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

            return contractdetail;
        }