示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(GwcModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

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

            strSql.Append(" BranchId = @BranchId , ");
            strSql.Append(" ProId = @ProId , ");
            strSql.Append(" Quantity = @Quantity , ");
            strSql.Append(" ProTeXing = @ProTeXing , ");
            strSql.Append(" ZlBs = @ZlBs , ");
            strSql.Append(" hope = @hope , ");
            strSql.Append(" Invalid = @Invalid , ");
            strSql.Append(" CreateTime = @CreateTime , ");
            strSql.Append(" MemberId = @MemberId  ");
            strSql.Append(" where GwcId=@GwcId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@GwcId",      SqlDbType.Decimal,    9),
                new SqlParameter("@BranchId",   SqlDbType.VarChar,   50),
                new SqlParameter("@ProId",      SqlDbType.VarChar,   50),
                new SqlParameter("@Quantity",   SqlDbType.Decimal,    9),
                new SqlParameter("@ProTeXing",  SqlDbType.Int,        4),
                new SqlParameter("@ZlBs",       SqlDbType.Decimal,    9),
                new SqlParameter("@hope",       SqlDbType.Decimal,    9),
                new SqlParameter("@Invalid",    SqlDbType.Bit,        1),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@MemberId",   SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.GwcId;
            parameters[1].Value = model.BranchId;
            parameters[2].Value = model.ProId;
            parameters[3].Value = model.Quantity;
            parameters[4].Value = model.ProTeXing;
            parameters[5].Value = model.ZlBs;
            parameters[6].Value = model.hope;
            parameters[7].Value = model.Invalid;
            parameters[8].Value = model.CreateTime;
            parameters[9].Value = model.MemberId; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
示例#2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(GwcModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.Gwc (");
            strSql.Append("BranchId,ProId,Quantity,ProTeXing,ZlBs,hope,Invalid,CreateTime,MemberId");
            strSql.Append(") values (");
            strSql.Append("@BranchId,@ProId,@Quantity,@ProTeXing,@ZlBs,@hope,@Invalid,@CreateTime,@MemberId");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@BranchId",   SqlDbType.VarChar,   50),
                new SqlParameter("@ProId",      SqlDbType.VarChar,   50),
                new SqlParameter("@Quantity",   SqlDbType.Decimal,    9),
                new SqlParameter("@ProTeXing",  SqlDbType.Int,        4),
                new SqlParameter("@ZlBs",       SqlDbType.Decimal,    9),
                new SqlParameter("@hope",       SqlDbType.Decimal,    9),
                new SqlParameter("@Invalid",    SqlDbType.Bit,        1),
                new SqlParameter("@CreateTime", SqlDbType.DateTime),
                new SqlParameter("@MemberId",   SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.BranchId;
            parameters[1].Value = model.ProId;
            parameters[2].Value = model.Quantity;
            parameters[3].Value = model.ProTeXing;
            parameters[4].Value = model.ZlBs;
            parameters[5].Value = model.hope;
            parameters[6].Value = model.Invalid;
            parameters[7].Value = model.CreateTime;
            parameters[8].Value = model.MemberId;

            bool result = false;

            try
            {
                model.GwcId = decimal.Parse(helper.ExecuteNonQueryBackId(strSql.ToString(), "GwcId", parameters));


                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
示例#3
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public GwcModel GetModel(decimal GwcId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select GwcId, BranchId, ProId, Quantity, ProTeXing, ZlBs, hope, Invalid, CreateTime, MemberId  ");
            strSql.Append("  from CORE.dbo.Gwc ");
            strSql.Append(" where GwcId=@GwcId");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GwcId", SqlDbType.Decimal)
            };
            parameters[0].Value = GwcId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["GwcId"].ToString() != "")
                {
                    model.GwcId = decimal.Parse(ds.Tables[0].Rows[0]["GwcId"].ToString());
                }
                model.BranchId = ds.Tables[0].Rows[0]["BranchId"].ToString();
                model.ProId    = ds.Tables[0].Rows[0]["ProId"].ToString();
                if (ds.Tables[0].Rows[0]["Quantity"].ToString() != "")
                {
                    model.Quantity = decimal.Parse(ds.Tables[0].Rows[0]["Quantity"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ProTeXing"].ToString() != "")
                {
                    model.ProTeXing = int.Parse(ds.Tables[0].Rows[0]["ProTeXing"].ToString());
                }
                if (ds.Tables[0].Rows[0]["ZlBs"].ToString() != "")
                {
                    model.ZlBs = decimal.Parse(ds.Tables[0].Rows[0]["ZlBs"].ToString());
                }
                if (ds.Tables[0].Rows[0]["hope"].ToString() != "")
                {
                    model.hope = decimal.Parse(ds.Tables[0].Rows[0]["hope"].ToString());
                }
                if (ds.Tables[0].Rows[0]["Invalid"].ToString() != "")
                {
                    if ((ds.Tables[0].Rows[0]["Invalid"].ToString() == "1") || (ds.Tables[0].Rows[0]["Invalid"].ToString().ToLower() == "true"))
                    {
                        model.Invalid = true;
                    }
                    else
                    {
                        model.Invalid = false;
                    }
                }
                if (ds.Tables[0].Rows[0]["CreateTime"].ToString() != "")
                {
                    model.CreateTime = DateTime.Parse(ds.Tables[0].Rows[0]["CreateTime"].ToString());
                }
                if (ds.Tables[0].Rows[0]["MemberId"].ToString() != "")
                {
                    model.MemberId = decimal.Parse(ds.Tables[0].Rows[0]["MemberId"].ToString());
                }

                return(model);
            }
            else
            {
                return(model);
            }
        }