/// <summary> /// 增加一条数据 /// </summary> public bool Add(OutHouseRecordME model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into OutHouseRecord("); strSql.Append("outHouseTime,productID,houseID)"); strSql.Append(" values ("); strSql.Append("@outHouseTime,@productID,@houseID)"); SqlParameter[] parameters = { new SqlParameter("@outHouseTime", SqlDbType.Timestamp,8), new SqlParameter("@productID", SqlDbType.NVarChar,50), new SqlParameter("@houseID", SqlDbType.Int,4)}; parameters[0].Value = model.outHouseTime; parameters[1].Value = model.productID; parameters[2].Value = model.houseID; int rows = _dbAssist.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
public bool AddProductOutRecord(OutHouseRecordME m) { return _outhouseRecordDAL.Add(m); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(OutHouseRecordME model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update OutHouseRecord set "); strSql.Append("houseID=@houseID"); strSql.Append(" where outHouseTime=@outHouseTime and productID=@productID "); SqlParameter[] parameters = { new SqlParameter("@houseID", SqlDbType.Int,4), new SqlParameter("@outHouseTime", SqlDbType.Timestamp,8), new SqlParameter("@productID", SqlDbType.NVarChar,50)}; parameters[0].Value = model.houseID; parameters[1].Value = model.outHouseTime; parameters[2].Value = model.productID; int rows = _dbAssist.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } }
/// <summary> /// 得到一个对象实体 /// </summary> public OutHouseRecordME GetModel(DateTime outHouseTime, string productID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 outHouseTime,productID,houseID from OutHouseRecord "); strSql.Append(" where outHouseTime=@outHouseTime and productID=@productID "); SqlParameter[] parameters = { new SqlParameter("@outHouseTime", SqlDbType.Timestamp,8), new SqlParameter("@productID", SqlDbType.NVarChar,50) }; parameters[0].Value = outHouseTime; parameters[1].Value = productID; OutHouseRecordME model = new OutHouseRecordME(); DataSet ds = _dbAssist.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["outHouseTime"] != null && ds.Tables[0].Rows[0]["outHouseTime"].ToString() != "") { model.outHouseTime = DateTime.Parse(ds.Tables[0].Rows[0]["outHouseTime"].ToString()); } if (ds.Tables[0].Rows[0]["productID"] != null && ds.Tables[0].Rows[0]["productID"].ToString() != "") { model.productID = ds.Tables[0].Rows[0]["productID"].ToString(); } if (ds.Tables[0].Rows[0]["houseID"] != null && ds.Tables[0].Rows[0]["houseID"].ToString() != "") { model.houseID = int.Parse(ds.Tables[0].Rows[0]["houseID"].ToString()); } return model; } else { return null; } }