Exemplo n.º 1
0
 /// <summary>
 /// Creates the given konto
 /// </summary>
 public void OpretKonto()
 {
     if (SQLAPI.Insert("Konto(KontoType, KundeNr, Saldo, OprettelsesDato) VALUES(" + typeNr + ", " + kundeNr + ", " + saldo + ", CAST('" + oprettelsesdato.ToString("yyyy-MM-dd hh:mm:ss") + "' AS DATETIME))"))
     {
         MessageBox.Show("Kontoen er nu oprettet!");
     }
 }
Exemplo n.º 2
0
        /// <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
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a kunde
        /// </summary>
        public void OpretKunde()
        {
            bool success;

            if (tlfNr == 0)
            {
                success = SQLAPI.Insert("Kunde(Fornavn, Efternavn, PostNr, Adresse, OprettelsesDato) VALUES(N'" + fornavn + "', N'" + efternavn + "', " + postNr + ", N'" + adresse + "', CAST('" + oprettelsesdato.ToString("yyyy-MM-dd hh:mm:ss") + "' AS DATETIME))");
            }
            else
            {
                success = SQLAPI.Insert("Kunde(Fornavn, Efternavn, PostNr, Adresse, TlfNr, OprettelsesDato) VALUES(N'" + fornavn + "', N'" + efternavn + "', " + postNr + ", N'" + adresse + "', " + tlfNr + ", CAST('" + oprettelsesdato.ToString("yyyy-MM-dd hh:mm:ss") + "' AS DATETIME))");
            }
            if (success)
            {
                MessageBox.Show("Kunden er nu oprettet!");
            }
        }