示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(AsrsStorDBAcc.Model.StockListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update StockList set ");
            strSql.Append("StockID=@StockID,");
            strSql.Append("InHouseTime=@InHouseTime,");
            strSql.Append("MeterialboxCode=@MeterialboxCode,");
            strSql.Append("MeterialBatch=@MeterialBatch,");
            strSql.Append("MeterialStatus=@MeterialStatus,");
            strSql.Append("Reserve=@Reserve");
            strSql.Append(" where StockListID=@StockListID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StockID",         SqlDbType.BigInt,      8),
                new SqlParameter("@InHouseTime",     SqlDbType.DateTime),
                new SqlParameter("@MeterialboxCode", SqlDbType.NVarChar,   50),
                new SqlParameter("@MeterialBatch",   SqlDbType.NVarChar,   50),
                new SqlParameter("@MeterialStatus",  SqlDbType.NVarChar,   50),
                new SqlParameter("@Reserve",         SqlDbType.NVarChar,  200),
                new SqlParameter("@StockListID",     SqlDbType.BigInt, 8)
            };
            parameters[0].Value = model.StockID;
            parameters[1].Value = model.InHouseTime;
            parameters[2].Value = model.MeterialboxCode;
            parameters[3].Value = model.MeterialBatch;
            parameters[4].Value = model.MeterialStatus;
            parameters[5].Value = model.Reserve;
            parameters[6].Value = model.StockListID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public AsrsStorDBAcc.Model.StockListModel DataRowToModel(DataRow row)
 {
     AsrsStorDBAcc.Model.StockListModel model = new AsrsStorDBAcc.Model.StockListModel();
     if (row != null)
     {
         if (row["StockListID"] != null && row["StockListID"].ToString() != "")
         {
             model.StockListID = long.Parse(row["StockListID"].ToString());
         }
         if (row["StockID"] != null && row["StockID"].ToString() != "")
         {
             model.StockID = long.Parse(row["StockID"].ToString());
         }
         if (row["InHouseTime"] != null && row["InHouseTime"].ToString() != "")
         {
             model.InHouseTime = DateTime.Parse(row["InHouseTime"].ToString());
         }
         if (row["MeterialboxCode"] != null)
         {
             model.MeterialboxCode = row["MeterialboxCode"].ToString();
         }
         if (row["MeterialBatch"] != null)
         {
             model.MeterialBatch = row["MeterialBatch"].ToString();
         }
         if (row["MeterialStatus"] != null)
         {
             model.MeterialStatus = row["MeterialStatus"].ToString();
         }
         if (row["Reserve"] != null)
         {
             model.Reserve = row["Reserve"].ToString();
         }
     }
     return(model);
 }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public long Add(AsrsStorDBAcc.Model.StockListModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into StockList(");
            strSql.Append("StockID,InHouseTime,MeterialboxCode,MeterialBatch,MeterialStatus,Reserve)");
            strSql.Append(" values (");
            strSql.Append("@StockID,@InHouseTime,@MeterialboxCode,@MeterialBatch,@MeterialStatus,@Reserve)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StockID",         SqlDbType.BigInt,     8),
                new SqlParameter("@InHouseTime",     SqlDbType.DateTime),
                new SqlParameter("@MeterialboxCode", SqlDbType.NVarChar,  50),
                new SqlParameter("@MeterialBatch",   SqlDbType.NVarChar,  50),
                new SqlParameter("@MeterialStatus",  SqlDbType.NVarChar,  50),
                new SqlParameter("@Reserve",         SqlDbType.NVarChar, 200)
            };
            parameters[0].Value = model.StockID;
            parameters[1].Value = model.InHouseTime;
            parameters[2].Value = model.MeterialboxCode;
            parameters[3].Value = model.MeterialBatch;
            parameters[4].Value = model.MeterialStatus;
            parameters[5].Value = model.Reserve;

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

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt64(obj));
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public AsrsStorDBAcc.Model.StockListModel GetModel(long StockListID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 StockListID,StockID,InHouseTime,MeterialboxCode,MeterialBatch,MeterialStatus,Reserve from StockList ");
            strSql.Append(" where StockListID=@StockListID");
            SqlParameter[] parameters =
            {
                new SqlParameter("@StockListID", SqlDbType.BigInt)
            };
            parameters[0].Value = StockListID;

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

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