コード例 #1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         String username = (String)Session["username"];
         ProjectDatasetTableAdapters.usersTableAdapter ds = new ProjectDatasetTableAdapters.usersTableAdapter();
         ProjectDataset.usersDataTable dtn = new ProjectDataset.usersDataTable();
         dtn = ds.GetDataByusername(username);
         int userid = Convert.ToInt32(dtn.Rows[0]["user_id"].ToString());
         ProjectDataset.usersDataTable dt = new ProjectDataset.usersDataTable();
         dt = ds.getreceiveinfo(userid);
         if (dt.Rows.Count > 0)
         {
             tblsent.Visible    = true;
             lblmsg.Visible     = false;
             tblsent.DataSource = dt;
             tblsent.DataBind();
         }
         else
         {
             tblsent.Visible = false;
             lblmsg.Visible  = true;
             lblmsg.Text     = "You have not received any payment yet!";
         }
     }
     catch (Exception ex)
     {
         lblmsg.Visible = true;
         lblmsg.Text    = ex.ToString();
     }
 }
コード例 #2
0
 protected void btnsave_Click(object sender, EventArgs e)
 {
     try
     {
         HttpPostedFile postedFile    = avimage.PostedFile;
         string         fileName      = Path.GetFileName(postedFile.FileName);
         string         fileextention = Path.GetExtension(fileName);
         int            filesize      = postedFile.ContentLength;
         if (fileextention.ToLower() == ".jpg" || fileextention.ToLower() == ".png" || fileextention.ToLower() == ".gif")
         {
             ProjectDatasetTableAdapters.usersTableAdapter ds = new ProjectDatasetTableAdapters.usersTableAdapter();
             string       username     = (string)Session["username"];
             Stream       stream       = postedFile.InputStream;
             BinaryReader binaryreader = new BinaryReader(stream);
             byte[]       bytes        = binaryreader.ReadBytes((int)stream.Length);
             ds.updateavatar(bytes, username);
             lblmsg.Visible             = true;
             lblmsg.Text                = "Image Successfully Uploaded!";
             lblmsg.Style["background"] = "#4CAF50!important";
             mtop.Style["margin-top"]   = "40px";
         }
         else
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Only Image files are supported.";
             mtop.Style["margin-top"] = "40px";
         }
     }
     catch (Exception ex)
     {
         lblmsg.Visible           = true;
         lblmsg.Text              = ex.ToString();
         mtop.Style["margin-top"] = "40px";
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         string username = (string)(Session["username"]);
         ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter();
         string balance = ta.GetBalancebyusername(username).ToString();
         ProjectDataset.usersDataTable dt = new ProjectDataset.usersDataTable();
         dt = ta.GetDataByusername(username);
         String ubalance = dt.Rows[0]["balance"].ToString();
         String userid   = dt.Rows[0]["user_id"].ToString();
         lblbalance.InnerText = ubalance + " PKR";
         ProjectDatasetTableAdapters.transfersTableAdapter tds = new ProjectDatasetTableAdapters.transfersTableAdapter();
         String counter = tds.transactioncount(username).ToString();
         if (Convert.ToInt32(counter) > 0)
         {
             String intransfers = ta.transfercount(Convert.ToInt32(userid)).ToString();
             lbltransfers.InnerText = intransfers + " PKR";
         }
         ProjectDatasetTableAdapters.withdrawalsTableAdapter wds = new ProjectDatasetTableAdapters.withdrawalsTableAdapter();
         String wcounter = wds.withdrawalcount(username).ToString();
         if (Convert.ToInt32(wcounter) > 0)
         {
             String twithdrawals = wds.totalwithdrawals(username).ToString();
             lblwithdrawals.InnerText = twithdrawals + " PKR";
         }
     }
     catch (Exception Ex)
     {
         Response.Write(Ex.ToString());
     }
 }
コード例 #4
0
 protected void btnlogin_Click(object sender, EventArgs e)
 {
     try
     {
         string username = Regex.Replace(txtusername.Text, @"[^\w]", "");
         string password = Regex.Replace(txtpassword.Text, @"[^\w]", "");
         if (username == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Username must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (password == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Password must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else
         {
             ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter();
             string ucheck = ta.checkbyusername(username).ToString();
             string pcheck = ta.passwordcheck(username, password).ToString();
             if (Convert.ToInt32(ucheck) == 0)
             {
                 lblmsg.Visible           = true;
                 lblmsg.Text              = "Username doesn't Exist.";
                 mtop.Style["margin-top"] = "40px";
             }
             else if (Convert.ToInt32(pcheck) == 0)
             {
                 lblmsg.Visible           = true;
                 lblmsg.Text              = "Username/Password Is incorrect.";
                 mtop.Style["margin-top"] = "40px";
             }
             else if (username == "admin")
             {
                 Session["username"]  = username;
                 Session["logintype"] = "admin";
                 Response.Redirect("dashboard.aspx");
             }
             else
             {
                 Session["username"]  = username;
                 Session["logintype"] = "user";
                 Response.Redirect("dashboard.aspx");
             }
         }
     }
     catch (Exception ex)
     {
         lblmsg.Visible           = true;
         lblmsg.Text              = ex.ToString();
         mtop.Style["margin-top"] = "40px";
     }
 }
 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 Loadbanks()
        {
            String username = (String)Session["username"];

            ProjectDatasetTableAdapters.usersTableAdapter uds = new ProjectDatasetTableAdapters.usersTableAdapter();
            ProjectDataset.usersDataTable uta = new ProjectDataset.usersDataTable();
            uta = uds.getuserbankaccounts(username);
            dropdownbank.DataSource     = uta;
            dropdownbank.DataTextField  = "bankdetails";
            dropdownbank.DataValueField = "bankid";
            dropdownbank.DataBind();
            dropdownbank.Items.Insert(0, new ListItem("Please Select Bank Account", "-1"));
        }
        public string Loadchart(int month)
        {
            ProjectDatasetTableAdapters.usersTableAdapter ds = new ProjectDatasetTableAdapters.usersTableAdapter();
            string username = (string)Session["username"];

            if (ds.chartvalue(username, month) != null)
            {
                string chartv = ds.chartvalue(username, month).ToString();
                return(chartv);
            }
            else
            {
                return("0");
            }
        }
 protected void btnsend_Click(object sender, EventArgs e)
 {
     try
     {
         string username  = (string)(Session["username"]);
         String bankname  = txtbankname.Text.ToString();
         String accountno = txtbankaccount.Text.ToString();
         if (bankname == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Bank Name Must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (accountno == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Account Number Must not be empty";
             mtop.Style["margin-top"] = "40px";
         }
         else
         {
             ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter();
             ProjectDataset.usersDataTable td = new ProjectDataset.usersDataTable();
             td = ta.GetDataByusername(username);
             String uid = td.Rows[0]["user_id"].ToString();
             lblmsg.Visible             = true;
             lblmsg.Text                = "Bank Added Successfully!";
             lblmsg.Style["background"] = "#4CAF50!important";
             mtop.Style["margin-top"]   = "40px";
             ProjectDatasetTableAdapters.user_banksTableAdapter bds = new ProjectDatasetTableAdapters.user_banksTableAdapter();
             bds.Insert(Convert.ToInt32(uid), bankname, accountno);
         }
     }
     catch (Exception ex)
     {
         lblmsg.Visible           = true;
         lblmsg.Text              = ex.ToString();
         mtop.Style["margin-top"] = "40px";
     }
 }
        public void Loadavatar()
        {
            ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter();
            ProjectDataset.usersDataTable dt = new ProjectDataset.usersDataTable();
            string username = (string)Session["username"];

            dt = ta.getavatarbyusername(username);
            if ((dt.Rows[0]["user_avatar"] as byte[]) != null)
            {
                byte[] bytes = (byte[])dt.Rows[0]["user_avatar"];
                String bse64 = Convert.ToBase64String(bytes);
                //avatar.ImageUrl = "data:Image/png;base64," + bse64;
                //avatar1.ImageUrl = "data:Image/png;base64," + bse64;
                avatar.ImageUrl  = "assets/img/avatar.png";
                avatar1.ImageUrl = "assets/img/avatar.png";
            }
            else
            {
                avatar.ImageUrl  = "assets/img/avatar.png";
                avatar1.ImageUrl = "assets/img/avatar.png";
            }
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (Session["username"] == null)
         {
             Response.Redirect("login.aspx");
         }
         else
         {
             Loadavatar();
             ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter();
             ProjectDataset.usersDataTable dt = new ProjectDataset.usersDataTable();
             string username = (string)Session["username"];
             dt = ta.GetDataByusername(username);
             lblname.InnerText = dt.Rows[0]["fullname"].ToString();
         }
     }
     catch (Exception ex)
     {
         Response.Write(ex.ToString());
     }
 }
        protected void btnsend_Click(object sender, EventArgs e)
        {
            String username = (String)Session["username"];
            String Name     = txtname.Text.ToString();
            String pass     = txtpassword.Text.ToString();

            ProjectDatasetTableAdapters.usersTableAdapter ds = new ProjectDatasetTableAdapters.usersTableAdapter();
            String count = ds.passwordcheck(username, pass).ToString();

            if (Convert.ToInt32(count) > 0)
            {
                ds.updatefullname(Name, username);
                lblmsg.Visible             = true;
                lblmsg.Style["background"] = "#4CAF50!important";
                lblmsg.Text = "Name Successfully Changed";
                mtop.Style["margin-top"] = "40px";
            }
            else
            {
                lblmsg.Visible           = true;
                lblmsg.Text              = "Password Is Incorrect";
                mtop.Style["margin-top"] = "40px";
            }
        }
 protected void btnregister_Click(object sender, EventArgs e)
 {
     try
     {
         string username        = Regex.Replace(txtusername.Text, @"[^\w]", "");
         string fullname        = Regex.Replace(txtfullname.Text, @"[^\w]", "");
         string email           = txtemail.Text.ToString();
         string password        = Regex.Replace(txtpassword.Text, @"[^\w]", "");
         string password_repeat = Regex.Replace(txtrepeatpassword.Text, @"[^\w]", "");
         string mobileno        = Regex.Replace(txtmobile.Text, @"[^\w]", "");
         if (username == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Username must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (fullname == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Real name must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (email == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Email must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (password == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Password must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (password_repeat == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Password Repeat Feild must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (mobileno == "")
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Mobile no must not be empty.";
             mtop.Style["margin-top"] = "40px";
         }
         else if (password != password_repeat)
         {
             lblmsg.Visible           = true;
             lblmsg.Text              = "Passwords Donot Match.";
             mtop.Style["margin-top"] = "40px";
         }
         else
         {
             ProjectDatasetTableAdapters.usersTableAdapter ta = new ProjectDatasetTableAdapters.usersTableAdapter();
             string ucount = ta.checkbyusername(username).ToString();
             string ecount = ta.checkbyemail(email).ToString();
             if (Convert.ToInt32(ucount) > 0)
             {
                 lblmsg.Visible           = true;
                 lblmsg.Text              = "Username Already Exists";
                 mtop.Style["margin-top"] = "40px";
             }
             else if (Convert.ToInt32(ecount) > 0)
             {
                 lblmsg.Visible           = true;
                 lblmsg.Text              = "Email Already Exists";
                 mtop.Style["margin-top"] = "40px";
             }
             else
             {
                 ta.InsertQuery(username, email, password, fullname);
                 lblmsg.Visible             = true;
                 lblmsg.Text                = "You are Registered Successfully!";
                 lblmsg.Style["background"] = "#4CAF50!important";
                 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";
            }
        }