Exemple #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public PeiSongTypeVsProductModel GetModel(decimal PeiSongTypeId, string ProId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select PeiSongTypeId, ProId, VsType  ");
            strSql.Append("  from CORE.dbo.PeiSongTypeVsProduct ");
            strSql.Append(" where PeiSongTypeId=@PeiSongTypeId and ProId=@ProId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@PeiSongTypeId", SqlDbType.Decimal, 9),
                new SqlParameter("@ProId",         SqlDbType.VarChar, 50)
            };
            parameters[0].Value = PeiSongTypeId;
            parameters[1].Value = ProId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["PeiSongTypeId"].ToString() != "")
                {
                    model.PeiSongTypeId = decimal.Parse(ds.Tables[0].Rows[0]["PeiSongTypeId"].ToString());
                }
                model.ProId  = ds.Tables[0].Rows[0]["ProId"].ToString();
                model.VsType = ds.Tables[0].Rows[0]["VsType"].ToString();

                return(model);
            }
            else
            {
                return(model);
            }
        }
Exemple #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(PeiSongTypeVsProductModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.PeiSongTypeVsProduct (");
            strSql.Append("PeiSongTypeId,ProId,VsType");
            strSql.Append(") values (");
            strSql.Append("@PeiSongTypeId,@ProId,@VsType");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@PeiSongTypeId", SqlDbType.Decimal,  9),
                new SqlParameter("@ProId",         SqlDbType.VarChar, 50),
                new SqlParameter("@VsType",        SqlDbType.VarChar, 20)
            };

            parameters[0].Value = model.PeiSongTypeId;
            parameters[1].Value = model.ProId;
            parameters[2].Value = model.VsType;

            bool result = false;

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

            strSql.Append("update CORE.dbo.PeiSongTypeVsProduct set ");

            strSql.Append(" PeiSongTypeId = @PeiSongTypeId , ");
            strSql.Append(" ProId = @ProId , ");
            strSql.Append(" VsType = @VsType  ");
            strSql.Append(" where PeiSongTypeId=@PeiSongTypeId and ProId=@ProId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@PeiSongTypeId", SqlDbType.Decimal,  9),
                new SqlParameter("@ProId",         SqlDbType.VarChar, 50),
                new SqlParameter("@VsType",        SqlDbType.VarChar, 20)
            };

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