Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(OrderExpectModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into CORE.dbo.OrderExpect (");
            strSql.Append("OrderExpectDay,OrderId,Num");
            strSql.Append(") values (");
            strSql.Append("@OrderExpectDay,@OrderId,@Num");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderExpectDay", SqlDbType.Int,      4),
                new SqlParameter("@OrderId",        SqlDbType.VarChar, 50),
                new SqlParameter("@Num",            SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.OrderExpectDay;
            parameters[1].Value = model.OrderId;
            parameters[2].Value = model.Num;

            bool result = false;

            try
            {
                helper.ExecSqlReInt(strSql.ToString(), parameters);


                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public OrderExpectModel GetModel(int OrderExpectDay, string OrderId)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select OrderExpectDay, OrderId, Num  ");
            strSql.Append("  from CORE.dbo.OrderExpect ");
            strSql.Append(" where OrderExpectDay=@OrderExpectDay and OrderId=@OrderId ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderExpectDay", SqlDbType.Int,     4),
                new SqlParameter("@OrderId",        SqlDbType.VarChar, 50)
            };
            parameters[0].Value = OrderExpectDay;
            parameters[1].Value = OrderId;


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

            if (ds.Tables[0].Rows.Count > 0)
            {
                if (ds.Tables[0].Rows[0]["OrderExpectDay"].ToString() != "")
                {
                    model.OrderExpectDay = int.Parse(ds.Tables[0].Rows[0]["OrderExpectDay"].ToString());
                }
                model.OrderId = ds.Tables[0].Rows[0]["OrderId"].ToString();
                if (ds.Tables[0].Rows[0]["Num"].ToString() != "")
                {
                    model.Num = decimal.Parse(ds.Tables[0].Rows[0]["Num"].ToString());
                }

                return(model);
            }
            else
            {
                return(model);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(OrderExpectModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

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

            strSql.Append(" OrderExpectDay = @OrderExpectDay , ");
            strSql.Append(" OrderId = @OrderId , ");
            strSql.Append(" Num = @Num  ");
            strSql.Append(" where OrderExpectDay=@OrderExpectDay and OrderId=@OrderId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@OrderExpectDay", SqlDbType.Int,      4),
                new SqlParameter("@OrderId",        SqlDbType.VarChar, 50),
                new SqlParameter("@Num",            SqlDbType.Decimal, 9)
            };

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