private void recargaReporte(string cnSQL, string param, int orden, bool fechas) { oDato.conectar(); //if (param != "") cnSQL += " WHERE (((C.apellido+' '+C.nombre) Like '%" + param + "%'))"; if (fechas) { cnSQL += " AND C.fechaNac BETWEEN #" + dtpDesde.Value.ToShortDateString() + "# AND #" + dtpHasta.Value.ToShortDateString() + "#"; } if (orden >= 0) { cnSQL += " ORDER BY " + (orden + 1); } OleDbDataAdapter da = new OleDbDataAdapter(cnSQL, oDato.pConexion); DataSet ds = new DataSet(); da.Fill(ds); repDS = new ReportDataSource("dsetProducto_dtClientes", ds.Tables[0]); rptvClientes.LocalReport.DataSources.Clear(); rptvClientes.LocalReport.DataSources.Add(repDS); rptvClientes.LocalReport.ReportEmbeddedResource = "PII_TP2_Vet.rptClientes.rdlc"; rptvClientes.LocalReport.Refresh(); rptvClientes.Refresh(); rptvClientes.RefreshReport(); oDato.desconectar(); }
private void recargaReporte(string cnSQL, string param, int orden) { oDato.conectar(); if (param != "") { cnSQL += " WHERE P.descripcion LIKE '%" + param + "%'"; } if (orden >= 0) { cnSQL += " ORDER BY " + (orden + 1); } OleDbDataAdapter da = new OleDbDataAdapter(cnSQL, oDato.pConexion); DataSet ds = new DataSet(); da.Fill(ds); repDS = new ReportDataSource("dsetProducto_dtProductos", ds.Tables[0]); rptvProds.LocalReport.DataSources.Clear(); rptvProds.LocalReport.DataSources.Add(repDS); rptvProds.LocalReport.ReportEmbeddedResource = "PII_TP2_Vet.rptProductos.rdlc"; rptvProds.LocalReport.Refresh(); rptvProds.Refresh(); rptvProds.RefreshReport(); oDato.desconectar(); }
private void btnGrabar_Click(object sender, EventArgs e) { if (Validar()) { //string consultaSQL = ""; Cliente C = new Cliente(); C.pIdCliente = Convert.ToInt32(txtIdCliente.Text); C.pApellido = txtApellido.Text; C.pNombre = txtNombre.Text; C.pDireccion = txtDireccion.Text; C.pTelFijo = txtTelFijo.Text; C.pTelCel = txtTelCel.Text; C.pCorreo = txtCorreo.Text; C.pTipoDoc = Convert.ToInt32(cboTipoDoc.SelectedValue); C.pNroDoc = txtNroDoc.Text; if (rbtMasculino.Checked) { C.pSexo = 1; } else { C.pSexo = 2; } C.pFechaNac = dtpFechaNac.Value; C.pEstado = chkActivo.Checked; DialogResult opcion = MessageBox.Show("¿Desea grabar el Cliente?", "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (opcion == DialogResult.Yes) { if (nuevo) { if (!existe(C.pIdCliente)) { //consultaSQL = "insert into Cliente " + // " Values(" // + C.pIdCliente + ",'" // + C.pNombreApellido + "','" // + C.pDireccion + "'," // + C.pTelFijo + "," // + C.pTelCel + ",'" // + C.pCorreo + "'," // + C.pNroDoc + "," // + C.pSexo + ",'" // + C.pFechaNac + "')"; //oDato.actualizarBd(consultaSQL); //cargarLista("Cliente"); oDato.conectar(); oDato.pComando.CommandText = "INSERT INTO Cliente VALUES(" + "?,?,?,?,?,?,?,?,?,?,?,?)"; oDato.pComando.Parameters.Clear(); oDato.pComando.Parameters.AddWithValue("idClie", C.pIdCliente); oDato.pComando.Parameters.AddWithValue("apell", C.pApellido); oDato.pComando.Parameters.AddWithValue("nom", C.pNombre); oDato.pComando.Parameters.AddWithValue("direc", C.pDireccion); oDato.pComando.Parameters.AddWithValue("fijo", C.pTelFijo); oDato.pComando.Parameters.AddWithValue("cel", C.pTelCel); oDato.pComando.Parameters.AddWithValue("correo", C.pCorreo); oDato.pComando.Parameters.AddWithValue("tipoDoc", C.pTipoDoc); oDato.pComando.Parameters.AddWithValue("nroDoc", C.pNroDoc); oDato.pComando.Parameters.AddWithValue("sexo", C.pSexo); oDato.pComando.Parameters.AddWithValue("fNac", C.pFechaNac); oDato.pComando.Parameters.AddWithValue("estado", C.pEstado); oDato.pComando.ExecuteNonQuery(); oDato.desconectar(); nuevo = false; limpiar(); cargarLista("Cliente"); habilitar(false); lstCliente.SelectedIndex = -1; } else { MessageBox.Show("El código que intenta cargar ya existe. Intente uno diferente", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Hand); txtIdCliente.SelectAll(); txtIdCliente.Focus(); } } else { //consultaSQL = "update Cliente set nombreApellido= '" + C.pNombreApellido + "'," // + "direccion='" + C.pDireccion + "'," // + "telefonoFijo=" + C.pTelFijo + "," // + "telefonoCelular=" + C.pTelCel + "," // + "correo='" + C.pCorreo + "'," // + "numeroDocumento= " + C.pNroDoc + "," // + "sexo=" + C.pSexo + "," // + "fechaNacimiento=" + C.pFechaNac + ","; ////+ "where codigo=" + C.pIdCliente; //oDato.actualizarBd(consultaSQL); //cargarLista("Cliente"); int pos = lstCliente.SelectedIndex; oDato.conectar(); oDato.pComando.CommandText = "UPDATE Cliente SET apellido=?,nombre=?,direccion=?," + "telefonoFijo=?,telefonoCelular=?,correo=?,idTipoDocumento=?," + "documento=?,sexo=?,fechaNac=?,estado=? " + "WHERE idCliente=?"; oDato.pComando.Parameters.Clear(); oDato.pComando.Parameters.AddWithValue("apell", C.pApellido); oDato.pComando.Parameters.AddWithValue("nom", C.pNombre); oDato.pComando.Parameters.AddWithValue("direc", C.pDireccion); oDato.pComando.Parameters.AddWithValue("fijo", C.pTelFijo); oDato.pComando.Parameters.AddWithValue("cel", C.pTelCel); oDato.pComando.Parameters.AddWithValue("correo", C.pCorreo); oDato.pComando.Parameters.AddWithValue("tipoDoc", C.pTipoDoc); oDato.pComando.Parameters.AddWithValue("nroDoc", C.pNroDoc); oDato.pComando.Parameters.AddWithValue("sexo", C.pSexo); oDato.pComando.Parameters.AddWithValue("fNac", C.pFechaNac); oDato.pComando.Parameters.AddWithValue("estado", C.pEstado); oDato.pComando.Parameters.AddWithValue("idClie", C.pIdCliente); oDato.pComando.ExecuteNonQuery(); oDato.desconectar(); limpiar(); cargarLista("Cliente"); habilitar(false); lstCliente.SelectedIndex = pos; } } } }
private void btnGrabar_Click(object sender, EventArgs e) { if (Validar()) { //string consultaSQL = ""; Mascota m = new Mascota(); m.pIdMascota = Convert.ToInt32(txtCodigo.Text); m.pNombre = txtNombre.Text; m.pTipoMascota = Convert.ToInt32(cboTipoMascota.SelectedValue); m.pRaza = Convert.ToInt32(cboRaza.SelectedValue); m.pFechaNac = dtpFechaNac.Value; if (rbtMacho.Checked) { m.pSexo = true; } else { m.pSexo = false; } m.pObservacion = txtObservacion.Text; m.pPeso = Convert.ToInt32(txtPeso.Text); if (cboDuenio.SelectedIndex >= 0) { m.pIdCliente = Convert.ToInt32(cboDuenio.SelectedValue); } if (chkEstado.Checked) { m.pEstado = true; } else { m.pEstado = false; } DialogResult opcion = MessageBox.Show("¿Desea grabar la Mascota?", "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (opcion == DialogResult.Yes) { if (nuevo) { if (!existe(m.pIdMascota)) { //consultaSQL = "INSERT INTO Mascota (idMascota,idCliente,nombre,idTipoMascota,sexo," // + "idRaza,fechaNacimiento,peso,observacion,estado) VALUES (" // + m.pIdMascota + "," // + m.pIdCliente + ",'" // + m.pNombre + "'," // + m.pTipoMascota + "," // + m.pSexo + "," // + m.pRaza + ",#" // + m.pFechaNac + "#," // + m.pPeso + ",'" // + m.pObservacion + "'," // + m.pEstado +")"; //adm.actualizarBD(consultaSQL); //cargarLista("Mascota"); adm.conectar(); adm.pComando.CommandText = "INSERT INTO Mascota (idMascota,idCliente,nombre,idTipoMascota," + "sexo,idRaza,fechaNacimiento,peso,observacion,estado) " + "VALUES (?,?,?,?,?,?,?,?,?,?)"; adm.pComando.Parameters.Clear(); adm.pComando.Parameters.AddWithValue("idMasc", m.pIdMascota); adm.pComando.Parameters.AddWithValue("idClien", m.pIdCliente); adm.pComando.Parameters.AddWithValue("nombre", m.pNombre); adm.pComando.Parameters.AddWithValue("tipoMasc", m.pTipoMascota); adm.pComando.Parameters.AddWithValue("sexo", m.pSexo); adm.pComando.Parameters.AddWithValue("raza", m.pRaza); adm.pComando.Parameters.AddWithValue("fecNac", m.pFechaNac); adm.pComando.Parameters.AddWithValue("peso", m.pPeso); adm.pComando.Parameters.AddWithValue("obs", m.pObservacion); adm.pComando.Parameters.AddWithValue("estado", m.pEstado); adm.pComando.ExecuteNonQuery(); adm.desconectar(); nuevo = false; limpiar(); cargarLista("Mascota"); habilitar(false); lstMascotas.SelectedIndex = -1; } else { MessageBox.Show("El código que intenta cargar ya existe. Intente uno diferente", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Hand); txtCodigo.SelectAll(); } } else { //consultaSQL = "UPDATE Mascota SET Nombre='" + m.pNombre + "'," // + "idCliente=" + m.pIdCliente + "," // + "idTipoMascota=" + m.pTipoMascota + "," // + "sexo=" + m.pSexo + "," // + "idRaza=" + m.pRaza + "," // + "fechaNacimiento=#" + m.pFechaNac + "#," // + "peso=" + m.pPeso + "," // + "Observacion='" + m.pObservacion + "', " // + "estado="+ m.pEstado // + " WHERE idMascota=" + m.pIdMascota; //adm.actualizarBD(consultaSQL); //cargarLista("Mascota"); adm.conectar(); adm.pComando.CommandText = "UPDATE Mascota SET idCliente=?,nombre=?,idTipoMascota=?," + "sexo=?,idRaza=?,fechaNacimiento=?,peso=?," + "Observacion=?,estado=? " + "WHERE idMascota=?"; adm.pComando.Parameters.Clear(); adm.pComando.Parameters.AddWithValue("idClien", m.pIdCliente); adm.pComando.Parameters.AddWithValue("nombre", m.pNombre); adm.pComando.Parameters.AddWithValue("tipoMasc", m.pTipoMascota); adm.pComando.Parameters.AddWithValue("sexo", m.pSexo); adm.pComando.Parameters.AddWithValue("raza", m.pRaza); adm.pComando.Parameters.AddWithValue("fecNac", m.pFechaNac); adm.pComando.Parameters.AddWithValue("peso", m.pPeso); adm.pComando.Parameters.AddWithValue("obs", m.pObservacion); adm.pComando.Parameters.AddWithValue("estado", m.pEstado); adm.pComando.Parameters.AddWithValue("idMasc", m.pIdMascota); adm.pComando.ExecuteNonQuery(); adm.desconectar(); limpiar(); cargarLista("Mascota"); habilitar(false); lstMascotas.SelectedIndex = -1; } } } }
private void btnGrabar_Click(object sender, EventArgs e) { if (validar()) { //string comandoSQL = ""; Producto p = new Producto(); p.pIdProducto = Convert.ToInt32(txtCod.Text); p.pIdMarca = Convert.ToInt32(cboMarca.SelectedValue); p.pNomProducto = txtProducto.Text; p.pPrecio_unitario = Convert.ToDouble(txtPrecio.Text); p.pStock = Convert.ToInt32(txtStock.Text); p.pActivo = chkActivo.Checked; DialogResult opcion = MessageBox.Show("¿Desea grabar el Producto?", "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (opcion == DialogResult.Yes) { if (esNuevo) { if (!existe(Convert.ToInt32(txtCod.Text))) { //INSERT DEL NUEVO PRODUCTO //comandoSQL = "INSERT INTO Producto VALUES(" // + p.pIdProducto + "," // + p.pIdMarca + ",'" // + p.pNomProducto + "'," // + Convert.ToString(p.pPrecio_unitario) + "," // + p.pStock + "," // + p.pActivo + ")"; //oDato.actualizarBD(comandoSQL); oDato.conectar(); oDato.pComando.CommandText = "INSERT INTO Producto VALUES(?,?,?,?,?,?)"; oDato.pComando.Parameters.Clear(); oDato.pComando.Parameters.AddWithValue("idProd", p.pIdProducto); oDato.pComando.Parameters.AddWithValue("idMarca", p.pIdMarca); oDato.pComando.Parameters.AddWithValue("descripcion", p.pNomProducto); oDato.pComando.Parameters.AddWithValue("precio", p.pPrecio_unitario); oDato.pComando.Parameters.AddWithValue("stock", p.pStock); oDato.pComando.Parameters.AddWithValue("activo", p.pActivo); oDato.pComando.ExecuteNonQuery(); oDato.desconectar(); esNuevo = false; limpiarCampos(); cargarLista(lstProductos, "Producto"); habilitar(false); lstProductos.SelectedIndex = (cont - 1); } else { txtCod.SelectAll(); txtCod.Focus(); } } else { //UPDATE DEL PRODUCTO SELECCIONADO //comandoSQL = "UPDATE Producto SET idMarca=" + p.pIdMarca + "," // + "descripcion='" + p.pNomProducto + "'," // + "precio=" + p.pPrecio_unitario + "," // + "stock=" + p.pStock + " " // + "WHERE idProducto=" + p.pIdProducto; //oDato.actualizarBD(comandoSQL); int pos = lstProductos.SelectedIndex; oDato.conectar(); oDato.pComando.CommandText = "UPDATE Producto SET idMarca=?,descripcion=?,precio=?,stock=? " + "WHERE idProducto=?"; oDato.pComando.Parameters.Clear(); oDato.pComando.Parameters.AddWithValue("idMarca", p.pIdMarca); oDato.pComando.Parameters.AddWithValue("descripcion", p.pNomProducto); oDato.pComando.Parameters.AddWithValue("precio", p.pPrecio_unitario); oDato.pComando.Parameters.AddWithValue("stock", p.pStock); oDato.pComando.Parameters.AddWithValue("idProd", p.pIdProducto); oDato.pComando.ExecuteNonQuery(); oDato.desconectar(); limpiarCampos(); cargarLista(lstProductos, "Producto"); habilitar(false); lstProductos.SelectedIndex = pos; } } } }