Exemplo n.º 1
0
        private void btnAddNew_Click(object sender, EventArgs e)
        {
            bool email = true;

            if (!String.IsNullOrEmpty(txtEmail.Text) && !Utils.check.checkEmail(txtEmail.Text))
            {
                email = false;
            }
            if (checkAdd() && email)
            {
                String sql = inserSql();
                GestorCustomers.insertCustomer(sql);
                clean();
            }
            else
            {
                if (!email)
                {
                    if (this.idioma == "ESPAÑOL")
                    {
                        MessageBox.Show(errorDialog() + "\t - El campo \"Email\"no tiene el formato correcto \n");
                    }
                    else
                    {
                        MessageBox.Show(errorDialog() + "\t - The field \"Email\"doesn't the correct format \n");
                    }
                }
                else
                {
                    MessageBox.Show(errorDialog());
                }
            }
        }
Exemplo n.º 2
0
        private String extraerRefZipCodesCities()
        {
            String refe = null;

            refe = GestorCustomers.getData("IDZPICODESCITIES", "ZIPCODESCITIES", " WHERE REFZIPCODE=" + cmbZIP.SelectedValue.ToString()
                                           + " REFCITY=" + cmbCity.SelectedValue.ToString() + " REFSTATE=" + cmbProv.SelectedValue.ToString());

            return(refe);
        }
Exemplo n.º 3
0
 private String errorDialog()
 {
     if (this.idioma == "ESPAÑOL")
     {
         String error = "Se han encontrado algunos errores: \n";
         if (string.IsNullOrEmpty(txtName.Text))
         {
             error += "\t - El campo \"Nombre\" no puede estar vacio \n";
         }
         if (string.IsNullOrEmpty(txtSurname.Text))
         {
             error += "\t - El campo \"Apellido\" no puede estar vacio \n";
         }
         if (string.IsNullOrEmpty(txtDNI.Text))
         {
             error += "\t - El campo \"DNI\" no puede estar vacio \n";
         }
         if (!Utils.check.checkDNI(txtDNI.Text))
         {
             error += "\t - El DNI no tiene el formato correcto \n" +
                      " \t\t ejemplo- 00000000A \n";
         }
         if (GestorCustomers.existDNI(txtDNI.Text))
         {
             error += "\t - Ya existe un cliente con este DNI: " + txtDNI.Text;
         }
         return(error);
     }
     else
     {
         String error = "Some Errors has been found: \n";
         if (string.IsNullOrEmpty(txtName.Text))
         {
             error += "\t - The field \"Name\" can`t be empty \n";
         }
         if (string.IsNullOrEmpty(txtSurname.Text))
         {
             error += "\t - The field \"Surname\" can`t be empty \n";
         }
         if (string.IsNullOrEmpty(txtDNI.Text))
         {
             error += "\t - The field \"DNI\" can`t be empty \n";
         }
         if (!Utils.check.checkDNI(txtDNI.Text))
         {
             error += "\t - The DNI doesn't the correct format \n" +
                      " \t\t Example- 00000000A \n";
         }
         if (GestorCustomers.existDNI(txtDNI.Text))
         {
             error += "\t - Already exist a User with the DNI: " + txtDNI.Text;
         }
         return(error);
     }
 }
Exemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            String valor = dgvCustomer.Rows[dgvCustomer.CurrentRow.Index].Cells[0].Value.ToString();

            if (!GestorCustomers.existCustomer(valor))
            {
                if (this.idioma == "ESPAÑOL")
                {
                    if (MessageBox.Show("¿Quieres eliminar a este cliente?", "Eliminar Cliente", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        String sql = "update customers set Deleted=1 where idcustomer =" + valor;
                        GestorCustomers.delCustomers(sql);
                        initTable(" Where Deleted=0");
                    }
                }
                else
                {
                    if (MessageBox.Show("Do yo Want Delete this Customer?", "Delete Customer", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        String sql = "update customers set Deleted=1 where idcustomer =" + valor;
                        GestorCustomers.delCustomers(sql);
                        initTable(" Where Deleted=0");
                    }
                }
            }
            else
            {
                if (this.idioma == "ESPAÑOL")
                {
                    MessageBox.Show("Este cliente tiene pedidos en DB");
                }
                else
                {
                    MessageBox.Show("This Customer have Orders in DB");
                }
            }
        }
Exemplo n.º 5
0
 public Customer()
 {
     g = new GestorCustomers();
 }
Exemplo n.º 6
0
 /*
  * Metodo para comprobar si  estan rellenos los campos obligatorios
  */
 private bool checkAdd()
 {
     return(!(string.IsNullOrEmpty(txtName.Text) && string.IsNullOrEmpty(txtSurname.Text) && string.IsNullOrEmpty(txtDNI.Text)) && Utils.check.checkDNI(txtDNI.Text) && !GestorCustomers.existDNI(txtDNI.Text));
 }
Exemplo n.º 7
0
 private void btnChange_Click(object sender, EventArgs e)
 {
     if (this.idioma == "ESPAÑOL")
     {
         if (MessageBox.Show("¿Estas seguro de modificar este cliente?", "Modificar Cliente", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             bool email = true;
             if (!String.IsNullOrEmpty(txtEmail.Text) && !Utils.check.checkEmail(txtEmail.Text))
             {
                 email = false;
             }
             if (checkUpdate() && email)
             {
                 String sql = updateSql();
                 Console.WriteLine(sql);
                 GestorCustomers.setData(sql);
                 Dispose();
             }
             else
             {
                 if (!email)
                 {
                     MessageBox.Show(errorDialog() + "\t - El campo \"Email\" no tiene el formato correcto  \n");
                 }
                 else
                 {
                     MessageBox.Show(errorDialog());
                 }
             }
         }
     }
     else
     {
         if (MessageBox.Show("Do yo Want Update this Customers ?", "Update Customer", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             bool email = true;
             if (!String.IsNullOrEmpty(txtEmail.Text) && !Utils.check.checkEmail(txtEmail.Text))
             {
                 email = false;
             }
             if (checkUpdate() && email)
             {
                 String sql = updateSql();
                 Console.WriteLine(sql);
                 GestorCustomers.setData(sql);
                 Dispose();
             }
             else
             {
                 if (!email)
                 {
                     MessageBox.Show(errorDialog() + "\t - The field \"Email\" doesn't the correct format \n");
                 }
                 else
                 {
                     MessageBox.Show(errorDialog());
                 }
             }
         }
     }
 }