Example #1
0
        private void LandingPageLogin_Click(object sender, EventArgs e)
        {
            //Redirect button to registrationpage

            Login.LoginForm LoginForm = new Login.LoginForm();
            LoginForm.Tag = this;
            Hide();
            LoginForm.Show(this);
        }
 private void cancel_Click(object sender, EventArgs e)
 {
     Login.LoginForm form = new Login.LoginForm();
     this.Hide();
     form.Show();
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (!razonSocial.Text.Equals("") && !cuit.Text.Equals("") && !direccion.Text.Equals("") && !codigoPostal.Text.Equals("") && !email.Text.Equals(""))
     {
         if (!BDSQL.existeString(razonSocial.Text, "MERCADONEGRO.Empresas", "Razon_Social"))
         {
             if (!BDSQL.existeString(cuit.Text, "MERCADONEGRO.Empresas", "CUIT"))
             {
                 if (Interfaz.esNumerico(telefono.Text, System.Globalization.NumberStyles.Integer) || telefono.Text.Equals(""))
                 {
                     if (!BDSQL.existeTelefono(Convert.ToInt32(telefono.Text)))
                     {
                         registrarEmpresa(username, password, razonSocial.Text, cuit.Text, telefono.Text, direccion.Text, codigoPostal.Text, ciudad.Text, email.Text, nombreContacto.Text, Interfaz.obtenerFecha());
                         MessageBox.Show("Alta finalizada. Puede ingresar al sistema.", "Registro exitoso");
                         Login.LoginForm form = new Login.LoginForm();
                         this.Hide();
                         form.Show();
                     }
                     else
                     {
                         MessageBox.Show("Teléfono existente.", "Error");
                     }
                 } else {
                     MessageBox.Show("Teléfono inválido existente.", "Error");
                 }
             }
             else
             {
                 MessageBox.Show("CUIT ya existente.", "Error");
             }
         }
         else
         {
             MessageBox.Show("Razón Social ya existente.", "Error");
         }
     }
     else
     {
         MessageBox.Show("Debe completar los campos solicitados.", "Error");
     }
 }
 private void button1_Click(object sender, EventArgs e)
 {
     if (cbTipoDocumento.SelectedIndex != -1 && !numeroDocumento.Text.Equals("") && !nombre.Text.Equals("") && !apellido.Text.Equals("") && !email.Text.Equals("") && !direccion.Text.Equals("") && !codigoPostal.Text.Equals("") && cbDia.SelectedIndex != -1 && cbMes.SelectedIndex != -1 && cbAno.SelectedIndex != -1)
     {
         if (Interfaz.esNumerico(numeroDocumento.Text, System.Globalization.NumberStyles.Integer))
         {
             if (!BDSQL.existenSimultaneamente(numeroDocumento.Text, cbTipoDocumento.SelectedItem.ToString(), "MERCADONEGRO.Clientes", "Num_Doc", "Tipo_Doc"))
             {
                 if (Interfaz.esNumerico(telefono.Text, System.Globalization.NumberStyles.Integer) || telefono.Text.Equals(""))
                 {
                     if (!BDSQL.existeTelefono(Convert.ToInt32(telefono.Text)))
                     {
                         registrarCliente(username, password, cbTipoDocumento.SelectedItem.ToString(), numeroDocumento.Text, nombre.Text, apellido.Text, email.Text, telefono.Text, direccion.Text, codigoPostal.Text, fechaNacimiento(cbDia.SelectedItem.ToString(), cbMes.SelectedItem.ToString(), cbAno.SelectedItem.ToString()));
                         MessageBox.Show("Alta finalizada. Puede ingresar al sistema.", "Registro exitoso");
                         Login.LoginForm form = new Login.LoginForm();
                         this.Hide();
                         form.Show();
                     }
                     else
                     {
                         MessageBox.Show("Teléfono existente.", "Error");
                     }
                 }
                 else
                 {
                     MessageBox.Show("Teléfono inválido.", "Error");
                 }
             }
             else
             {
                 MessageBox.Show("Datos identificatorios (Tipo de documento, Número de documento) ya existentes.", "Error");
             }
         }
         else
         {
             MessageBox.Show("Número de documento inválido.", "Error");
         }
     }
     else
     {
         MessageBox.Show("Debe completar los campos solicitados.", "Error");
     }
 }
Example #5
0
        private void RegisterButton_Click(object sender, EventArgs e)
        {
            string  user = RegisterPageUsername.Text;
            string  pass = RegisterPagePassword.Text;
            string  n    = RegisterPageName.Text;
            string  dob  = RegisterPageDoB.Value.ToString("yyyy-MM-dd");
            string  h    = RegisterPageHeight.Text;
            string  w    = RegisterPageWeight.Text;
            decimal a    = RegisterPageActivity.Value;
            string  g    = "";

            while (true)
            {
                if (RegisterPageRadioButtonMale.Checked == true)
                {
                    g = RegisterPageRadioButtonMale.Text;
                    break;
                }
                else
                {
                    g = RegisterPageRadioButtonFemale.Text;
                    break;
                }
            }

            if (register.IsRegisterInfoInput(user, pass, dob, n, h, w))
            {
                try
                {
                    MySqlConnection conR = DietTracker.DatabaseConnect.OpenDefaultDBConnection();

                    //First it writes to the user table
                    MySqlCommand registerCommand = new MySqlCommand();
                    registerCommand.CommandText =
                        "INSERT INTO diettracker.users (Username, Name, Gender, DoB, Height, Weight, Activity)" +
                        "VALUES ('" + user + "', '" + n + "', '" + g + "', '" + dob + "', '" + h + "', '" + w + "', '" + a + "');";
                    registerCommand.Connection = conR;

                    conR.Open();
                    registerCommand.ExecuteNonQuery();
                    conR.Close();

                    //It then takes the ID from the user table to use it
                    MySqlCommand idCommand = new MySqlCommand();
                    idCommand.CommandText = "SELECT ID FROM users WHERE Username = '******';";
                    idCommand.Connection  = conR;

                    conR.Open();
                    MySqlDataReader IDRead = idCommand.ExecuteReader();
                    IDRead.Read();
                    string UserID = IDRead.GetString(0);
                    var    ID     = String.Format("{0}", UserID);
                    UserID = ID;
                    conR.Close();

                    //It inserts into the password table the password and the ID that corresponded to the user table
                    MySqlCommand passwordCommand = new MySqlCommand();
                    passwordCommand.CommandText = "INSERT INTO diettracker.password (Password, ForeignID) " +
                                                  "VALUES ('" + pass + "', '" + UserID + "');";
                    passwordCommand.Connection = conR;
                    conR.Open();
                    passwordCommand.ExecuteNonQuery();
                    conR.Close();

                    var          dateTimeToday = DateTime.Today.ToString("yyyy-MM-dd");
                    MySqlCommand dayCommand    = new MySqlCommand();
                    dayCommand.CommandText = "INSERT INTO diettracker.day (Date, Weight, Calories, UserID)" +
                                             "VALUES ('" + dateTimeToday + "', '" + w + "', '0', '" + user + "');";
                    dayCommand.Connection = conR;
                    conR.Open();
                    dayCommand.ExecuteNonQuery();
                    conR.Close();

                    MessageBox.Show("User Successfully created!");

                    Login.LoginForm loginForm = new Login.LoginForm();
                    loginForm.Tag = this;
                    Hide();
                    loginForm.Show(this);
                }
                catch (MySqlException ex)
                {
                    //MessageBox.Show("Something happened" + ex);
                    switch (ex.Number)
                    {
                    case 0:
                        MessageBox.Show("Cannot connect to server.");
                        break;

                    case 1062:
                        MessageBox.Show("That Username is already in use");
                        break;

                    case 1264:
                        MessageBox.Show("You can't be higher than 255 cm (Come on, you're not that tall)");
                        break;
                    }
                }

                catch (Exception)
                {
                    MessageBox.Show("Something unexpected happened");
                }
            }
        }