Пример #1
0
        private void btnlogout_Click(object sender, EventArgs e)
        {
            lastlog last = new lastlog();

            last.insertlastlog(DateTime.Now, loggingform.email);

            loggingform log = new loggingform();

            log.Show();
            this.Close();
        }
Пример #2
0
        private void log_Click(object sender, EventArgs e)
        {
            SqlConnection con = constr.getconnection();

            con.Open();

            string query = "select pwdchange,userrole from userlogins where email = @email AND password = @pwd";

            SqlCommand com = new SqlCommand(query, con);

            com.Parameters.AddWithValue("@email", txtemail.Text);
            com.Parameters.AddWithValue("@pwd", txtpassword.Text);


            DataTable dt = new DataTable();

            //SqlDataReader reader = com.ExecuteReader();
            string userrole = string.Empty;

            using (SqlDataReader Reader = com.ExecuteReader())
            {
                try
                {
                    while (Reader.Read())
                    {
                        userrole = Reader["userrole"].ToString();
                    }

                    if (userrole == "")
                    {
                        MessageBox.Show("PASSWORD OR EMAIL INCORRECTED");
                    }

                    if (userrole == "recep")
                    {
                        getinformrecep();
                        if (pwdchange.checkaccountdefaultpwdchange() == 0)
                        {
                            pwdchangeview pcv = new pwdchangeview();
                            pcv.Show();

                            return;
                        }

                        lastlog lg = new lastlog();
                        lastdateis = lg.getlastlog(txtemail.Text);


                        Form1 f = new Form1();

                        f.Show();
                    }

                    else if (userrole == "doctor")
                    {
                        getinfodoctors();
                        if (pwdchange.checkaccountdefaultpwdchange() == 0)
                        {
                            pwdchangeview pcv = new pwdchangeview();
                            pcv.Show();
                            this.Close();
                            return;
                        }

                        lastlog lg = new lastlog();
                        lastdateis = lg.getlastlog(txtemail.Text);

                        maindoc doc = new maindoc();
                        doc.Show();
                    }

                    else if (userrole == "admin")
                    {
                        getinfoadmin();

                        if (pwdchange.checkaccountdefaultpwdchange() == 0)
                        {
                            pwdchangeview pcv = new pwdchangeview();
                            pcv.Show();
                            //this.Close();
                            return;
                        }
                        AdminPanel adminf = new AdminPanel();
                        lastlog    lg     = new lastlog();
                        lastdateis = lg.getlastlog(txtemail.Text);


                        adminf.Show();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.ToString());
                }



                com.Dispose();
                con.Close();
            }



            /*
             * if (dt.Rows.Count > 0)
             * {
             *
             *  MessageBox.Show("hi");
             *  while (reader.Read())
             *  {
             *
             *      string output = reader.GetValue(0).ToString();
             *
             *  }
             *
             *
             * }*/

            /*
             * while (reader.Read())
             * {
             *  string name = reader.GetValue(0).ToString();
             *  MessageBox.Show(name);
             * }*/


            /*
             * if (dt.Rows.Count > 0)
             * {
             *  while (reader.Read())
             *  {
             *      string role = reader["userrole"].ToString();
             *      MessageBox.Show(role);
             * }
             *
             *
             * }
             *
             * else
             * {
             *
             * }
             */
        }