Esempio n. 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AsrsStorDBAcc.Model.StockModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Stock set ");
            strSql.Append("GoodsSiteID=@GoodsSiteID,");
            strSql.Append("TrayID=@TrayID,");
            strSql.Append("IsFull=@IsFull,");
            strSql.Append("Reserve=@Reserve");
            strSql.Append(" where StockID=@StockID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsSiteID", SqlDbType.BigInt,     8),
                new SqlParameter("@TrayID",      SqlDbType.NVarChar,  50),
                new SqlParameter("@IsFull",      SqlDbType.Bit,        1),
                new SqlParameter("@Reserve",     SqlDbType.NVarChar, 200),
                new SqlParameter("@StockID",     SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.GoodsSiteID;
            parameters[1].Value = model.TrayID;
            parameters[2].Value = model.IsFull;
            parameters[3].Value = model.Reserve;
            parameters[4].Value = model.StockID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(AsrsStorDBAcc.Model.StockModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Stock(");
            strSql.Append("GoodsSiteID,TrayID,IsFull,Reserve)");
            strSql.Append(" values (");
            strSql.Append("@GoodsSiteID,@TrayID,@IsFull,@Reserve)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsSiteID", SqlDbType.BigInt,    8),
                new SqlParameter("@TrayID",      SqlDbType.NVarChar, 50),
                new SqlParameter("@IsFull",      SqlDbType.Bit,       1),
                new SqlParameter("@Reserve",     SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = model.GoodsSiteID;
            parameters[1].Value = model.TrayID;
            parameters[2].Value = model.IsFull;
            parameters[3].Value = model.Reserve;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public AsrsStorDBAcc.Model.StockModel DataRowToModel(DataRow row)
 {
     AsrsStorDBAcc.Model.StockModel model = new AsrsStorDBAcc.Model.StockModel();
     if (row != null)
     {
         if (row["StockID"] != null && row["StockID"].ToString() != "")
         {
             model.StockID = long.Parse(row["StockID"].ToString());
         }
         if (row["GoodsSiteID"] != null && row["GoodsSiteID"].ToString() != "")
         {
             model.GoodsSiteID = long.Parse(row["GoodsSiteID"].ToString());
         }
         if (row["TrayID"] != null)
         {
             model.TrayID = row["TrayID"].ToString();
         }
         if (row["IsFull"] != null && row["IsFull"].ToString() != "")
         {
             if ((row["IsFull"].ToString() == "1") || (row["IsFull"].ToString().ToLower() == "true"))
             {
                 model.IsFull = true;
             }
             else
             {
                 model.IsFull = false;
             }
         }
         if (row["Reserve"] != null)
         {
             model.Reserve = row["Reserve"].ToString();
         }
     }
     return(model);
 }
Esempio n. 4
0
        public AsrsStorDBAcc.Model.StockModel GetModelByGSID(long gsID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select top 1 StockID,GoodsSiteID,TrayID,IsFull,Reserve from Stock ");
            strSql.Append(" where GoodsSiteID=@GoodsSiteID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@GoodsSiteID", SqlDbType.BigInt)
            };
            parameters[0].Value = gsID;

            AsrsStorDBAcc.Model.StockModel model = new AsrsStorDBAcc.Model.StockModel();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }