Example #1
0
 //METODO OLVIDE MI CONTRASEÑA
 private void linkPass_Click(object sender, EventArgs e)
 {
     if (mailPassword != "" && mailPassword.Contains("@"))
     {
         string  status = string.Empty, code = string.Empty;
         Boolean boolPass = new BrAnimusRest().recoverPassword(mailPassword, out status, out code);
         if (boolPass == true)
         {
             //mensaje ok
         }
         else
         {
             //mensaje no se pudo
         }
     }
 }
Example #2
0
        //Metodo encargado de registrar
        private void btnRegistro_Click(object sender, EventArgs e)
        {
            if (ValidateFields() == false)
            {
                return;
            }


            //si el email ya existe lo tengo que mandar a iniciar session
            string       status = string.Empty, code = string.Empty;
            BrAnimusRest brAnimus     = new BrAnimusRest();
            Boolean      validateMail = brAnimus.validateMail(txtCorreo.Text, out status, out code);

            if (status.ToUpper().Trim() != "OK" || code != "200")
            {
                MetroFramework.MetroMessageBox.Show(this, "No existe conexión con el servidor, vuelva a reintentarlo.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);


                return;
            }

            if (validateMail == true)
            {
                txtCorreo.Text = string.Empty;
                txtNick.Text   = string.Empty;
                MetroFramework.MetroMessageBox.Show(this, "La cuenta de correo existe, debe ingresar por la opción ya tengo una cuenta.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            //PASSING VARIABLES

            this.Hide();
            mail = txtCorreo.Text;
            nick = txtNick.Text;

            Password pass = new Password();

            pass.ShowDialog();
        }
Example #3
0
        private void btnSaveHome_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidatePassword(txtPassword.Text) == false)
                {
                    return;
                }

                if (btnSaveHome.Text.ToUpper().Trim().Contains("HOGAR"))
                { // INSERT HOGAR.
                    //devuelde id select last_insert_rowid();
                    if (mailPassword != "" && nickPassword != "" && txtPassword.Text != "")
                    {
                        CoHome coHome = new CoHome();
                        coHome.nick     = nickPassword;
                        coHome.password = txtPassword.Text;
                        coHome.mail     = mailPassword;
                        string status = string.Empty;
                        string code   = string.Empty;

                        string fullimagepath = Path.Combine(Application.StartupPath);

                        string path = System.IO.Directory.GetCurrentDirectory().Replace("\\bin\\Debug", "");
                        path = path + "\\" + "usr.txt";

                        //Consumir post al insert casa
                        coHome = new BrAnimusRest().registerHome(out status, out code, coHome);

                        if (status.ToUpper().Trim() != "OK" || code != "201")
                        {
                            MetroFramework.MetroMessageBox.Show(this, "No existe conexión con el servidor, vuelva a reintentarlo.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        if (coHome.id != 0)
                        {
                            string response = string.Empty;
                            //insertamos home en base de datos
                            //new BrHome().InsertHome(coHome, out response);

                            //GUARDA ARCHIVO CON HOME,ID,MAIL,PASS
                            if (File.Exists(path) && response == "OK")
                            {
                                //remove text archive
                                //File.Delete(path);
                                //create archive
                                idHome = coHome.id;
                                string createText = coHome.id + ";" + coHome.mail + ";" + coHome.nick;
                                File.WriteAllText(path, createText);

                                homeControl = coHome;

                                //this.Close();
                                //DashBoardMenu dashBoard = new DashBoardMenu();
                                //dashBoard.ShowDialog();

                                this.Close();
                                //ControlCenter c = new ControlCenter();
                                //c.ShowDialog();
                            }
                        }
                    }
                }
                else // validate auth
                {
                    if (mailPassword != "" && txtPassword.Text != "")
                    {
                        CoHome coHome = new CoHome();
                        coHome.mail     = mailPassword;
                        coHome.password = txtPassword.Text;
                        string status = string.Empty;
                        string code   = string.Empty;

                        //consume validate password
                        new BrAnimusRest().validateAuth(out status, out code, coHome);

                        if (status.ToUpper().Trim() != "OK" || code == "402")
                        {
                            MetroFramework.MetroMessageBox.Show(this, "Usuario o Password Incorrecto.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        if (status.ToUpper().Trim() != "OK" || code != "201")
                        {
                            MetroFramework.MetroMessageBox.Show(this, "No existe conexión con el servidor, vuelva a reintentarlo.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }

                        if (coHome.id != 0)
                        {
                            // mando a llamar al dashboard
                            //this.Hide();
                            //DashBoardMenu d = new DashBoardMenu();
                            //d.ShowDialog();
                            homeControl = coHome;
                            this.Hide();
                            //ControlCenter c = new ControlCenter();
                            //c.ShowDialog();
                        }
                        else
                        {
                            MetroFramework.MetroMessageBox.Show(this, "No se pudo rescatar los datos del usuario, favor reintentar.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            return;
                        }
                    }
                }

                #region
                //CoHome coHome = new CoHome();
                //coHome.nickHome = nickPassword;
                //coHome.password = txtPassword.Text;
                //coHome.mail = mailPassword;

                //if (imageHomePath != "")
                //    coHome.pathImageHome = imageHomePath;

                //if (nameArchiveHome != "")
                //    coHome.imageHome = nameArchiveHome;

                //int homeIdRescue = 0;
                ////vamos a validar si existe el home con el correo y nick
                //int countExist = new BrHome().HomeExits(coHome, out homeIdRescue);
                //if (countExist == 0)
                //{
                //    //inserto home
                //    idHome = new BrHome().InsertHome(coHome);
                //    if (idHome > 0)
                //    {
                //        //Mando A llamar menu
                //        this.Hide();

                //        DashBoardMenu dashBoard = new DashBoardMenu();
                //        dashBoard.ShowDialog();
                //    }
                //    else
                //    {
                //        MetroFramework.MetroMessageBox.Show(this, "No se pudo registrar el Hogar, pongase en contacto con el administrador.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    }
                //}
                //else
                //{
                //    if (countExist == 1 && homeIdRescue != 0)
                //    {
                //        coHome.idHome = homeIdRescue;
                //        //validar password
                //        Boolean validatePass = new BrHome().validatePassword(coHome);

                //        if (validatePass == false)
                //        {
                //            MetroFramework.MetroMessageBox.Show(this, "La contraseña es incorrecta.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //            return;
                //        }



                //        idHome = homeIdRescue;
                //        //Mando A llamar menu
                //        this.Hide();

                //        DashBoardMenu dashBoard = new DashBoardMenu();
                //        dashBoard.ShowDialog();
                //    }
                //    else
                //    {
                //        MetroFramework.MetroMessageBox.Show(this, "No se pudieron rescatar los datos del Hogar, pongase en contacto con el administrador.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //    }
                //}
                #endregion
            }
            catch (Exception ex)
            {
            }
        }
Example #4
0
        private void txtCorreo_Leave(object sender, EventArgs e)
        {
            if (txtCorreo.Text != "")
            {
                BrHome br = new BrHome();
                //vamos a validar que el correo sea valido
                if (br.ValidateEmailFormat(txtCorreo.Text) == true)
                {
                    //si el email ya existe lo tengo que mandar a iniciar session
                    string       status = string.Empty, code = string.Empty;
                    BrAnimusRest brAnimus     = new BrAnimusRest();
                    Boolean      validateMail = brAnimus.validateMail(txtCorreo.Text, out status, out code);

                    if (status.ToUpper().Trim() != "OK" || code != "200")
                    {
                        MetroFramework.MetroMessageBox.Show(this, "No existe conexión con el servidor, vuelva a reintentarlo.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    if (validateMail == true)
                    {
                        MetroFramework.MetroMessageBox.Show(this, "La cuenta de correo existe, debe ingresar por la opción ya tengo una cuenta.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return;
                    }

                    //CoHome coHome = new CoHome();
                    //int homeIdRescue = 0;
                    //coHome.mail = txtCorreo.Text;
                    ////buscamos si el correo es valido para cargar la foto en el picture
                    //int countExist = new BrHome().HomeExits(coHome, out homeIdRescue);
                    //if (homeIdRescue != 0)
                    //{
                    //    DataTable dtHome = new BrHome().GetHomeId(homeIdRescue);
                    //    if (dtHome.Rows.Count > 0)
                    //    {
                    //        string pathImage = dtHome.Rows[0]["imagehome"].ToString();
                    //        if (pathImage != "")
                    //            pictureBox1.Image = Image.FromFile(pathImage);
                    //        else
                    //            pictureBox1.Image = Image.FromFile(pathImageDefault + imageDefault);
                    //        txtNick.Text = dtHome.Rows[0]["nickhome"].ToString();
                    //        errorProvider.SetError(txtCorreo, "");
                    //        errorProvider.SetError(txtNick, "");
                    //        idHome = Convert.ToInt32(dtHome.Rows[0]["idhome"].ToString());
                    //    }
                    //}
                    //else
                    //{
                    //    if (File.Exists(pathImageDefault + imageDefault))
                    //    {
                    //        pictureBox1.Image = Image.FromFile(pathImageDefault + imageDefault);
                    //        txtNick.Text = "";
                    //        errorProvider.SetError(txtCorreo, "");
                    //        errorProvider.SetError(txtNick, "");
                    //    }
                    //    idHome = 0;
                    //    mail = "";
                    //    nick = "";
                    //}
                }
                else
                {
                    MetroFramework.MetroMessageBox.Show(this, "El campo correo electrónico no tiene un formato correcto.", "Animus", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    txtCorreo.Text = string.Empty;
                    txtNick.Text   = string.Empty;
                    //    if (File.Exists(pathImageDefault + imageDefault))
                    //    {
                    //        pictureBox1.Image = Image.FromFile(pathImageDefault + imageDefault);
                    //        txtNick.Text = "";
                    //        errorProvider.SetError(txtCorreo, "");
                    //        errorProvider.SetError(txtNick, "");
                    //    }
                    //    idHome = 0;
                    //    mail = "";
                    //    nick = "";
                }
            }
            else
            {
                //idHome = 0;
                //mail = "";
                //nick = "";
            }
        }