Esempio n. 1
0
        // 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);
        }
Esempio n. 2
0
        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");
            }
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }