예제 #1
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MovVsMerModel GetModel(string MovId, decimal MerchantId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select MovId, MerchantId, vsType  ");
            strSql.Append("  from MovVsMer ");
            strSql.Append(" where MovId=@MovId and MerchantId=@MerchantId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MovId",      SqlDbType.VarChar, 50),
                new SqlParameter("@MerchantId", SqlDbType.Decimal, 9)
            };
            parameters[0].Value = MovId;
            parameters[1].Value = MerchantId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                model.MovId = ds.Tables[0].Rows[0]["MovId"].ToString();
                if (ds.Tables[0].Rows[0]["MerchantId"].ToString() != "")
                {
                    model.MerchantId = decimal.Parse(ds.Tables[0].Rows[0]["MerchantId"].ToString());
                }
                model.vsType = ds.Tables[0].Rows[0]["vsType"].ToString();

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

            strSql.Append("insert into MovVsMer(");
            strSql.Append("MovId,MerchantId,vsType");
            strSql.Append(") values (");
            strSql.Append("@MovId,@MerchantId,@vsType");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@MovId",      SqlDbType.VarChar, 50),
                new SqlParameter("@MerchantId", SqlDbType.Decimal,  9),
                new SqlParameter("@vsType",     SqlDbType.VarChar, 20)
            };

            parameters[0].Value = model.MovId;
            parameters[1].Value = model.MerchantId;
            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);
        }
예제 #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MovVsMerModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update MovVsMer set ");

            strSql.Append(" MovId = @MovId , ");
            strSql.Append(" MerchantId = @MerchantId , ");
            strSql.Append(" vsType = @vsType  ");
            strSql.Append(" where MovId=@MovId and MerchantId=@MerchantId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@MovId",      SqlDbType.VarChar, 50),
                new SqlParameter("@MerchantId", SqlDbType.Decimal,  9),
                new SqlParameter("@vsType",     SqlDbType.VarChar, 20)
            };

            parameters[0].Value = model.MovId;
            parameters[1].Value = model.MerchantId;
            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);
        }