// Save existed member to MemberJoinTrip table public static bool AddExistedToJoinTrip(MemberInTripModel memberInTrip, int tripID) { int result = 0; string sqlString = $"INSERT INTO MEMBERJOINTRIP VALUES({tripID},@ID,@MoneyPaid)"; using (var cnn = new SQLiteConnection(LoadConnectionString())) { result = cnn.Execute(sqlString, memberInTrip); } return((result == 0) ? false : true); }
public void GetMoreMoneyFromMember(MemberInTripModel memberInTrip, int amount) { memberInTrip.MoneyPaid += amount; // update database bool result = DatabaseAccess.UpdateMemberAddMoneyPaid(this.ID, memberInTrip, amount); if (!result) { Console.WriteLine("Fail add more money"); } }
public static bool UpdateMemberAddMoneyPaid(int tripID, MemberInTripModel memberInTrip, int amount) { string sqlString = $"UPDATE MEMBERJOINTRIP " + $"SET MONEYPAID = MONEYPAID + {amount} " + $" WHERE TRIPID = {tripID} AND MEMBERID = @ID"; int result = 0; using (var cnn = new SQLiteConnection(LoadConnectionString())) { result = cnn.Execute(sqlString, memberInTrip); } return(result == 0 ? false : true); }
public void AddAlreadyExistedMember(MemberModel memberModel, int moneyPaid = 0) { var newMemberJoin = new MemberInTripModel { ID = memberModel.ID, Name = memberModel.Name, MoneyPaid = moneyPaid }; this.memberList.Add(newMemberJoin); // add in database DatabaseAccess.AddExistedToJoinTrip(newMemberJoin, this.ID); }