Advertisement
Guest User

Untitled

a guest
May 29th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 5.47 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.Data.OleDb;
  10. using System.IO;
  11.  
  12. namespace Descartes
  13. {
  14.     public partial class frmAccount : Form
  15.     {
  16.         public frmAccount()
  17.         {
  18.             InitializeComponent();
  19.         }
  20.  
  21.         int Admin = 0;
  22.         /*OleDbConnection banking;
  23.         OleDbCommand accountCommand;
  24.         OleDbDataAdapter accountAdapter;
  25.         DataTable accountTable;
  26.         OleDbCommand itemsCommand;
  27.         OleDbDataAdapter itemsAdapter;
  28.         DataTable itemsTable;
  29.         OleDbCommand purchasesCommand;
  30.         OleDbDataAdapter purchasesAdapter;
  31.         DataTable purchasesTable;*/
  32.  
  33.         OleDbConnection con;
  34.         DataSet ds1;
  35.         DataSet ds2;
  36.         DataSet ds3;
  37.         OleDbDataAdapter da;
  38.         OleDbDataAdapter da2;
  39.         OleDbDataAdapter da3;
  40.         int MaxRows = 0;
  41.         int inc = 0;
  42.         string User = "";
  43.  
  44.         private void exitToolStripMenuItem_Click(object sender, EventArgs e)
  45.         {
  46.             Application.Exit();
  47.         }
  48.  
  49.         private void mainMenuToolStripMenuItem3_Click(object sender, EventArgs e)
  50.         {
  51.             // Goes to the Main Menu Page
  52.  
  53.             frmMainMenu frm = new frmMainMenu();
  54.             frm.Show();
  55.             this.Hide();
  56.         }
  57.  
  58.         private void catalogueToolStripMenuItem3_Click(object sender, EventArgs e)
  59.         {
  60.             // Goes to the Catalogue Page
  61.  
  62.             frmCatalogue frm = new frmCatalogue();
  63.             frm.Show();
  64.             this.Hide();
  65.         }
  66.  
  67.         private void tmrFadeIn_Tick(object sender, EventArgs e)
  68.         {
  69.             //Fades the page in
  70.  
  71.             this.Opacity += 0.02;
  72.         }
  73.  
  74.         private void tmrWait_Tick(object sender, EventArgs e)
  75.         {
  76.             //Stops the fade in function
  77.  
  78.             tmrFadeIn.Enabled = false;
  79.         }
  80.  
  81.         private void btnMainMenu_Click(object sender, EventArgs e)
  82.         {
  83.             // Goes to the Main Menu Page
  84.  
  85.             frmMainMenu frm = new frmMainMenu();
  86.             frm.Show();
  87.             this.Hide();
  88.         }
  89.  
  90.         private void topupBalanceToolStripMenuItem3_Click(object sender, EventArgs e)
  91.         {
  92.             // Goes to the Top-up Page
  93.  
  94.             frmTop frm = new frmTop();
  95.             frm.Show();
  96.             this.Hide();
  97.         }
  98.  
  99.         private void logoutToolStripMenuItem3_Click(object sender, EventArgs e)
  100.         {
  101.             // Goes to the Login Page
  102.  
  103.             frmLogin frm = new frmLogin();
  104.             frm.Show();
  105.             this.Hide();
  106.         }
  107.  
  108.         private void frmAccount_Load(object sender, EventArgs e)
  109.         {
  110.             string file_name = "user.ini";
  111.  
  112.             System.IO.StreamReader objReader;
  113.             objReader = new System.IO.StreamReader(file_name);    //Reads the text file and saves it as a variable
  114.             User = objReader.ReadLine().ToString();
  115.  
  116.             objReader.Close();
  117.  
  118.             con = new OleDbConnection();
  119.             ds1 = new DataSet();
  120.             ds2 = new DataSet();
  121.             ds3 = new DataSet();
  122.  
  123.             con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source = " + Application.StartupPath + "\\..\\..\\banking.mdb"; //connection to database
  124.             con.Open();
  125.  
  126.             string sql = "SELECT * From account"; //select everything from the account table
  127.             da = new OleDbDataAdapter(sql, con);
  128.             da.Fill(ds1, "UserList"); //creates a virtual database in memory called Userlist
  129.             MaxRows = ds1.Tables["UserList"].Rows.Count;
  130.  
  131.             string sql2 = "SELECT * From items"; //select everything from the account table
  132.             da2 = new OleDbDataAdapter(sql2, con);
  133.             da.Fill(ds2, "ItemList"); //creates a virtual database in memory called Userlist
  134.             MaxRows = ds2.Tables["ItemList"].Rows.Count;
  135.  
  136.             string sql3 = "SELECT * From purchases"; //select everything from the account table
  137.             da3 = new OleDbDataAdapter(sql3, con);
  138.             da.Fill(ds3, "PurchaseList"); //creates a virtual database in memory called Userlist
  139.             MaxRows = ds3.Tables["PurchaseList"].Rows.Count;
  140.  
  141.             string Balance;
  142.             int User_int;
  143.             int user;
  144.             User_int = Convert.ToInt32(User);
  145.             user = User_int - 2;
  146.             DataRow dRow = ds1.Tables["UserList"].Rows[user];
  147.             Balance = dRow.ItemArray.GetValue(3).ToString();     //Balance has been found
  148.  
  149.             label3.Text = Balance + ".00";
  150.  
  151.             con.Close();
  152.             con.Dispose();
  153.         }
  154.  
  155.         private void helpToolStripMenuItem_Click(object sender, EventArgs e)
  156.         {
  157.             MessageBox.Show("The account information page acts as a portal for each user to check their statistics in relation to Descartes. Your account balance total will show up in the top left box, the total amount of money you have spent purchasing items on Descartes shows up on the bottom left box and a compiled list of all goods you have purchased from Descartes will show up in the box on the right. If you wish to go directly to the Top-up page, simply click the Top-up Balance button – if not, you may go back to the Main Menu using the Back button.", "Catalogue Help");
  158.         }
  159.  
  160.         private void btnTopUp_Click(object sender, EventArgs e)
  161.         {
  162.  
  163.         }
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement