コード例 #1
0
        private void FrmAgregarPlato_Load(object sender, EventArgs e)
        {
            TipoPlatoNegocio tiposPlatos = new TipoPlatoNegocio();

            try
            {
                cbxTipo.DataSource    = tiposPlatos.listaTipoPlato();
                cbxTipo.DisplayMember = "descripcion";
                cbxTipo.ValueMember   = "id";
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void BtnAgregar_Click(object sender, EventArgs e)
 {
     if (txtNombre.Text.Trim() != "")
     {
         if (TipoPlatoNegocio.agregar(txtNombre.Text.Trim()))
         {
             MessageBox.Show("Se agrego correctamente");
             txtNombre.Text = "";
         }
         else
         {
             MessageBox.Show("No se pudo agregar, intentelo de nuevo");
         }
     }
     else
     {
         MessageBox.Show("Rellene el nombre");
     }
 }
        private void FrmPlatoModificar_Load(object sender, EventArgs e)
        {
            TipoPlatoNegocio tiposPlatos = new TipoPlatoNegocio();

            try
            {
                cbxTipo.DataSource    = tiposPlatos.listaTipoPlato();
                cbxTipo.DisplayMember = "descripcion";
                cbxTipo.ValueMember   = "id";
                if (platoLocal != null)
                {
                    txtNombre.Text        = platoLocal.nombre.ToString();
                    txtDescripcion.Text   = platoLocal.descripcion.ToString();
                    txtPrecio.Text        = platoLocal.precio.ToString();
                    cbxTipo.SelectedValue = platoLocal.tipoPlato.id;
                    id = platoLocal.id;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }