Example #1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (textBox1.Text == "Matan" && textBox2.Text == "123456")
     {
         ManagerCalander frmCal = new ManagerCalander();
         frmCal.Show();
         Visible = false;
     }
     else if (textBox1.Text == "Tom" && textBox2.Text == "123456")
     {
         TeacherCalander frmCal = new TeacherCalander();
         frmCal.Show();
         Visible = false;
     }
     else if (textBox1.Text == "Aviran" && textBox2.Text == "123456")
     {
         StudentCalander frmCal = new StudentCalander();
         frmCal.Show();
         Visible = false;
     }
     else if (textBox1.Text == "Amir" && textBox2.Text == "123456")
     {
         StudentCalander frmCal = new StudentCalander();
         frmCal.Show();
         Visible = false;
     }
     else
     {
         MessageBox.Show("Worng password");
     }
 }
Example #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                dataBase       dataBase = new dataBase();
                SqlConnection  con      = dataBase.connect_to_scheduluz_DB();
                string         query    = "Select permission from connection_details Where userName = '******' and Password = '******'";
                SqlDataAdapter sda      = new SqlDataAdapter(query, con);
                DataTable      dtbl     = new DataTable();
                sda.Fill(dtbl);

                SqlConnection  con2   = dataBase.connect_to_scheduluz_DB();
                string         query2 = "Select id from connection_details Where userName = '******' and Password = '******'";
                SqlDataAdapter sda2   = new SqlDataAdapter(query2, con2);
                DataTable      dtb2   = new DataTable();
                sda2.Fill(dtb2);

                /*creating text file for later use.
                 * for permission only
                 * M for manager
                 * T for teacher
                 * S for student
                 */
                //       StreamWriter perFile = new StreamWriter("permissionFile.txt");
                //       StreamWriter userFile = new StreamWriter("userFile.txt");



                if (dtbl.Rows.Count > 0)
                {
                    /*
                     * the next code part is storing the user permission for later use
                     */
                    User user = new User();
                    user.insertID(dtb2.Rows[0][0].ToString().Trim());
                    user.insertPermission(dtbl.Rows[0][0].ToString().Trim());
                    user.insertUsername(textBox1.Text.Trim());
                    user.insertPassword(textBox2.Text.Trim());
                    userId = user.getID();

                    permission = user.getPermission();

                    if (user.getPassword() != user.getID())
                    {
                        string per = user.getPermission();

                        if (per == "manager")
                        {
                            ManagerCalander Mc = new ManagerCalander();
                            this.Hide();
                            // perFile.Write("M");
                            loginUserName = textBox1.Text;
                            insert_logins_report();

                            //perFile.Close();
                            Mc.Show();
                        }
                        if (per == "teacher")
                        {
                            TeacherCalander Tc = new TeacherCalander();
                            this.Hide();
                            //           perFile.Write("T");
                            loginUserName = textBox1.Text;
                            insert_logins_report();
                            //perFile.Close();
                            Tc.Show();
                        }
                        if (per == "student")
                        {
                            StudentCalander Sc = new StudentCalander();
                            this.Hide();
                            //           perFile.Write("S");
                            loginUserName = textBox1.Text;
                            insert_logins_report();
                            //           perFile.Close();
                            Sc.Show();
                        }

                        /* userFile.WriteLine(user.getID());
                         * userFile.WriteLine(user.getPassword());
                         * userFile.WriteLine(user.getPermission());
                         * userFile.WriteLine("username: "******"username: "******"Invalid username or password.");
                    //    perFile.Close();
                    //    userFile.Close();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Connection problem detected. please contact your ScheduLuz guide with this code:" + ex.GetType().ToString());
            }
        }