private void btnAddAddress_Click(object sender, EventArgs e)
 {
     if (txtNewAddress.Text.Equals(""))
     {
         MessageBox.Show("Debe escribir una dirección.", "Hugo",
                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         try
         {
             Address address = new Address();
             address.IdUser   = user.IdUser;
             address.SAddress = txtNewAddress.Text;
             AddressDAO.CreateAddress(address);
             UpdateTable();
             UpdateCmbAddress();
             MessageBox.Show("La dirección ha sido ingresada con éxito.", "Hugo",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception exception)
         {
             MessageBox.Show("Ha ocurrido un error.", "Hugo",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
 private void btnUpdateAddress_Click(object sender, EventArgs e)
 {
     if (txtUpdateAddress.Text.Equals("") || nudAddressID.Value == 0)
     {
         MessageBox.Show("Debe modificar una dirección existente.", "Hugo",
                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         try
         {
             Address address = new Address();
             address.IdUser    = user.IdUser;
             address.IdAddress = (int)nudAddressID.Value;
             address.SAddress  = txtUpdateAddress.Text;
             AddressDAO.UpdateAddress(address);
             UpdateTable();
             UpdateCmbAddress();
             MessageBox.Show("La dirección ha sido modificada con éxito.", "Hugo",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception exception)
         {
             MessageBox.Show("Ha ocurrido un error.", "Hugo",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
 private void UpdateCmbAddress()
 {
     cmbAddress.DataSource    = null;
     cmbAddress.ValueMember   = nameof(Address.IdAddress);
     cmbAddress.DisplayMember = nameof(Address.SAddress);
     cmbAddress.DataSource    = AddressDAO.GetAddress(user.IdUser);
 }
 private void UpdateTable()
 {
     dgvShowAddress.DataSource = null;
     dgvShowAddress.DataSource = AddressDAO.GetAddressTable(user.IdUser);
     nudAddressID.Maximum      = dgvShowAddress.RowCount > 0?Convert.ToInt32(
         dgvShowAddress.Rows[dgvShowAddress.RowCount - 1].Cells[0].Value.ToString()):0;
 }
 private void btnDeleteAddress_Click(object sender, EventArgs e)
 {
     if (txtUpdateAddress.Text.Equals("") || nudAddressID.Value == 0)
     {
         MessageBox.Show("Debe seleccionar una dirección. ", "Hugo",
                         MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
     else
     {
         try
         {
             Address address = new Address();
             address.IdAddress = Convert.ToInt32(nudAddressID.Value);
             address.IdUser    = user.IdUser;
             address.SAddress  = txtUpdateAddress.Text;
             AddressDAO.DeleteAddress(address);
             UpdateTable();
             UpdateCmbAddress();
             MessageBox.Show("La dirección ha sido eliminada con éxito.", "Hugo",
                             MessageBoxButtons.OK, MessageBoxIcon.Information);
         }
         catch (Exception exception)
         {
             MessageBox.Show("Ha ocurrido un error.", "Hugo",
                             MessageBoxButtons.OK, MessageBoxIcon.Warning);
         }
     }
 }
Exemple #6
0
 private void PoblarControles()
 {
     comboBox1.DataSource    = null;
     comboBox1.ValueMember   = "idAddress";
     comboBox1.DisplayMember = "address";
     comboBox1.DataSource    = AddressDAO.getLista();
 }
Exemple #7
0
 private void btnDelDireccion_Click(object sender, EventArgs e)
 {
     try
     {
         AddressDAO.EliminarDir(Convert.ToInt32(txtDelDir.Text));
         MessageBox.Show("Eliminado con exito",
                         "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ActualizarControles();
     }
     catch (Exception exception)
     {
         MessageBox.Show("La dirccion no existe.",
                         "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
Exemple #8
0
 private void btnAddDireccion_Click(object sender, EventArgs e)
 {
     try
     {
         AddressDAO.CrearNuevo(user.idUser, txtNewDir.Text);
         MessageBox.Show("Ingresado con exito",
                         "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Information);
         ActualizarControles();
     }
     catch (Exception exception)
     {
         MessageBox.Show(exception.Message,
                         "Hugo App", MessageBoxButtons.OK, MessageBoxIcon.Error);
         throw;
     }
 }
 private void nudAddressID_ValueChanged(object sender, EventArgs e)
 {
     txtUpdateAddress.Text = AddressDAO.GetAddress((int)nudAddressID.Value, user.IdUser).SAddress;
 }