Esempio n. 1
0
 private void LoadStart()
 {
     try
     {
         string query = "Select * from expense_tbl";
         DatabaseConnect db = new DatabaseConnect();
         DataTable values = db.data(query);
         dataGridView1.DataSource = values;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 2
0
        private void btnsave_Click(object sender, EventArgs e)
        {
            try
            {
                expenses ep = new expenses();
                ep.title = comboBox1.Text;
                ep.money = txtmoney.Text;
                ep.date = DateTime.Now;
                ep.description = rchdescription.Text;

                chart1 cc = new chart1();
                cc.title = comboBox1.Text;
                cc.total = txtmoney.Text;

                if (errorTest.PresenceOfTitle(comboBox1.Text))
                {
                    MessageBox.Show("Sorry need a title of expenses");
                    return;
                }
                if (errorTest.PresenceOfmoney(txtmoney.Text))
                {
                    MessageBox.Show("Sorry you need to insert the amount you've spent");
                    return;
                }

                String query1 = "Insert into expense_tbl values('" + ep.title + "','" + ep.money + "','" + ep.date + "','" + ep.description + "')";
                DatabaseConnect db = new DatabaseConnect();
                db.Executequery(query1);

                String query2 = "Insert into chart_tbl values('" + cc.title + "','" + cc.total + "')";
                DatabaseConnect dt = new DatabaseConnect();
                dt.Executequery(query2);

                MessageBox.Show(" Expense successfully registered");
                comboBox1.Text = "";
                txtmoney.Text = "";
                rchdescription.Text = "";

            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Esempio n. 3
0
 private void btnregister_Click(object sender, EventArgs e)
 {
     try
     {
         register r = new register();
         r.FirstName = txtfirstname.Text;
         r.LastName  = txtlastname.Text;
         r.Username  = txtusername.Text;
         r.Password  = txtpassword.Text;
         r.Hint      = txthint.Text;
         string command = "insert into register_tbl (Firstname,Lastname,Username,Password,Hint) values ('" + r.FirstName + "','" + r.LastName + "'," +
                          "" + "'" + r.Username + "','" + r.Password + "','" + r.Hint + "')";
         DatabaseConnect dc = new DatabaseConnect();
         dc.Executequery(command);
         MessageBox.Show("Your account has been registered");
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Esempio n. 4
0
 public static bool CheckDuplicateUsername(string Username)
 {
     try
     {
         string          query  = "select * from register_tbl where Username='******'";
         DatabaseConnect dc     = new DatabaseConnect();
         DataTable       deuser = dc.data(query);
         if (deuser.Rows.Count > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 5
0
 private void btnsearch_Click(object sender, EventArgs e)
 {
     try
     {
         if (txtsearch.Text == null)
         {
             MessageBox.Show("Enter a word to search Thank You!!!");
         }
         else
         {
             string          query = "Select * from expense_tbl where  title like'" + txtsearch.Text + "%'or description like'" + txtsearch.Text + "%' ";
             DatabaseConnect db    = new DatabaseConnect();
             DataTable       dt    = db.data(query);
             dataGridView1.DataSource = dt;
             txtsearch.Text           = "";
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }