Пример #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ChouJiangTypeModel GetModel(int ChouJiangTypeId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ChouJiangTypeId, ChouJiangTypeName, ChouJiangTypeMemo  ");
            strSql.Append("  from YYHD.dbo.ChouJiangType ");
            strSql.Append(" where ChouJiangTypeId=@ChouJiangTypeId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ChouJiangTypeId", SqlDbType.Int, 4)
            };
            parameters[0].Value = ChouJiangTypeId;


            ChouJiangTypeModel model = new ChouJiangTypeModel();
            DataSet            ds    = helper.ExecSqlReDs(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["ChouJiangTypeId"].ToString() != "")
                {
                    model.ChouJiangTypeId = int.Parse(ds.Tables[0].Rows[0]["ChouJiangTypeId"].ToString());
                }
                model.ChouJiangTypeName = ds.Tables[0].Rows[0]["ChouJiangTypeName"].ToString();
                model.ChouJiangTypeMemo = ds.Tables[0].Rows[0]["ChouJiangTypeMemo"].ToString();

                return(model);
            }
            else
            {
                return(model);
            }
        }
Пример #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ChouJiangTypeModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into YYHD.dbo.ChouJiangType (");
            strSql.Append("ChouJiangTypeId,ChouJiangTypeName,ChouJiangTypeMemo");
            strSql.Append(") values (");
            strSql.Append("@ChouJiangTypeId,@ChouJiangTypeName,@ChouJiangTypeMemo");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ChouJiangTypeId",   SqlDbType.Int,      4),
                new SqlParameter("@ChouJiangTypeName", SqlDbType.VarChar, 50),
                new SqlParameter("@ChouJiangTypeMemo", SqlDbType.VarChar, 500)
            };

            parameters[0].Value = model.ChouJiangTypeId;
            parameters[1].Value = model.ChouJiangTypeName;
            parameters[2].Value = model.ChouJiangTypeMemo;

            bool result = false;

            try
            {
                helper.ExecSqlReInt(strSql.ToString(), parameters);
                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
Пример #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ChouJiangTypeModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update YYHD.dbo.ChouJiangType set ");

            strSql.Append(" ChouJiangTypeId = @ChouJiangTypeId , ");
            strSql.Append(" ChouJiangTypeName = @ChouJiangTypeName , ");
            strSql.Append(" ChouJiangTypeMemo = @ChouJiangTypeMemo  ");
            strSql.Append(" where ChouJiangTypeId=@ChouJiangTypeId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ChouJiangTypeId",   SqlDbType.Int,      4),
                new SqlParameter("@ChouJiangTypeName", SqlDbType.VarChar, 50),
                new SqlParameter("@ChouJiangTypeMemo", SqlDbType.VarChar, 500)
            };

            parameters[0].Value = model.ChouJiangTypeId;
            parameters[1].Value = model.ChouJiangTypeName;
            parameters[2].Value = model.ChouJiangTypeMemo; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }