Пример #1
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            SqlConnection con = DataBaseManager.GetConnector(); //new SqlConnection(@"Data Source=JOJO;Initial Catalog=LMS;Integrated Security=True");
                                                                //con.Open();


            SqlDataAdapter ada = new SqlDataAdapter("Select * from Login_Details where   username= '******' and password='******' ", con);//and usertype='"+ComboBox1.SelectedValue.ToString()+"'",con);

            DataTable dt = new DataTable();

            ada.Fill(dt);

            if (dt.Rows.Count == 1)
            {
                CurrentUser.Employee = DataBaseManager.GetCurrentUser(txtuser.Text);
                DataTable employeeData = DataBaseManager.GetEmployeeDataTable();
                CurrentUser.SetDetails(employeeData);

                Session["Login_Details"] = UniqueID;
                if (CurrentUser.Employee.Usertype == "Admin")//ComboBox1.SelectedIndex==0
                {
                    Response.Redirect("~/Admin/admin_home.aspx");
                }
                else
                {
                    Response.Redirect("~/Users/user_home.aspx");
                }
            }
            else
            {
                lblerror.Visible = true;
            }
            //con.Close();
        }
Пример #2
0
        private Employee FindEmployeeWithUsername(string username)
        {
            SqlCommand command = new SqlCommand("Select Email From empDetails Where username = @username", DataBaseManager.GetConnector());

            command.Parameters.AddWithValue("@username", username);
            SqlDataReader reader = command.ExecuteReader();

            if (reader.Read())
            {
                Employee emp = new Employee {
                    Email = reader["Email"].ToString()
                };
                reader.Close();
                return(emp);
            }
            else
            {
                reader.Close();
                return(null);
            }
        }