Esempio n. 1
0
 public TransactionTable(TransactionTable other)
 {
     //no deepcopy required since strings are references in c#, and
     //ints are basic types.
     this.baseValues = new Dictionary <string, string>(other.baseValues);
     this.diffValues = new Dictionary <string, int>(other.diffValues);
 }
Esempio n. 2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            SA46Team10BsportsEntities ctx = new SA46Team10BsportsEntities();
            TransactionTable          tt  = new TransactionTable();

            try
            {
                tt.CustomerID = Convert.ToInt32(CIDTextBox.Text);
                CourtTable ct = ctx.CourtTables.Where(x => x.CourtType == comboBox1.Text).First();
                tt.CourtTable = ct;
                tt.DateBook   = dateTimePicker1.Value.Date;
                SlotTable st = ctx.SlotTables.Where(x => x.Time == timeSlotListBox1.Text).First();
                tt.SlotTable = st;
                tt.Status    = "Booked";

                ctx.TransactionTables.Add(tt);
                ctx.SaveChanges();
                MessageBox.Show("Booking for " + comboBox1.Text + " on " + dateTimePicker1.Value.ToString("dd/MM/yyyy") + " at " + timeSlotListBox1.Text + " is completed.");
                ClearContent();
            }

            catch (System.FormatException)
            {
                MessageBox.Show("Please ensure all fields are manually selected");
            }
        }
        //Displays the current table
        public void disp_data()
        {
            //Creates a command for the SQL query
            SqlCommand cmd = con.CreateCommand();

            cmd.CommandType = CommandType.Text;



            cmd.CommandText = "select top 10 processing_date as 'Processing Date'," +
                              " CONCAT('$',balance) as Balance," +
                              " Action = CASE Action " +
                              " WHEN 'CR' THEN 'Deposit' " +
                              " WHEN 'DR' THEN 'Withdrawal' " +
                              " ELSE Action" +
                              " END," +
                              " Description " +
                              " from CustomerData " +
                              " ORDER BY processing_date desc; ";

            //Executes the SQL query
            cmd.ExecuteNonQuery();

            //Data Table Read from sql server
            DataTable dt = new DataTable();

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            //Fills the SQL Data by the Data Table
            da.Fill(dt);

            //Gets the Data from the data table and places it into the HTML
            TransactionTable.DataSource = dt;
            TransactionTable.DataBind();
        }
Esempio n. 4
0
 public object FundTransfer(Transaction transaction)
 {
     try
     {
         BankAppEntities1 db = new BankAppEntities1();
         TransactionTable tt = new TransactionTable();
         if (tt.UserId == 0)
         {
             tt.UserId          = transaction.UserId;
             tt.AccountNumber   = transaction.AccountNumber;
             tt.BenificiaryName = transaction.BenificiaryName;
             tt.IFSC            = transaction.IFSC;
             tt.Branch          = transaction.Branch;
             tt.Date            = transaction.Date;
             tt.Amount          = transaction.Amount;
             tt.Remarks         = transaction.Remarks;
             db.TransactionTables.Add(tt);
             db.SaveChanges();
             return(new Response
             {
                 Status = "Success", Message = "SuccessFully Saved."
             });
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(new Response
     {
         Status = "Error", Message = "Invalid Data."
     });
 }
        public TransactionTable UpdateItems(WebProperties WebProps, DataTable Items, IntegrationLog Log)
        {
            CheckArgumentForNull(WebProps, nameof(WebProps));
            CheckArgumentForNull(Items, nameof(Items));
            CheckArgumentForNull(Log, nameof(Log));

            const string queryTemplate = "SELECT * FROM {0} WHERE {1}=@id";
            var          tableName     = WebProps.Properties[PropKeyTable];
            var          idColumn      = WebProps.Properties[PropKeyIdColumn];
            var          trans         = new TransactionTable();

            using (var connection = GetConnection(WebProps.Properties))
            {
                connection.Open();

                foreach (DataRow drItem in Items.Rows)
                {
                    var currentId = drItem[ColNameId].ToString();
                    var spId      = drItem[ColNameSpid].ToString();

                    try
                    {
                        if (currentId == string.Empty)
                        {
                            trans.AddRow(spId, InsertRow(WebProps, drItem, Log, connection), TransactionType.INSERT);
                        }
                        else
                        {
                            var dataSet = new DataSet();
                            using (var command = new SqlCommand(string.Format(queryTemplate, tableName, idColumn), connection))
                            {
                                command.Parameters.AddWithValue("@id", currentId);

                                using (var dataAdapter = new SqlDataAdapter(command))
                                {
                                    dataAdapter.Fill(dataSet);
                                }
                            }

                            if (dataSet.Tables.Count > 0 && dataSet.Tables[0].Rows.Count > 0)
                            {
                                trans.AddRow(spId, UpdateRow(WebProps, drItem, Log, connection), TransactionType.UPDATE);
                            }
                            else
                            {
                                trans.AddRow(spId, InsertRow(WebProps, drItem, Log, connection), TransactionType.INSERT);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.ToString());
                        Log.LogMessage(ex.Message, IntegrationLogType.Error);
                        trans.AddRow(spId, currentId, TransactionType.FAILED);
                    }
                }
            }

            return(trans);
        }
        public IHttpActionResult PutTransactionTable(int id, TransactionTable transactionTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != transactionTable.TransactionID)
            {
                return(BadRequest());
            }

            db.Entry(transactionTable).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TransactionTableExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 7
0
        private void button8_Click_1(object sender, EventArgs e)
        {
            TransactionTable T = new TransactionTable();

            T.StartPosition = FormStartPosition.CenterParent;
            T.ShowDialog();
        }
        public IHttpActionResult PostTransactionTable(TransactionTable transactionTable)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.TransactionTables.Add(transactionTable);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (TransactionTableExists(transactionTable.TransactionID))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { id = transactionTable.TransactionID }, transactionTable));
        }
 public int Refund(TransactionTable transaction, Wallet wallet)
 {
     try {
         int flag = ProcessTransaction(transaction, "Refund");
         if (flag == 1)
         {
             int flagInternal = restaurantBAL.CreateTransactionsTableEntry(transaction);
             if (flagInternal == 1)
             {
                 return(1);
             }
             else
             {
                 return(0);
             }
         }
         else
         {
             return(0);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 10
0
    protected bool ParseLine(string s, TransactionTable data)
    {
        if (s != previousLine)
        {
            previousLine = s;
            //pull out all transactions...
            int           startTransaction = 0;
            int           endTransaction;
            List <string> transactionStrings = new List <string>();

            startTransaction = s.IndexOf("<tr");
            while (startTransaction != -1)
            {
                endTransaction = s.IndexOf("/tr>", startTransaction) + "/tr>".Length;
                string transaction = s.Substring(startTransaction,
                                                 endTransaction - startTransaction);
                transactionStrings.Add(transaction);
                startTransaction = s.IndexOf("<tr", endTransaction);
            }

            List <Transaction> transactions = new List <Transaction>();
            foreach (string transactionString in transactionStrings)
            {
                Transaction t = Transaction.ProcessTransaction(transactionString);
                if (t != null)
                {
                    transactions.Add(t);
                }
            }

            data.UpdateTransactionTable(transactions);
            return(true);
        }
        return(false);
    }
Esempio n. 11
0
        public TransactionTable UpdateItems(WebProperties WebProps, DataTable Items, IntegrationLog Log)
        {
            TransactionTable trans = new TransactionTable();

            if (BuildWSDL(WebProps, Log))
            {
                MethodInfo Method = null;

                foreach (MethodInfo t in methodInfo)
                {
                    if (t.Name == WebProps.Properties["WSDLFunction"].ToString())
                    {
                        Method = t;
                        param  = t.GetParameters();
                        break;
                    }
                }

                if (Method != null)
                {
                    foreach (DataRow drItem in Items.Rows)
                    {
                        try
                        {
                            Hashtable hshProps = GetItemHash(WebProps, drItem);

                            object[] param1 = new object[param.Length];

                            int i = 0;

                            foreach (var p in param)
                            {
                                param1[i++] = Convert.ChangeType(hshProps[p.Name], p.ParameterType);
                            }

                            Object obj      = Activator.CreateInstance(service);
                            Object response = Method.Invoke(obj, param1);
                            try
                            {
                                if (WebProps.Properties["LogInfo"].ToString() == "True")
                                {
                                    Log.LogMessage("WSDL Response: " + response.ToString(), IntegrationLogType.Information);
                                }
                            }
                            catch { }
                        }
                        catch (Exception ex)
                        {
                            Log.LogMessage("Error sending item (" + drItem["SPID"].ToString() + "): " + ex.Message, IntegrationLogType.Error);
                        }
                    }
                }
                else
                {
                    Log.LogMessage("Could not find method", IntegrationLogType.Error);
                }
            }
            return(trans);
        }
Esempio n. 12
0
        // Public Methods (9) 

        public TransactionTable DeleteItems(WebProperties webProps, DataTable items, IntegrationLog log)
        {
            var transactionTable = new TransactionTable();

            try
            {
                if (!bool.Parse((string)webProps.Properties["AllowDeleteInt"]))
                {
                    throw new Exception("Office 365 delete is not allowed.");
                }

                O365Service o365Service = GetO365Service(webProps);

                List <string> ids;
                Dictionary <string, string> idMap = BuildIdMap(items, out ids);

                int index = 0;

                foreach (
                    O365Result result in
                    o365Service.DeleteListItemsById(ids.ToArray(), (string)webProps.Properties["List"]))
                {
                    string o365Id = result.ItemId.ToString();
                    string spid;

                    try
                    {
                        spid = idMap[o365Id];
                    }
                    catch
                    {
                        spid = items.Rows[index]["SPID"].ToString();
                    }

                    if (result.Success)
                    {
                        transactionTable.AddRow(spid, o365Id, TransactionType.DELETE);
                    }
                    else
                    {
                        transactionTable.AddRow(spid, o365Id, TransactionType.FAILED);
                        log.LogMessage(string.Format(
                                           "Could not delete record with Office 365 ID: {0}, SharePoint ID: {1}. Message: {2}",
                                           o365Id, spid, result.Error), IntegrationLogType.Warning);
                    }

                    index++;
                }
            }
            catch (Exception e)
            {
                log.LogMessage(e.Message, IntegrationLogType.Error);
            }

            return(transactionTable);
        }
Esempio n. 13
0
 public int CreateTransactionsTableEntry(TransactionTable transaction)
 {
     try {
         int flag = restaurantDAL.CreateTransactionsTableEntry(transaction);
         return(flag);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
 public ActionResult ViewTransaction(int transId)
 {
     try {
         TransactionTable transaction = restaurantBAL.FindTransactionsTable(transId);
         return(View(transaction));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "Error", ex));
     }
 }
Esempio n. 15
0
 public TransactionTable FindTransactionsTable(int transactionId)
 {
     try {
         TransactionTable transaction = restaurantDAL.FindTransactionsTable(transactionId);
         return(transaction);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        public IHttpActionResult GetTransactionTable(int id)
        {
            TransactionTable transactionTable = db.TransactionTables.Find(id);

            if (transactionTable == null)
            {
                return(NotFound());
            }

            return(Ok(transactionTable));
        }
Esempio n. 17
0
 public int EditTransactionsTable(TransactionTable transaction)
 {
     try {
         int flag = restaurantDAL.EditTransactionsTable(transaction);
         return(flag);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 18
0
        public TransactionTable UpdateItems(WebProperties webProps, DataTable items, IntegrationLog log)
        {
            var transactionTable = new TransactionTable();

            try
            {
                O365Service o365Service = GetO365Service(webProps);

                List <string> ids;
                Dictionary <string, string> idMap = BuildIdMap(items, out ids);

                int index = 0;

                foreach (
                    O365Result result in
                    o365Service.UpsertItems((string)webProps.Properties["List"], webProps.IntegrationId, items))
                {
                    string o365Id = result.ItemId.ToString();

                    string spId;

                    try
                    {
                        spId = idMap[o365Id];
                    }
                    catch
                    {
                        spId = items.Rows[index]["SPID"].ToString();
                    }

                    if (result.Success)
                    {
                        transactionTable.AddRow(spId, o365Id, result.TransactionType);
                    }
                    else
                    {
                        transactionTable.AddRow(spId, o365Id, TransactionType.FAILED);

                        log.LogMessage(string.Format(
                                           "Could not insert / update record with Office 365 ID: {0}, SharePoint ID: {1}. Message: {2}",
                                           o365Id, spId, result.Error), IntegrationLogType.Warning);
                    }

                    index++;
                }
            }
            catch (Exception e)
            {
                log.LogMessage(e.Message, IntegrationLogType.Error);
            }

            return(transactionTable);
        }
        public IHttpActionResult DeleteTransactionTable(int id)
        {
            TransactionTable transactionTable = db.TransactionTables.Find(id);

            if (transactionTable == null)
            {
                return(NotFound());
            }

            db.TransactionTables.Remove(transactionTable);
            db.SaveChanges();

            return(Ok(transactionTable));
        }
Esempio n. 20
0
    // Update is called once per frame
    void Update()
    {
        if (t1 == null)
        {
            t1 = p1.LatestEvent;
        }
        if (t2 == null)
        {
            t2 = p2.LatestEvent;
        }

        if (t1 != null && t2 != null)
        {
            UpdateStats();
            t1 = null;
            t2 = null;
        }
    }
 public int ProcessTransaction(TransactionTable transaction, string transactionType)
 {
     try {
         if (transactionType.Equals("Pay"))
         {
             Wallet depositor = restaurantBAL.FindWallet((int)(restaurantBAL.FindCustomer((int)transaction.Trans_From_Id).wallet_id));
             Wallet accepter  = restaurantBAL.FindWallet((int)(restaurantBAL.FindCustomer((int)transaction.Trans_To_Id).wallet_id));
             int    flag      = DeductMoney((decimal)transaction.Trans_Amount, depositor.Wallet_Id);
             if (flag == 1)
             {
                 AddMoney((decimal)transaction.Trans_Amount, accepter.Wallet_Id);
                 return(1);
             }
             else
             {
                 AddMoney((decimal)transaction.Trans_Amount, depositor.Wallet_Id);
                 return(0);
             }
         }
         if (transactionType.Equals("Refund"))
         {
             Wallet depositor = restaurantBAL.FindWallet((int)(restaurantBAL.FindCustomer((int)transaction.Trans_To_Id).wallet_id));
             Wallet accepter  = restaurantBAL.FindWallet((int)(restaurantBAL.FindCustomer((int)transaction.Trans_From_Id).wallet_id));
             int    flag      = DeductMoney((decimal)transaction.Trans_Amount, depositor.Wallet_Id);
             if (flag == 1)
             {
                 AddMoney((decimal)transaction.Trans_Amount, accepter.Wallet_Id);
                 return(1);
             }
             else
             {
                 AddMoney((decimal)transaction.Trans_Amount, depositor.Wallet_Id);
                 return(0);
             }
         }
         return(0);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 22
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                int TransID = Convert.ToInt32(dataGridView1.SelectedCells[0].FormattedValue.ToString());
                SA46Team10BsportsEntities context = new SA46Team10BsportsEntities();
                TransactionTable          t       = context.TransactionTables.Where(x => x.TransactionID == TransID).First();
                t.Status = "Cancelled";
                context.SaveChanges();
                MessageBox.Show("Transaction " + dataGridView1.SelectedCells[0].FormattedValue.ToString() + " has been cancelled.");
                ClearContent();
            }

            catch (System.IndexOutOfRangeException ex)
            {
                MessageBox.Show(ex.Message + "\nPlease select a row");
            }

            catch (System.ArgumentOutOfRangeException ex)
            {
                MessageBox.Show("\nPlease select a row before click on cancel");
            }
        }
        public TransactionTable DeleteItems(WebProperties WebProps, DataTable Items, IntegrationLog Log)
        {
            CheckArgumentForNull(WebProps, nameof(WebProps));
            CheckArgumentForNull(Items, nameof(Items));

            const string deleteCommandTemplate = "DELETE FROM {0} WHERE {1}=@id";
            var          tableName             = WebProps.Properties[PropKeyTable];
            var          idColumn = WebProps.Properties[PropKeyIdColumn];

            var table = new TransactionTable();

            using (var connection = GetConnection(WebProps.Properties))
            {
                connection.Open();

                foreach (DataRow dataRow in Items.Rows)
                {
                    try
                    {
                        using (var command = new SqlCommand(string.Format(deleteCommandTemplate, tableName, idColumn), connection))
                        {
                            command.Parameters.AddWithValue("@id", dataRow[ColNameId].ToString());
                            command.ExecuteNonQuery();
                        }

                        table.AddRow(dataRow[ColNameSpid].ToString(), dataRow[ColNameId].ToString(), TransactionType.DELETE);
                    }
                    catch (Exception ex)
                    {
                        Trace.TraceError(ex.ToString());
                        table.AddRow(dataRow[ColNameSpid].ToString(), dataRow[ColNameId].ToString(), TransactionType.FAILED);
                    }
                }
            }

            return(table);
        }
Esempio n. 24
0
    void RunScraper()
    {
        TransactionTable data = new TransactionTable();

        while (stillRunning)
        {
            string[] lines = Scrape();

            foreach (string line in lines)
            {
                string line2 = line.Trim();
                if (line2.StartsWith("<div class = 'user_stats_table_box'>"))
                {
                    if (ParseLine(line2, data)) //new result!
                    {
                        lock (TransactionTableLock)
                        {
                            latestEvent = new TransactionTable(data); //make a copy of the data.
                        }
                    }
                }
            }
        }
    }
Esempio n. 25
0
        public TransactionTable UpdateItems(WebProperties webProps, DataTable items, IntegrationLog log)
        {
            var transactionTable = new TransactionTable();

            try
            {
                SfService sfService = GetSfService(webProps);

                if (!sfService.IsSyncEnabled())
                {
                    throw new Exception("All synchronizations are currently disabled.");
                }

                List <string> ids;
                Dictionary <string, string> idMap = BuildIdMap(items, out ids);

                int index = 0;

                foreach (var result in sfService.UpsertItems((string)webProps.Properties["Object"], items))
                {
                    foreach (var pair in result)
                    {
                        SaveResult upsertResult = pair.Value;

                        string sfId = upsertResult.id;
                        string spid;

                        try
                        {
                            spid = idMap[sfId];
                        }
                        catch
                        {
                            spid = items.Rows[index]["SPID"].ToString();
                        }

                        if (upsertResult.success)
                        {
                            transactionTable.AddRow(spid, sfId,
                                                    pair.Key == UpsertKind.INSERT
                                                        ? TransactionType.INSERT
                                                        : TransactionType.UPDATE);
                        }
                        else
                        {
                            transactionTable.AddRow(spid, sfId, TransactionType.FAILED);
                            if (upsertResult.errors.Any())
                            {
                                Error[] errors = upsertResult.errors;

                                for (int i = 0; i < errors.Count(); i++)
                                {
                                    var error = errors[i];

                                    string fields = string.Empty;

                                    if (error.fields != null)
                                    {
                                        try
                                        {
                                            fields = "Fields: " + string.Join(",", error.fields) + ".";
                                        }
                                        catch { }
                                    }

                                    log.LogMessage(
                                        string.Format(
                                            "Could not insert / update record with Salesforce ID: {0}, SharePoint ID: {1}. Status code: {2}. Message: {3} {4}",
                                            sfId, spid, error.statusCode, error.message, fields), IntegrationLogType.Warning);
                                }
                            }
                        }
                    }

                    index++;
                }
            }
            catch (Exception e)
            {
                log.LogMessage(e.Message, IntegrationLogType.Error);
            }

            return(transactionTable);
        }
Esempio n. 26
0
        // Public Methods (9) 

        public TransactionTable DeleteItems(WebProperties webProps, DataTable items, IntegrationLog log)
        {
            var transactionTable = new TransactionTable();

            try
            {
                if (!bool.Parse((string)webProps.Properties["AllowDeleteInt"]))
                {
                    throw new Exception("Salesforce delete is not allowed.");
                }

                SfService sfService = GetSfService(webProps);

                if (!sfService.IsSyncEnabled())
                {
                    throw new Exception("All synchronizations are currently disabled.");
                }

                List <string> ids;
                Dictionary <string, string> idMap = BuildIdMap(items, out ids);

                int index = 0;

                foreach (DeleteResult deleteResult in sfService.DeleteObjectItemsById(ids.ToArray()))
                {
                    string sfId = deleteResult.id;
                    string spid;

                    try
                    {
                        spid = idMap[sfId];
                    }
                    catch
                    {
                        spid = items.Rows[index]["SPID"].ToString();
                    }

                    if (deleteResult.success)
                    {
                        transactionTable.AddRow(spid, sfId, TransactionType.DELETE);
                    }
                    else
                    {
                        transactionTable.AddRow(spid, sfId, TransactionType.FAILED);
                        if (deleteResult.errors.Any())
                        {
                            Error[] errors = deleteResult.errors;

                            for (int i = 0; i < errors.Count(); i++)
                            {
                                log.LogMessage(
                                    string.Format(
                                        "Could not delete record with Salesforce ID: {0}, SharePoint ID: {1}. Status code: {2}. Message: {3}. Fields: {4}",
                                        sfId, spid, errors[i].statusCode, errors[i].message,
                                        string.Join(",", errors[i].fields)), IntegrationLogType.Warning);
                            }
                        }
                    }

                    index++;
                }
            }
            catch (Exception e)
            {
                log.LogMessage(e.Message, IntegrationLogType.Error);
            }

            return(transactionTable);
        }
Esempio n. 27
0
 public void addTransaction(TransactionTable transaction)
 {
     entities.TransactionTables.Add(transaction);
     entities.SaveChanges();
 }
Esempio n. 28
0
        public TransactionTable DeleteItems(WebProperties WebProps, DataTable Items, IntegrationLog Log)
        {
            TransactionTable trans = new TransactionTable();

            return(trans);
        }