private void dataGridView1_Click(object sender, EventArgs e) { if (dataGridView1.SelectedRows.Count>0) { ocontrol = (EControl_Cabecera)dataGridView1.CurrentRow.DataBoundItem; Ehenvase oenvase = new Ehenvase(); oenvase.Cod_cliente = ocontrol.Cod_cliente; dataGridView2.DataSource = null; dataGridView2.AutoGenerateColumns = false; dataGridView2.DataSource = oenvase.ListarHistorialEnvase(); } }
private void toolStripButton1_Click(object sender, EventArgs e) { if (list_detalle.Count>0) { EControl_Cabecera opedido = new EControl_Cabecera(); opedido.Idcomprobante = 1; opedido.Serie = txt_serie.Text; opedido.Numero = txt_numero.Text; opedido.Cod_cliente = txt_cod_cliente.Text; opedido.Cod_vendedor = txt_codvendedor.Text; opedido.Fech_pedido = Convert.ToDateTime(dtp_fecha.Value.ToShortDateString()); opedido.Hora_pedido = Convert.ToDateTime(DateTime.Now.ToLongTimeString()); opedido.Idtipopago = idtipopago; opedido.Idtipoventa = Convert.ToInt32(cmb_tipopedido.SelectedValue); opedido.Neto = pimporte; //opedido.T_envase = 5; opedido.SETREGISTRO(); foreach (EControlDetalle item in list_detalle) { EControlDetalle odetalle = new EControlDetalle(); odetalle.Idcontrol = opedido.Idcontrol; odetalle.Serie = txt_serie.Text; odetalle.Numero = txt_numero.Text; odetalle.Cod_producto = item.Cod_producto; odetalle.Cantidad = Convert.ToInt32(item.Cantidad); odetalle.Precio = Convert.ToDecimal(item.Precio); odetalle.Importe = Convert.ToDecimal(item.Importe); odetalle.Idcomprobante = 1; odetalle.Cod_cliente = txt_cod_cliente.Text; odetalle.Cod_vendedor = txt_codvendedor.Text; odetalle.Fech_pedido = Convert.ToDateTime(dtp_fecha.Value.ToShortDateString()); odetalle.Retornable = item.Retornable; odetalle.SETREGISTRO(); Ehenvase oenvase = new Ehenvase(); oenvase.Idcontrol = opedido.Idcontrol; oenvase.Serie = txt_serie.Text; oenvase.Numero = txt_numero.Text; oenvase.Cod_cliente = txt_cod_cliente.Text; oenvase.Cod_personal = txt_codvendedor.Text; oenvase.Fech_ven =Convert.ToDateTime( dtp_fecha.Value.ToShortDateString()); oenvase.Cod_producto = item.Cod_producto; oenvase.Cantidad = item.Cantidad; oenvase.SETREGISTRO(); } if (idtipopago != 2) { Ehpago opago = new Ehpago(); opago.Idcontrol = opedido.Idcontrol; opago.Idhijo = opedido.Idcontrol; opago.Iddocumento = 9; opago.Fech_pago = Convert.ToDateTime(dtp_fecha.Value.ToShortDateString()); opago.Monto = pimporte; opago.SETREGISTRO(); EControl_Cabecera rocabecera = new EControl_Cabecera(); rocabecera.Idcontrol = opedido.Idcontrol; rocabecera.Fech_pago = Convert.ToDateTime(dtp_fecha.Value.ToShortDateString()); rocabecera.CancelarPedido(); } /*Devolucion de enbases*/ if (txt_envase.Value != 0 || txt_pendiente.Value != 0) { EDevolucion odevolucion = new EDevolucion(); odevolucion.Cod_cliente = txt_cod_cliente.Text; odevolucion.Cod_vendedor = txt_codvendedor.Text; odevolucion.Serie = txt_serie.Text; odevolucion.Numero = txt_numero.Text; odevolucion.Cantidad = Convert.ToInt32(txt_envase.Value); odevolucion.Fech_dev = Convert.ToDateTime(dtp_fecha.Value.ToShortDateString()); odevolucion.Cod_producto = cmb_producto.SelectedValue.ToString(); odevolucion.Pendiente = Convert.ToInt32(txt_pendiente.Value); odevolucion.Insertar(); } MessageBox.Show("Proceso realizado con éxito !"); Limpiar(); } else { /*Devolucion de enbases*/ EDevolucion odevolucion = new EDevolucion(); odevolucion.Cod_cliente = txt_cod_cliente.Text; odevolucion.Cod_vendedor = txt_codvendedor.Text; odevolucion.Serie = txt_serie.Text; odevolucion.Numero = txt_numero.Text; odevolucion.Cantidad = Convert.ToInt32(txt_envase.Value); odevolucion.Fech_dev = Convert.ToDateTime(dtp_fecha.Value.ToShortDateString()); odevolucion.Cod_producto = cmb_producto.SelectedValue.ToString(); odevolucion.Pendiente = Convert.ToInt32(txt_pendiente.Value); odevolucion.Insertar(); MessageBox.Show("Proceso realizado con éxito !"); Limpiar(); } }
public List<Ehenvase> ListarHistorialEnvase() { try { BDAcces bd = new BDAcces(); DataSet dt= new DataSet(); List<Ehenvase> lista = new List<Ehenvase>(); bd.AddParameter("@cod_cliente", cod_cliente); SqlDataReader leer = (SqlDataReader)bd.ExecuteReader("GETDEVOLUCIONES"); while (leer.Read()) { Ehenvase oenvase = new Ehenvase(); oenvase.serie=leer[0].ToString(); oenvase.numero = leer[1].ToString(); oenvase.vendedor = leer[2].ToString(); oenvase.fech_ven = Convert.ToDateTime(leer[3].ToString()); oenvase.cantidad = Convert.ToInt32(leer[4].ToString()); oenvase.cod_personal = leer[5].ToString(); oenvase.iddevolucion = Convert.ToInt32(leer[6].ToString()); lista.Add(oenvase); } return lista; } catch (Exception) { throw; } }