Esempio n. 1
0
        private void Button3_Click_1(object sender, EventArgs e)
        {
            frmMenu form = new frmMenu();

            form.Show();
        }
Esempio n. 2
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            SqlConnection  sqlcon = new SqlConnection(@"Data Source=NOTE-ASUS\SQLEXPRESS;Initial Catalog=PBCS;User ID=josivan;Password=josivan");
            string         query  = "Select * from PBCS.Users where UserName = '******' and UserPassword = '******'";
            SqlDataAdapter sda    = new SqlDataAdapter(query, sqlcon);

            DataTable dtbl = new DataTable();

            sda.Fill(dtbl);

            if (txtUserLogin.Text == string.Empty)
            {
                MessageBox.Show("Please, type your name!", "PBCS - System message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (txtPasswordLogin.Text == string.Empty)
            {
                MessageBox.Show("Please, type your password!", "PBSC - System message", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            if (dtbl.Rows.Count == 1)
            {
                MessageBox.Show("Welcome " + txtUserLogin.Text + " you are loged", "PBSC - System message", MessageBoxButtons.OK, MessageBoxIcon.Information);

                uType = dtbl.Rows[0][4].ToString();

                frmMenu objFrmMenu = new frmMenu();
                objFrmMenu.txtLogedUSer.Text = txtUserLogin.Text;
                objFrmMenu.txtUserType.Text  = uType;

                this.Hide();
                objFrmMenu.Show();

                //++++++++++++ BEGIN OF LOG MODULE +++++++++++++++++++++++++++++++++++
                try
                {
                    FileStream   aFile = new FileStream(@"C:\Users\Admin2\OneDrive\2019 - IBT COLLEGE\01-Subjects\D_\BudgetControl\Log\LogLogin.txt", FileMode.Append);
                    StreamWriter sw    = new StreamWriter(aFile);

                    string user = txtUserLogin.Text;

                    sw.WriteLine("Date: {0} - User: {1}", DateTime.Now.ToUniversalTime(), user);
                    sw.Close();
                }
                catch (IOException ioMessage)
                {
                    Console.WriteLine("An IO exception has been thrown!");
                    Console.WriteLine(ioMessage.ToString());
                    Console.ReadLine(); return;
                }

                //++++++++++++ END OF LOG MODULE +++++++++++++++++++++++++++++++++++
            }

            else
            {
                MessageBox.Show("Check user name and password!", "PBCS - System message", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                return;
            }
        }