/// <summary> /// 更新ClubM某筆資料 /// </summary> /// <returns>Boolean</returns> public bool Update(ClubMInfo ClubM) { Database db = DatabaseFactory.CreateDatabase(); StringBuilder sqlStatement = new StringBuilder(); sqlStatement.Append("UPDATE club_m SET "); sqlStatement.Append("name = @name"); sqlStatement.Append(" WHERE sn = @sn"); DbCommand dbCommand = db.GetSqlStringCommand(sqlStatement.ToString()); db.AddInParameter(dbCommand, "@sn", DbType.Int64, ClubM.Sn); db.AddInParameter(dbCommand, "@name", DbType.String, ClubM.Name); bool result = false; try { db.ExecuteNonQuery(dbCommand); result = true; } catch (DbException ex) { LogController.WriteLog("ClubMDB.Update", ex.ToString()); throw (ex); } return(result); }
/// <summary> /// 新增ClubM1筆資料 /// </summary> /// <param name="ClubM"> /// ClubM新資料 /// </param> /// <returns>Boolean</returns> public bool AddNew(ClubMInfo ClubM) { Database db = DatabaseFactory.CreateDatabase(); StringBuilder sqlStatement = new StringBuilder(); sqlStatement.Append("INSERT INTO club_m "); sqlStatement.Append("(name)"); sqlStatement.Append("VALUES(@name)"); DbCommand dbCommand = db.GetSqlStringCommand(sqlStatement.ToString()); db.AddInParameter(dbCommand, "@name", DbType.String, ClubM.Name); bool result = false; try { db.ExecuteNonQuery(dbCommand); dbCommand = db.GetSqlStringCommand("SELECT max(sn) FROM club_m "); ClubM.Sn = int.Parse(db.ExecuteScalar(dbCommand).ToString()); result = true; } catch (DbException ex) { LogController.WriteLog("ClubMDB.AddNew", ex.ToString()); throw (ex); } return(result); }
private ClubMInfo BindInfo(IDataReader dr) { ClubMInfo myInfo = new ClubMInfo(); try { if (!dr["sn"].Equals(DBNull.Value)) { myInfo.Sn = int.Parse(dr["sn"].ToString()); } if (!dr["name"].Equals(DBNull.Value)) { myInfo.Name = dr["name"].ToString(); } } catch (Exception ex) { LogController.WriteLog("ClubMDB.BindInfo", ex.ToString()); throw (ex); } return(myInfo); }
/// <summary> /// 讀取ClubM1筆資料 /// </summary> /// <param name="Sn"> /// 流水號 /// </param> /// <returns>ClubMInfo</returns> public ClubMInfo GetInfo(int Sn) { Database db = DatabaseFactory.CreateDatabase(); StringBuilder sqlStatement = new StringBuilder(); sqlStatement.Append("SELECT * FROM club_m WHERE sn = @sn"); DbCommand dbCommand = db.GetSqlStringCommand(sqlStatement.ToString()); db.AddInParameter(dbCommand, "@sn", DbType.Int64, Sn); ClubMInfo myInfo = new ClubMInfo(); IList <ClubMInfo> myList = new List <ClubMInfo>(); myList = GetList(db, dbCommand); if (myList.Count > 0) { myInfo = myList[0]; } return(myInfo); }
/// <summary> /// 更新ClubM某筆資料 /// </summary> /// <param name="ClubM"> /// ClubM的某筆資料 /// </param> /// <returns>Boolean</returns> public static bool Update(ClubMInfo ClubM) { return(myDB.Update(ClubM)); }
/// <summary> /// 新增ClubM1筆資料 /// </summary> /// <param name="ClubM"> /// ClubM的新資料 /// </param> /// <returns>Boolean</returns> public static bool AddNew(ClubMInfo ClubM) { return(myDB.AddNew(ClubM)); }