Ejemplo n.º 1
0
        private void btnFtp_Click(object sender, EventArgs e)
        {
            ftptext.Text = "Please wait while uploading your data";



            Thread backgroundThread = new Thread(new ThreadStart(() =>
            {
                DBAccessClass db = new DBAccessClass();

                db.openConnection();

                DataTable dt = db.getExpensesOfAll();


                pathtodownload = Path.GetTempPath();
                pathtodownload = pathtodownload + "ftp-";
                Console.WriteLine(pathtodownload);
                dt.WriteToCsvFile(pathtodownload + "admin.csv");
                string ufilename = pathtodownload + "admin.csv";
                db.closeConnection();



                Upload("ftp://" + ftpserver, "dvta", "p@ssw0rd", @pathtodownload + "admin.csv");
                Console.WriteLine(@pathtodownload + "admin.csv");
            }));

            backgroundThread.Start();
        }
Ejemplo n.º 2
0
        private void btnClear_Click(object sender, EventArgs e)
        {
            DialogResult dialog = MessageBox.Show("Do you want to clear all your expenses?", "Caution", MessageBoxButtons.YesNo);

            if (dialog == DialogResult.Yes)
            {
                DBAccessClass db = new DBAccessClass();
                db.openConnection();

                Microsoft.Win32.RegistryKey key;
                key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("dvta");

                String email = (string)key.GetValue("email", "null");

                if (db.clearExpenses(email))
                {
                    MessageBox.Show("Success");
                }
                else
                {
                    MessageBox.Show("Failed");
                }

                db.closeConnection();
            }

            else
            {
                Console.WriteLine("User chose not to clear the expenses");
            }
        }
Ejemplo n.º 3
0
        private void btnFtp_Click(object sender, EventArgs e)
        {
            ftptext.Text = "Please wait while uploading your data";

            Thread backgroundThread = new Thread(new ThreadStart(() =>
            {
                DBAccessClass db = new DBAccessClass();

                db.openConnection();

                DataTable dt = db.getExpensesOfAll();

                //pathtodownload = Environment.GetEnvironmentVariable("USERPROFILE") + @"\" + "Downloads";
                pathtodownload = Path.GetTempPath();


                dt.WriteToCsvFile(pathtodownload + "admin.csv");

                db.closeConnection();

                Upload("ftp://192.168.56.110", "dvta", "p@ssw0rd", @pathtodownload + "admin.csv");

                //cleaning up - Delete files in temp folder

                try
                {
                    System.IO.Directory.Delete(@pathtodownload, true);
                }
                catch (Exception exp) {
                    Console.WriteLine(exp);
                }
            }));

            backgroundThread.Start();
        }
Ejemplo n.º 4
0
        private void btnView_Click(object sender, EventArgs e)
        {
            DBAccessClass db = new DBAccessClass();

            db.openConnection();

            Microsoft.Win32.RegistryKey key;
            key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("dvta");

            String email = (string)key.GetValue("email", "null");

            returnvalue = db.viewExpenses(email);

            dataGridView1.DataSource = returnvalue;

            db.closeConnection();
        }
Ejemplo n.º 5
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Microsoft.Win32.RegistryKey key;
            key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("dvta");

            String email = (string)key.GetValue("email", "null");

            String   dat   = textDate.Text.Trim();
            String   item  = textItem.Text.Trim();
            String   price = textPrice.Text.Trim();
            DateTime now   = DateTime.Now;
            String   time  = now.ToString("T");

            if (dat == string.Empty || item == string.Empty || price == string.Empty || email == string.Empty || time == string.Empty)
            {
                MessageBox.Show("Please enter all the fields!");
                return;
            }
            else
            {
                DBAccessClass db = new DBAccessClass();

                db.openConnection();

                //Read system time and insert it into the database

                if (db.addExpenses(dat, item, price, email, time))
                {
                    textDate.Text  = "";
                    textItem.Text  = "";
                    textPrice.Text = "";
                    time           = "";

                    MessageBox.Show("Data saved succesfully");
                }
                else
                {
                    MessageBox.Show("Failed");
                }

                db.closeConnection();
            }
        }
        private void btnReg_Click(object sender, EventArgs e)
        {
            String username        = txtRegUsername.Text.Trim();
            String password        = txtRegPass.Text.Trim();
            String confirmpassword = txtRegCfmPass.Text.Trim();
            String email           = txtRegEmail.Text.Trim();

            if (username == string.Empty || password == string.Empty || confirmpassword == string.Empty || email == string.Empty)
            {
                MessageBox.Show("Please enter all the fields!");
                return;
            }
            else
            {
                if (password != confirmpassword)
                {
                    MessageBox.Show("Passwords do not match");
                    return;
                }
                else
                {
                    DBAccessClass db = new DBAccessClass();

                    db.openConnection();

                    if (db.RegisterUser(username, password, email))
                    {
                        txtRegUsername.Text = "";
                        txtRegPass.Text     = "";
                        txtRegCfmPass.Text  = "";
                        txtRegEmail.Text    = "";
                        MessageBox.Show("Registration Success");
                    }
                    else
                    {
                        MessageBox.Show("Registration Failed");
                    }

                    db.closeConnection();
                }
            }
        }
Ejemplo n.º 7
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            String username = txtLgnUsername.Text.Trim();
            String password = txtLgnPass.Text.Trim();

            if (username == string.Empty || password == string.Empty)
            {
                MessageBox.Show("Please enter all the fields!");
                return;
            }

            DBAccessClass db = new DBAccessClass();

            db.openConnection();

            SqlDataReader data = db.checkLogin(username, password);

            if (data.HasRows)
            {
                String user;
                String pass;
                String email;
                int    isadmin = 0;

                /* Microsoft.Win32.RegistryKey myRegKey = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Details");
                 * String uname = (String)myRegKey.GetValue("username", null);
                 * String pass = (String)myRegKey.GetValue("password", null);*/

                while (data.Read())
                {
                    user    = data.GetString(1);
                    pass    = data.GetString(2);
                    email   = data.GetString(3);
                    isadmin = (int)data.GetValue(4);

                    if (user != "admin")
                    {
                        Microsoft.Win32.RegistryKey key;
                        key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("dvta");
                        key.SetValue("username", user);
                        key.SetValue("password", pass);
                        key.SetValue("email", email);
                        key.SetValue("isLoggedIn", "true");
                        key.Close();
                    }
                }
                txtLgnUsername.Text = "";
                txtLgnPass.Text     = "";

                //redirecting to main screen

                if (isadmin != 1)
                {
                    this.Close();
                    Main main = new Main();
                    main.ShowDialog();
                    Application.Exit();
                }
                else
                {
                    this.Hide();
                    Admin admin = new Admin();
                    admin.ShowDialog();
                    Application.Exit();
                }

                return;
            }
            else
            {
                MessageBox.Show("Invalid Login");
                txtLgnUsername.Text = "";
                txtLgnPass.Text     = "";
            }
            db.closeConnection();
        }