Esempio n. 1
0
        public DataTable select()
        {
            ConnClass     cDL    = new ConnClass();
            SqlConnection connDL = new SqlConnection(cDL.Datalogconnection);
            DataTable     dtDL   = new DataTable();

            try
            {
                string         query   = "SELECT* FROM Logs";
                SqlCommand     cmdDL   = new SqlCommand(query, connDL);
                SqlDataAdapter adapter = new SqlDataAdapter(cmdDL);
                connDL.Open();
                adapter.Fill(dtDL);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error While Loading!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //MetroMessageBox.Show(ex.Message, Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            finally
            {
                connDL.Close();
            }
            return(dtDL);
        }
Esempio n. 2
0
        public bool Check(UserBLL u)
        {
            bool          isunique = false;
            ConnClass     c        = new ConnClass();
            SqlConnection conn     = new SqlConnection(c.Appconnection);

            try
            {
                string         query       = "Select * From tbl_user where email='" + u.username + "' OR username='******'";
                SqlCommand     cmd         = new SqlCommand(query, conn);
                SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
                conn.Open();
                dataAdapter.Fill(dataSet);
                int i = dataSet.Tables[0].Rows.Count;
                if (i > 0)
                {
                    isunique = true;
                }
                else
                {
                    isunique = false;
                }
            }
            catch (Exception)
            {
                isunique = false;
                return(isunique);
            }
            finally
            {
                conn.Close();
            }
            return(isunique);
        }
Esempio n. 3
0
        public bool delete(UserBLL u)
        {
            bool          issucess = false;
            ConnClass     c        = new ConnClass();
            SqlConnection conn     = new SqlConnection(c.Appconnection);

            try
            {
                string     query = "DELETE FROM tbl_user WHERE id=@id";
                SqlCommand cmd   = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@id", u.id);
                conn.Open();
                int row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    issucess = true;
                }
                else
                {
                    issucess = false;
                }
            }

            catch (Exception)
            {
                issucess = false;
                return(issucess);
            }
            finally
            {
                conn.Close();
            }

            return(issucess);
        }
Esempio n. 4
0
        public bool update(UserBLL u)
        {
            bool          issucess = false;
            ConnClass     c        = new ConnClass();
            SqlConnection conn     = new SqlConnection(c.Appconnection);

            try
            {
                string     query = "UPDATE tbl_user set email=@email,username=@username,password=@password WHERE id=@id";
                SqlCommand cmd   = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@email", u.email);
                cmd.Parameters.AddWithValue("@username", u.username);
                cmd.Parameters.AddWithValue("@password", u.password);
                cmd.Parameters.AddWithValue("@id", u.id);
                conn.Open();
                int row = cmd.ExecuteNonQuery();
                if (row > 0)
                {
                    issucess = true;
                }
                else
                {
                    issucess = false;
                }
            }

            catch (Exception)
            {
                issucess = false;
                return(issucess);
            }
            finally
            {
                conn.Close();
            }

            return(issucess);
        }
Esempio n. 5
0
        public DataTable Search(string keyword)
        {
            ConnClass     c    = new ConnClass();
            SqlConnection conn = new SqlConnection(c.Datalogconnection);
            DataTable     dt   = new DataTable();

            try
            {
                string         query   = "SELECT* FROM  Logs WHERE id Like '%" + keyword + "%' OR Level like '%" + keyword + "%' OR Type like '%" + keyword + "%'";
                SqlCommand     cmd     = new SqlCommand(query, conn);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                conn.Open();
                adapter.Fill(dt);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }
            return(dt);
        }
Esempio n. 6
0
        public bool login(LoginBLL u)
        {
            bool          issuccess = false;
            ConnClass     c         = new ConnClass();
            SqlConnection conn      = new SqlConnection(c.Appconnection);

            try
            {
                string     query = "select * from tbl_user where username=@username AND password=@password";
                SqlCommand cmd   = new SqlCommand(query, conn);
                cmd.Parameters.AddWithValue("@username", u.username);
                cmd.Parameters.AddWithValue("@password", u.password);
                SqlDataAdapter adapter = new SqlDataAdapter(cmd);
                DataTable      dt      = new DataTable();
                conn.Open();
                adapter.Fill(dt);
                if (dt.Rows.Count > 0)
                {
                    issuccess = true;
                }
                else
                {
                    issuccess = false;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            finally
            {
                conn.Close();
            }

            return(issuccess);
        }