protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) { //tx statuses //1 = pending //2 = processed //3 = removed if (e.CommandName == "btnconnectuser") { GridDataItem item = (GridDataItem)e.Item; int txkey = Convert.ToInt32(item["tx_external_key"].Text); decimal amount = Convert.ToDecimal(item["amount"].Text); int currency = Convert.ToInt32(item["info_currencies_key"].Text); RadComboBox ddlconnectuser = (RadComboBox)item.FindControl("ddlconnectuser"); if (ddlconnectuser.SelectedValue != "") { int userkey = Convert.ToInt32(ddlconnectuser.SelectedValue); Peerfx_DB.SPs.UpdateProcessDeposit(txkey, 2, userkey).Execute(); RadGrid1.Rebind(); //deposit to user, send email External_APIs.SendGrid sg = new External_APIs.SendGrid(); sg.Send_Email_Deposit_Received(userkey, 0, 0, amount, currency); } else { Label lblerror = (Label)item.FindControl("lblerror"); lblerror.Text = "You must select a user"; lblerror.Visible = true; } } else if (e.CommandName == "btnconnectpayment") { //connect tx to a payment GridDataItem item = (GridDataItem)e.Item; int txkey = Convert.ToInt32(item["tx_external_key"].Text); decimal amount = Convert.ToDecimal(item["amount"].Text); int currency = Convert.ToInt32(item["info_currencies_key"].Text); RadComboBox ddlconnectuser = (RadComboBox)item.FindControl("ddlconnectpayment"); if (ddlconnectuser.SelectedIndex > -1) { int paymentskey = Convert.ToInt32(ddlconnectuser.SelectedValue); //Move money to payment object & change status to 3 Peerfx_DB.SPs.UpdateProcessDeposit(txkey, 1, paymentskey).Execute(); RadGrid1.Rebind(); //Send to complete payment Models.Payment paymenttemp = sitetemp.getPayment(paymentskey); sitetemp.payment_complete(paymenttemp); int userkey = paymenttemp.Requestor_user_key; //deposit to payment, send email External_APIs.SendGrid sg = new External_APIs.SendGrid(); sg.Send_Email_Deposit_Received(userkey, paymentskey, 1, amount, currency); } else { Label lblerror = (Label)item.FindControl("lblerror"); lblerror.Text = "You must select a payment"; lblerror.Visible = true; } } else if (e.CommandName == "btnconnectCC") { //connect tx to a payment GridDataItem item = (GridDataItem)e.Item; int txkey = Convert.ToInt32(item["tx_external_key"].Text); RadComboBox ddlconnectCC = (RadComboBox)item.FindControl("ddlconnectCC"); if (ddlconnectCC.SelectedIndex > -1) { int paymentskey = Convert.ToInt32(ddlconnectCC.SelectedValue); Peerfx_DB.SPs.UpdateProcessDeposit(txkey, 1, paymentskey).Execute(); RadGrid1.Rebind(); //Send to currency conversion Models.Payment paymenttemp = sitetemp.getPayment(paymentskey); sitetemp.payment_complete(paymenttemp); } else { Label lblerror = (Label)item.FindControl("lblerror"); lblerror.Text = "You must select a payment"; lblerror.Visible = true; } } else if (e.CommandName == "btnremovedeposit") { GridDataItem item = (GridDataItem)e.Item; int txkey = Convert.ToInt32(item["tx_external_key"].Text); Peerfx_DB.SPs.UpdateTransactionExternalStatus(txkey, 3, sitetemp.get_ipaddress(),currentuser.User_key).Execute(); RadGrid1.Rebind(); } else if (e.CommandName == "Update") { //updating fees GridEditFormItem item = (GridEditFormItem)e.Item; Label lbltxfees = (Label)item.FindControl("lbltxfeeskey"); int txfees = Convert.ToInt32(lbltxfees.Text); RadNumericTextBox txtamount = (RadNumericTextBox)item.FindControl("txtamount"); RadComboBox ddlconnectuser = (RadComboBox)item.FindControl("ddlcurrency"); string description = (item["description"].Controls[0] as TextBox).Text; Peerfx_DB.SPs.UpdateTransactionFees(txfees, 0, 0, Convert.ToDecimal(txtamount.Text), Convert.ToInt32(ddlconnectuser.SelectedValue), description, null,0).Execute(); } else if (e.CommandName == "btninsertexisting") { //insert new deposit & connect it to existing bank account GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item; decimal amount = Convert.ToDecimal((insertedItem["tx_external_key"].FindControl("txtamountexisting") as RadNumericTextBox).Text); int sender_bank_key = Convert.ToInt32((insertedItem["tx_external_key"].FindControl("ddlexistingbankaccounts") as RadComboBox).SelectedValue); int receiver_bank_key = Convert.ToInt32((insertedItem["tx_external_key"].FindControl("ddlreceiveraccount") as RadComboBox).SelectedValue); string Description = (insertedItem["tx_external_key"].FindControl("txtdeposit") as RadTextBox).Text; string bankreference = (insertedItem["tx_external_key"].FindControl("txtbankref") as RadTextBox).Text; Peerfx_DB.SPs.UpdateTransactionsExternal(0, 1, sitetemp.getbankaccountcurrency(receiver_bank_key), amount, sitetemp.getpaymentobject(sender_bank_key), sitetemp.getpaymentobject(receiver_bank_key), sitetemp.get_ipaddress(), currentuser.User_key, Description, bankreference, 0, null, null).Execute(); RadGrid1.EditIndexes.Clear(); RadGrid1.MasterTableView.IsItemInserted = false; RadGrid1.MasterTableView.Rebind(); } }