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