Пример #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string name = Request.Form["name"];
            string email = Request.Form["email"];
            string address = Request.Form["address"];
            int cpf = Convert.ToInt32(Request.Form["cpf"]);

            string username = Request.Form["username"];
            string password = Request.Form["password"];

            if (Page.IsPostBack)
            {
                clDataAccess insert = new clDataAccess();

                clUsers validate = new clUsers();

                //VERIFICA SE JA EXISTE O USERNAME
                if (!validate.containsUser(username) && name != "" && address != "" && cpf.ToString() != "" && email != "" && username != "" && password != "")
                {
                    insert.Registeruser(name, address, cpf, email, username, password);
                    Response.Redirect("Login.aspx");
                }

            }
        }
Пример #2
0
 public void VerifyPermission(string Login)
 {
     clDataAccess ReturnData = new clDataAccess();
     SqlDataReader retorno = ReturnData.ReturnDataset("select codRoles,codUser  from TB_Users where login = '******'");
     while (retorno.Read())
     {
         codRoles = Convert.ToInt32(retorno["codRoles"]);
         codUser = Convert.ToInt32(retorno["codUser"]);
     }
 }
Пример #3
0
        public bool VerifyPermission(int IdRole, int IdPermissions)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader retorno = ReturnData.ReturnDataset("select codRolePermission from TB_RolePermission where " + IdRole + " = codRoles and " + IdPermissions + " =  codPermission");

            if (retorno.HasRows == false)
            {
                return false;

            }
            else
            {
                return true;
            }
        }
Пример #4
0
 public List<clCategory> ReturnCategory()
 {
     clDataAccess Return = new clDataAccess();
     SqlDataReader ReturnData = Return.ReturnDataset("select codCategory,Name  from TB_Category ");
     DataTable dt = new DataTable();
     dt.Load(ReturnData);
     List<clCategory> categories = new List<clCategory>(dt.Rows.Count);
     foreach (DataRow row in dt.Rows)
     {
         categories.Add(new clCategory
         {
             Name = row["Name"].ToString(),
             podSubCategory = int.Parse(row["podSubCategory"].ToString())
         });
     }
     return categories;
 }
Пример #5
0
 public void Insertsubcategory(int codSubCategory, string Name, int codCategory)
 {
     clDataAccess InsertData = new clDataAccess();
     SqlDataReader Insert = InsertData.ReturnDataset("insert into TB_Category (codSubCategory,Name, codCategory) values ( " + codSubCategory + ",'" + Name + "'," + codCategory + ")");
 }
Пример #6
0
 //Marka 1 problema como Resolvido
 public void MarkSolved(int codProblem)
 {
     clDataAccess ReturnData = new clDataAccess();
     SqlDataReader Mark = ReturnData.ReturnDataset("Update TB_Problem Set Solved = 1 where codProblem = " + codProblem + "");
     SqlDataReader Noedit = ReturnData.ReturnDataset("Update TB_Problem Set Edit = 0 where codProblem = " + codProblem + "");
 }
Пример #7
0
 //Insere problemas
 public void InsertProblem(string Description, string Address, string Photo, int CodSubCategory, int codNeighborhood, int Solved, DateTime Date, int CodUser, int Edit = 1)
 {
     clDataAccess InsertData = new clDataAccess();
     SqlDataReader Insert = InsertData.ReturnDataset("insert into TB_Problem (Description,Address,Photo,CodSubCategory,codNeighborhood,Solved,Date,CodUser,Edit) values ( '" + Description + "','" + Address + "','" + Photo + "'," + CodSubCategory + "," + codNeighborhood + "," + Solved + ",'" + Date + "'," + CodUser + "," + Edit + ")");
 }
Пример #8
0
        //Retorna todos os problemas de um usuario
        public void UserProblem(int codUser)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader Return = ReturnData.ReturnDataset("select * from TB_Problem where " + "'" + codUser + "'" + " = codUser ");

            while (Return.Read())
            {

                pDescription = Convert.ToString(Return["Description"]);
                pAddress = Convert.ToString(Return["Address"]);
                pPhoto = Convert.ToString(Return["Photo"]);
                pcodSubCategory = Convert.ToInt32(Return["CodSubCategory"]);
                pcodNeighborhood = Convert.ToInt32(Return["codNeighborhood"]);
                pSolved = Convert.ToInt32(Return["Solved"]);
                pDate = Convert.ToDateTime(Return["Date"]);
                pCodUser = Convert.ToInt32(Return["CodUser"]);

            }

            // DataTable dt = new DataTable();
            // dt.Load(Return);
            // List<clProblem> problems = new List<clProblem>(dt.Rows.Count);
            // foreach (DataRow row in dt.Rows)
            // {
            //    problems.Add(new clProblem
            //   {
            //      pcodProblem = Convert.ToInt32(row["codProblem"]),
            //  pDescription = Convert.ToString(row["Description"]),
            // pAddress = Convert.ToString(row["Address"]),
            // pPhoto = Convert.ToString(row["Photo"]),
            // pcodSubCategory = Convert.ToInt32(row["CodSubCategory"]),
            // pcodNeighborhood = Convert.ToInt32(row["codNeighborhood"]),
            // pSolved = Convert.ToInt32(row["Solved"]),
            // pDate = Convert.ToDateTime(row["Date"]),
            //  pCodUser = Convert.ToInt32(row["CodUser"]),
            // });
        }
Пример #9
0
        //return problems;
        //Retorna todos os problemas de uma subcategoria
        public List<clProblem> ReturnProblemSub(int codSubCategory)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader Return = ReturnData.ReturnDataset("select * from TB_Problem where " + "'" + codSubCategory + "'" + " = subCategory ");
            DataTable dt = new DataTable();
            dt.Load(Return);
            List<clProblem> problems = new List<clProblem>(dt.Rows.Count);
            foreach (DataRow row in dt.Rows)
            {
                problems.Add(new clProblem
                {
                    pcodProblem = Convert.ToInt32(row["codProblem"]),
                    pDescription = Convert.ToString(row["Description"]),
                    pAddress = Convert.ToString(row["Address"]),
                    pPhoto = Convert.ToString(row["Photo"]),
                    pcodSubCategory = Convert.ToInt32(row["CodSubCategory"]),
                    pcodNeighborhood = Convert.ToInt32(row["codNeighborhood"]),
                    pSolved = Convert.ToInt32(row["Solved"]),
                    pDate = Convert.ToDateTime(row["Date"]),
                    pCodUser = Convert.ToInt32(row["CodUser"]),
                });
            }

            return problems;
        }
Пример #10
0
        // Retorna um problema
        public void ReturnProblem(int codProblem)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader Return = ReturnData.ReturnDataset("select * from TB_Problem where " + "'" + codProblem + "'" + " = codProblem ");

            while (Return.Read())
            {

                pcodProblem = Convert.ToInt32(Return["codProblem"]);
                pDescription = Convert.ToString(Return["Description"]);
                pAddress = Convert.ToString(Return["Address"]);
                pPhoto = Convert.ToString(Return["Photo"]);
                pcodSubCategory = Convert.ToInt32(Return["CodSubCategory"]);
                pcodNeighborhood = Convert.ToInt32(Return["codNeighborhood"]);
                pSolved = Convert.ToInt32(Return["Solved"]);
                pDate = Convert.ToDateTime(Return["Date"]);
                pCodUser = Convert.ToInt32(Return["CodUser"]);
            }
        }
Пример #11
0
        public bool containsUser(string User)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader retorno = ReturnData.ReturnDataset("select login from TB_Users where " + "'" + User + "'" + "= login ");
            while (retorno.Read())
            {
                Login = Convert.ToString(retorno["login"]);
            }
            if (User == Login)
            {

                return true;
            }
            else
            {
                return false;
            }
        }
Пример #12
0
        public void UserReturn(string User)
        {
            clDataAccess ReturnData = new clDataAccess();

            //Parameters.Add(new SqlParameter("@User", User));

            SqlDataReader retorno = ReturnData.ReturnDataset("select *  from TB_Users where Name = " + "'" + User + "'");

            while (retorno.Read())
            {
                pcodUser = Convert.ToInt32(retorno["codUser"]);
                Name = Convert.ToString(retorno["name"]);
                Address = Convert.ToString(retorno["address"]);
                Cpf = Convert.ToInt32(retorno["cpf"]);
                Email = Convert.ToString(retorno["email"]);
                Login = Convert.ToString(retorno["login"]);
                codRoles = Convert.ToInt32(retorno["codRoles"]);
                 activated = Convert.ToInt32(retorno["activated"]);

            }
        }
Пример #13
0
        public bool LoginValidation(string User, string Pass)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader retorno = ReturnData.ReturnDataset("select login, password, activated from TB_Users where " + "'" + User + "'" + "= login  and " + "'" + Pass + "'" + " = password");
            while (retorno.Read())
            {
                activated = Convert.ToInt32(retorno["activated"]);
                Login = Convert.ToString(retorno["login"]);
                Password = Convert.ToString(retorno["password"]);
            }
            if (User == Login && Pass == Password && activated == 1)
            {

                return true;
            }
            else
            {
                return false;
            }
        }
Пример #14
0
 public void EnableUser(string Login)
 {
     clDataAccess InsertData = new clDataAccess();
     SqlDataReader Insert = InsertData.ReturnDataset ("Update TB_Users Set Activated = 1 where codUser = '******'");
 }
Пример #15
0
        public string EmailRecovery(string rEmail)
        {
            clDataAccess ReturnData = new clDataAccess();
            SqlDataReader retorno = ReturnData.ReturnDataset("select password,email from TB_Users where email="+"'"+rEmail+"'");
            while (retorno.Read())
            {

                Password = Convert.ToString(retorno["password"]);
                Email = Convert.ToString(retorno["email"]);
            }

            if (rEmail == Email)
            {
                return Password;
            }
            else
            {
                return "Email Não encontrado";
            }
        }