protected void btnwithdraw_Click(object sender, EventArgs e) { try { String username = (string)Session["username"]; String bankid = dropdownbank.SelectedItem.Value.ToString(); String wamount = txtamount.Text.ToString(); int amount = Convert.ToInt32(wamount); ProjectDatasetTableAdapters.withdrawalsTableAdapter wds = new ProjectDatasetTableAdapters.withdrawalsTableAdapter(); ProjectDatasetTableAdapters.usersTableAdapter uds = new ProjectDatasetTableAdapters.usersTableAdapter(); ProjectDataset.usersDataTable udt = new ProjectDataset.usersDataTable(); udt = uds.GetDataByusername(username); String userid = udt.Rows[0]["user_id"].ToString(); int balance = Convert.ToInt32(udt.Rows[0]["balance"].ToString()); String bankcount = uds.verifybankforwithdrawal(username, Convert.ToInt32(bankid)).ToString(); if (Convert.ToInt32(bankcount) > 0) { if (amount < 500) { lblmsg.Visible = true; lblmsg.Text = "Minimum amount to withdraw is 500 PKR"; mtop.Style["margin-top"] = "40px"; } else if (balance < amount) { lblmsg.Visible = true; lblmsg.Text = "You Don't have Enought Balance"; mtop.Style["margin-top"] = "40px"; } else { lblmsg.Visible = true; lblmsg.Text = "Withdrawal Successfully Initiated."; lblmsg.Style["background"] = "#4CAF50!important"; mtop.Style["margin-top"] = "40px"; wds.insertwithdrawal(Convert.ToInt32(userid), Convert.ToInt32(bankid), Convert.ToInt32(wamount)); uds.updatesenderbalance(Convert.ToInt32(wamount), username); } } else { lblmsg.Visible = true; lblmsg.Text = "This bank account is not yours."; mtop.Style["margin-top"] = "40px"; } } catch (Exception ex) { lblmsg.Visible = true; lblmsg.Text = ex.ToString(); mtop.Style["margin-top"] = "40px"; } }
protected void btnsend_Click(object sender, EventArgs e) { try { string username = (string)(Session["username"]); String receiver = Regex.Replace(txtreceiver.Text, @"[^\w]", ""); String amount = Regex.Replace(txtamount.Text, @"[^\w]", ""); if (receiver == "") { lblmsg.Visible = true; lblmsg.Text = "Receiver Username Must not be empty."; mtop.Style["margin-top"] = "40px"; } else if (amount == "") { lblmsg.Visible = true; lblmsg.Text = "Amount Must not be empty"; mtop.Style["margin-top"] = "40px"; } else { if (Convert.ToInt32(amount) < 100) { lblmsg.Visible = true; lblmsg.Text = "Minimum amount you can send is, RS100"; mtop.Style["margin-top"] = "40px"; } else { ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter(); String rcount = ta.checkbyusername(receiver).ToString(); if (Convert.ToInt32(rcount) == 0) { lblmsg.Visible = true; lblmsg.Text = "User is not registered"; mtop.Style["margin-top"] = "40px"; } else { ProjectDataset.usersDataTable td = new ProjectDataset.usersDataTable(); td = ta.GetDataByusername(username); String sid = td.Rows[0]["user_id"].ToString(); String sbalance = td.Rows[0]["balance"].ToString(); if (Convert.ToInt32(sbalance) < Convert.ToInt32(amount)) { lblmsg.Visible = true; lblmsg.Text = "You Do not Have Enough Balance"; mtop.Style["margin-top"] = "40px"; } else { ta.updatesenderbalance(Convert.ToInt32(amount), username); ta.updatereceiverbalance(Convert.ToInt32(amount), receiver); td = ta.GetDataByusername(receiver); string rid = td.Rows[0]["user_id"].ToString(); lblmsg.Visible = true; lblmsg.Text = "Amount successfully Transferred!"; lblmsg.Style["background"] = "#4CAF50!important"; mtop.Style["margin-top"] = "40px"; ProjectDatasetTableAdapters.transfersTableAdapter tta = new ProjectDatasetTableAdapters.transfersTableAdapter(); tta.Insert(Convert.ToInt32(sid), Convert.ToInt32(rid), Convert.ToInt32(amount), DateTime.Now); } } } } } catch (Exception ex) { lblmsg.Visible = true; lblmsg.Text = ex.ToString(); mtop.Style["margin-top"] = "40px"; } }