/// <summary> /// Updates a kunde /// </summary> public void OpdaterKunde(int type) { switch (type) { case 1: SQLAPI.Update("Kunde SET Fornavn = " + fornavn + " WHERE KundeNr = " + kundeNr); break; case 2: SQLAPI.Update("Kunde SET Efternavn = " + efternavn + " WHERE KundeNr = " + kundeNr); break; case 3: SQLAPI.Update("Kunde SET Adresse = " + adresse + " WHERE KundeNr = " + kundeNr); break; case 4: SQLAPI.Update("Kunde SET PostNr = " + postNr + " WHERE KundeNr = " + kundeNr); break; case 5: SQLAPI.Update("Kunde SET TlfNr = " + tlfNr + " WHERE KundeNr = " + kundeNr); break; default: MessageBox.Show("Error\nIf you find a developer give him/her this message: OpdaterKunde() did not lead to anything."); break; } }
/// <summary> /// Creates a transaction for a udbetaling. /// </summary> /// <param name="amount"></param> public void Udbetaling(double amount) { if (amount < 0) { MessageBox.Show("Error!\n\nDer var en taste fejl!"); return; } double newSaldo = 0; System.Data.DataTable table = new System.Data.DataTable(); adapter = SQLAPI.Read("Saldo FROM Konto WHERE KontoNr = " + kontoNr); adapter.Fill(table); newSaldo = Double.Parse(table.Rows[0]["Saldo"].ToString()) - amount; if (newSaldo < 0) { MessageBox.Show("Error!\n\nDer er ikke penge nok på kontoen"); } else { SQLAPI.Update("Konto SET Saldo = " + newSaldo + " WHERE KontoNr = " + kontoNr); // Update the saldo on the the account SQLAPI.Insert("Transaktion(Beløb,Dato,KontoNr) Values(" + (amount * -1) + ", CAST('" + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "' AS DATETIME)," + kontoNr + ")"); // Create a transaction } }