private void btnBuscar_Click(object sender, EventArgs e) { try { if (!txtIdEnvio.Text.Equals("")) { ENVIO pedidoIdUser = new ENVIO(); pedidoIdUser.IDENVIO = Convert.ToInt32(txtIdEnvio.Text.Trim()); List <ENVIO> lstPedidos = _02LogicadeNegocios.Logica.BuscarDatoA(pedidoIdUser); this.dataGrid.DataSource = lstPedidos; this.dataGrid.Refresh(); } else if (!txtDesc.Text.Equals("")) { ENVIO pedidoIdUser = new ENVIO(); pedidoIdUser.DESC_ENVIO = txtDesc.Text.Trim(); List <ENVIO> lstPedidos = _02LogicadeNegocios.Logica.BuscarDatoB(pedidoIdUser); this.dataGrid.DataSource = lstPedidos; this.dataGrid.Refresh(); } else if (txtIdEnvio.Text.Equals("") && txtDesc.Text.Equals("")) { CargarEnvios(); } } catch (Exception ex) { MessageBox.Show("Error al Buscar Datos de Tabla Envios" + ex.Message); } Limpiar(); }
public ENVIO processoBase() { ENVIO envio = new ENVIO(); envio.IDENVIO = Convert.ToInt16(txtIdEnvio.Text.Trim()); envio.DESC_ENVIO = txtDesc.Text.Trim(); envio.PRECIO_ENVIO = Convert.ToInt32(txtPrecio.Text.Trim()); return(envio); }
private void btnGuardar_Click(object sender, EventArgs e) { try { ENVIO envio = new ENVIO(); //envio.IDENVIO = Convert.ToInt16(txtIdEnvio.Text.Trim()); envio.DESC_ENVIO = txtDesc.Text.Trim(); envio.PRECIO_ENVIO = Convert.ToInt32(txtPrecio.Text.Trim()); _02LogicadeNegocios.Logica.GuardarDato(envio); MessageBox.Show("Envio Agregado"); Limpiar(); this.Close(); } catch (Exception ex) { MessageBox.Show("Error al Guardar Datos en Tabla Envio" + ex.Message); } }
public List <ENVIO> Obtener_Envio(SQLSentencia objsentencia) { List <ENVIO> lstEnvio = new List <ENVIO>(); System.Data.DataTable dt = new System.Data.DataTable(); try { SqlCommand cmd = new SqlCommand(); cmd.CommandText = objsentencia.PETICION; cmd.Connection = objConexion; cmd.CommandType = System.Data.CommandType.Text; SqlDataAdapter objcarga = new SqlDataAdapter(cmd); objcarga.Fill(dt); foreach (System.Data.DataRow item in dt.Rows) { ENVIO objEnvio = new ENVIO(); objEnvio.IDENVIO = Convert.ToInt16(item.ItemArray[0].ToString()); objEnvio.DESC_ENVIO = item.ItemArray[1].ToString(); objEnvio.PRECIO_ENVIO = Convert.ToInt16(item.ItemArray[2].ToString()); lstEnvio.Add(objEnvio); } } catch (Exception ex) { throw ex; } finally { this.CERRAR(); } return(lstEnvio); }