Exemplo n.º 1
0
        internal static bool CreateTransaction(CreateTransactionData data)
        {
            using (SqlConnection con = new SqlConnection(_ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("dbo.CreateAccountTransaction", con);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlParameter outParam = cmd.Parameters.Add("@OutboundAccountID", SqlDbType.Int);
                outParam.Value = data.OutboundAccountID;
                SqlParameter inParam = cmd.Parameters.Add("@InboundAccountID", SqlDbType.Int);
                inParam.Value = data.InboundAccountID;
                SqlParameter valParam = cmd.Parameters.Add("@Value", SqlDbType.Float);
                valParam.Value = data.Value;
                SqlParameter dtParam = cmd.Parameters.Add("@Date", SqlDbType.DateTime);
                dtParam.Value = data.Date;
                SqlParameter descParam = cmd.Parameters.Add("@Description", SqlDbType.VarChar, 228);
                descParam.Value = data.Description;

                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
            }
            return true;
        }
Exemplo n.º 2
0
        private void startTransactionCommand(object parameter)
        {
            //lock the start of a new transaction
            CanStartTransaction = false;

            setInfoTextWarning("Erstelle Transaktion");

            CreateTransactionData data = new CreateTransactionData();
            data.Date = DateTime.Now;
            data.Description = Description;

            //positiv or negative?
            if(TransactionTypeIsNegative)
            {
                //money will be withdrawn from initiator and credited to target account
                data.OutboundAccountID = InitiatingAccount.ID;
                data.InboundAccountID = SelectedTargetAccount.ID;
            }
            else
            {
                //money will be withdrawn from target account and credited to initiator
                data.OutboundAccountID = InitiatingAccount.ID;
                data.InboundAccountID = SelectedTargetAccount.ID;
            }

            data.Value = Value;

            setInfoTextWarning("Führe Transaktion durch");

            try
            {
                DBHelper.CreateTransaction(data);
                setInfoTextWarning("Transaktion durchgeführt");
                _RefreshAccountBalance();
            }
            catch(Exception ex)
            {
                setInfoTextError("Fehler beim durchführen der Transaktion", ex.Message);
            }

            CanStartTransaction = true;
        }