public void cargarComboBox(object sender, EventArgs e, ComboBox cmbx, string consulta) { // 27/10/2019 Autor: Victor Fernandez // Este metodo carga los resultados de una columna (de uan consulta) al // combobox pasado como parametro try { ConectarServidor cn = new ConectarServidor(); string comando = consulta; OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { cmbx.Items.Add(queryResultsReader.GetString(0)); } cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error MessageBox.Show(ex.Message); } }
public string[] ObtenerProgresoFromListBox(ListBox Lst_datos_grafica, ComboBox Cbo_seleccion) { /* Autor: Victor Fernandez * Fecha: 28/10/2019 * * Descripcion: Funcion para mover obtener el progreso de avance de * cada item en la lista. * ... * */ string[] datos_grafica = Lst_datos_grafica.Items.OfType <string>().ToArray(); /* Cambiarlo, hacerlo dinamico*/ string[] progreso = new string[2500]; int itemsTotal = Lst_datos_grafica.Items.Count; /* Obteniendo el progreso por cada item en Lst_datos_grafica y guardandolo * en un arreglo */ for (int i = 0; i < datos_grafica.Length; i++) { try { ConectarServidor miConexion = new ConectarServidor(); string sentencia = "SELECT Progreso FROM " + ObtenerNombreTabla(Cbo_seleccion) + " WHERE Nombre = " + "'" + Convert.ToString(Lst_datos_grafica.Items[i]) + "'"; OdbcCommand comando = new OdbcCommand(sentencia, miConexion.Conexion()); OdbcDataReader lector_query = comando.ExecuteReader(); while (lector_query.Read()) { progreso[i] = lector_query.GetString(0); } miConexion.CerrarConexion(); } catch (Exception ex) { MessageBox.Show(ex.Message); MessageBox.Show("Error ObtenerProgresoFromListBox"); } } return(progreso); }
public int contarObjetivos(int idDominio) { /* Autor: Victor Fernandez * Fecha: 27/10/2019 * * Descripcion: Funcion para devolver el numero de objetivos dependiendo * el dominio seleccionado * ... * */ int totalObjetivos = 0; try { ConectarServidor cn = new ConectarServidor(); string comando = "SELECT COUNT(Nombre) FROM tbl_objetivo " + "WHERE tbl_dominio_PK_Id_dominio = " + Convert.ToString(idDominio); OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { // Conviertiendo el resultado a entero para poder enviarlo en el return totalObjetivos = Convert.ToInt32(queryResultsReader.GetString(0)); } cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error MessageBox.Show(ex.Message); MessageBox.Show("Error ContarObjetivos"); } return(totalObjetivos); }
private void dg_Cotizacion_CellEndEdit(object sender, DataGridViewCellEventArgs e) { double total = 0; int n = e.RowIndex; int m = e.ColumnIndex; double cantidadENBD = 0; double coddd = 0; coddd = Convert.ToDouble(dg_Cotizacion.Rows[n].Cells[0].Value); double cantidadSeleccionada = 0; cantidadSeleccionada = Convert.ToDouble(dg_Cotizacion.Rows[n].Cells[m].Value); // MessageBox.Show("cantidadEscrita: " + codigoACTUAL); try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarVideoCodigo"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@codigo", coddd); MySqlDataReader reader = sql.ExecuteReader(); while (reader.Read() == true) { cantidadENBD = Convert.ToDouble(reader.GetString(3)); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (cantidadSeleccionada <= cantidadENBD) { foreach (DataGridViewRow row in dg_Cotizacion.Rows) { double cantidad = Convert.ToDouble(row.Cells["CantidadCotizacion"].Value); double sub = Convert.ToDouble(row.Cells["PrecioCotizacion"].Value); total = cantidad * sub; row.Cells["SubTotalCotizacion"].Value = total; } double suma = 0; double iva = 0; double total2 = 0; double valor = 0; foreach (DataGridViewRow row in dg_Cotizacion.Rows) { valor = Convert.ToDouble(row.Cells["SubtotalCotizacion"].Value); suma += valor; } txt_subTotal.Text = Convert.ToString(suma); iva = suma * 0.12; total2 = iva + suma; txt_iva.Text = Convert.ToString(iva); txt_totalAPagar.Text = Convert.ToString(total2); } else { MessageBox.Show("Existencias sobre pasadas, se colocó la cantidad maxima registrada"); dg_Cotizacion.Rows[n].Cells[m].Value = cantidadENBD; foreach (DataGridViewRow row in dg_Cotizacion.Rows) { double cantidad = Convert.ToDouble(row.Cells["CantidadCotizacion"].Value); double sub = Convert.ToDouble(row.Cells["PrecioCotizacion"].Value); total = cantidad * sub; row.Cells["SubTotalCotizacion"].Value = total; } double suma = 0; double iva = 0; double total2 = 0; double valor = 0; foreach (DataGridViewRow row in dg_Cotizacion.Rows) { valor = Convert.ToDouble(row.Cells["SubtotalCotizacion"].Value); suma += valor; } txt_subTotal.Text = Convert.ToString(suma); iva = suma * 0.12; total2 = iva + suma; txt_iva.Text = Convert.ToString(iva); txt_totalAPagar.Text = Convert.ToString(total2); } }
private void llenarGrid() { try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarVideoCategoria"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; int indCategoria = categoriaVideo.SelectedIndex + 1; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@codigo", indCategoria); MySqlDataReader reader = sql.ExecuteReader(); while (reader.Read() == true) { DataGridViewRow filas = new DataGridViewRow(); filas.CreateCells(dgv_Peliculas); filas.Cells[0].Value = reader.GetString(0); filas.Cells[1].Value = reader.GetString(1); filas.Cells[2].Value = reader.GetString(3); filas.Cells[3].Value = reader.GetString(7); dgv_Peliculas.Rows.Add(filas); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void frmFactura_Load(object sender, EventArgs e) { autocompletarcodigo(); txtIva.Text = "0.12%"; txtVendedor.Text = user; DateTime fecha = DateTime.Now; txtFecha.Text = fecha.ToString(); try { MySqlCommand sql = new MySqlCommand(String.Format("Select * from FormaDePago"), ConectarServidor.conexion()); MySqlDataAdapter da = new MySqlDataAdapter(sql); DataSet ds = new DataSet(); da.Fill(ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { cbo_formasPago.Items.Add(ds.Tables[0].Rows[i][0] + " | " + ds.Tables[0].Rows[i][1]); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } try { MySqlCommand sql = new MySqlCommand(String.Format("Select * from Videos"), ConectarServidor.conexion()); MySqlDataAdapter da = new MySqlDataAdapter(sql); DataSet ds = new DataSet(); da.Fill(ds); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { cobVideo.Items.Add(ds.Tables[0].Rows[i][0] + " | " + ds.Tables[0].Rows[i][1]); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } try { MySqlCommand sql = new MySqlCommand(String.Format("SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME='Encabezado_Factura'"), ConectarServidor.conexion()); MySqlDataReader dr = sql.ExecuteReader(); if (dr.Read() == true) { txtNo.Text = dr.GetString(0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button1_Click(object sender, EventArgs e) { if (txt_disponible.Text != "0") { try { MySqlCommand sql = new MySqlCommand(String.Format("pd_InsertaDetalleRenta"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; sql.Parameters.AddWithValue("@nombre", txt_nombrePelicula.Text); sql.Parameters.AddWithValue("@idrenta", lblidRenta.Text); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } txt_codigo.Clear(); txt_directorPelicula.Clear(); txt_actor.Clear(); txt_disponible.Clear(); txt_formato.Clear(); txt_descripcionPelicula.Clear(); txtAño.Clear(); txt_precioRenta.Clear(); txtGenero.Clear(); txtDuracion.Clear(); txt_nombrePelicula.Clear(); } }
private void obtenerCodigoCotizacion() { txtCodigoCotizacion.Clear(); double codcotsum = 0; try { MySqlCommand cm = new MySqlCommand("Select Id_Cotizacion from Cotizacion_Encabezado", ConectarServidor.conexion()); MySqlDataReader almacena = cm.ExecuteReader(); if (almacena.Read()) { while (almacena.Read()) { } codcotsum = Convert.ToDouble(almacena.GetValue(0)) + 1; txtCodigoCotizacion.Text = codcotsum.ToString(); } else { txtCodigoCotizacion.Text = "1"; } // } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void ConsultaMembresia() { try { MySqlCommand sql3 = new MySqlCommand(String.Format("pd_BuscarMembresia"), ConectarServidor.conexion()); sql3.CommandType = CommandType.StoredProcedure; sql3.Parameters.AddWithValue("@codigo", txtMembresia.Text); MySqlDataReader reader3 = sql3.ExecuteReader(); if (reader3.Read() == true) { txtNit.Text = reader3.GetString(0); try { MySqlCommand sql2 = new MySqlCommand(String.Format("pd_BuscarClienteCodigo"), ConectarServidor.conexion()); sql2.CommandType = CommandType.StoredProcedure; sql2.Parameters.AddWithValue("@codigo", txtNit.Text); MySqlDataReader reader2 = sql2.ExecuteReader(); if (reader2.Read() == true) { txt_nombreCliente.Text = (reader2.GetString(1) + " " + reader2.GetString(2)); txt_direccionCliente.Text = reader2.GetString(4); txt_telefonoCliente.Text = reader2.GetString(7); } reader2.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } MessageBox.Show("Cliente encontrado"); } else { txtNit.Clear(); txt_nombreCliente.Clear(); txt_direccionCliente.Clear(); txt_telefonoCliente.Clear(); MessageBox.Show("La membresia no existe"); } reader3.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void Frm_ActivosFijosGrid_Load(object sender, EventArgs e) { try { OdbcCommand InfActivos = new OdbcCommand(string.Format("Select * From tbl_detalle_activos"), ConectarServidor.conexion()); OdbcDataAdapter da = new OdbcDataAdapter(InfActivos); DataSet ds = new DataSet(); da.Fill(ds); Dgv_Activos.DataSource = ds.Tables[0]; Dgv_Activos.DataSource = ds.Tables[1]; Dgv_Activos.DataSource = ds.Tables[2]; Dgv_Activos.DataSource = ds.Tables[3]; Dgv_Activos.DataSource = ds.Tables[4]; Dgv_Activos.DataSource = ds.Tables[5]; } catch (Exception) { } }
private void Cbo_seleccion_SelectedIndexChanged(object sender, EventArgs e) { /* Autor: Victor Fernandez * Fecha: 28/10/2019 * Modiciacion: Sebastian Recinos * Fecha: 30/10/2019 * Descripcion: LLena Lst_datos_a_elegir con los datos de la * opcion seleccionada en el combobox Cbo_seleccion * ... */ Lst_datos_grafica.Items.Clear(); /*if (Cbo_seleccion.SelectedIndex == 0) * { * // Si la opcion normativa es seleccionada, mostrar todas las normativas almacenadas * * // Borrando datos anteriores del listbox * Lst_datos_a_elegir.Items.Clear(); * Lst_datos_grafica.Items.Clear(); * * try * { * ConectarServidor cn = new ConectarServidor(); * string comando = "SELECT Nombre FROM tbl_normativa"; * * OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); * OdbcDataReader queryResultsReader = command.ExecuteReader(); * * while (queryResultsReader.Read()) * { * * Lst_datos_a_elegir.Items.Add(queryResultsReader.GetString(0)); * } * * cn.CerrarConexion(); * * } * catch (Exception ex) * { * // Mostrando mensaje que indica el error * MessageBox.Show(ex.Message); * } * * }*/ if (Cbo_seleccion.SelectedIndex == 0) { // Si la opcion dominio es seleccionada, mostrar todos los dominios // Borrando datos anteriores del listbox Lst_datos_a_elegir.Items.Clear(); Lst_datos_grafica.Items.Clear(); try { ConectarServidor cn = new ConectarServidor(); string comando = "SELECT Nombre FROM tbl_dominio"; OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { Lst_datos_a_elegir.Items.Add(queryResultsReader.GetString(0)); } cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error MessageBox.Show(ex.Message); } } else if (Cbo_seleccion.SelectedIndex == 1) { // Si la opcion objetivos es seleccionada, mostrar todos los objetivos // Borrando datos anteriores del listbox Lst_datos_a_elegir.Items.Clear(); Lst_datos_grafica.Items.Clear(); try { ConectarServidor cn = new ConectarServidor(); string comando = "SELECT Nombre FROM tbl_objetivo"; OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { Lst_datos_a_elegir.Items.Add(queryResultsReader.GetString(0)); } cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error MessageBox.Show(ex.Message); } } else if (Cbo_seleccion.SelectedIndex == 2) { // Si la opcion subobjetivo es seleccionada, mostrar todos los subobjetivos // Borrando datos anteriores del listbox Lst_datos_a_elegir.Items.Clear(); Lst_datos_grafica.Items.Clear(); try { ConectarServidor cn = new ConectarServidor(); string comando = "SELECT Nombre FROM tbl_subobjetivo"; OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { Lst_datos_a_elegir.Items.Add(queryResultsReader.GetString(0)); } cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error MessageBox.Show(ex.Message); } } }
private void Frm_ActivosFijos_Load(object sender, EventArgs e) { /*inicializacion de los componentes del formulario en el cual algunos deben de aparecer desahilitados, ya que * la inforacion que se menaja en los mismos no puede ser alterada */ Dtp_FecAct.Enabled = false; Cbo_PerDep.Enabled = false; Cbo_PerAmort.Enabled = false; Chk_AmortDigitosDecrecientes.Enabled = false; Chk_AmortLineal.Enabled = false; Txt_PersonaEncargada.Enabled = false; Chk_DepLineaRecta.Enabled = false; Chk_DepSumDigAnual.Enabled = false; Chk_DepPorcentual.Enabled = false; Chk_AmortPorcentual.Enabled = false; //Aqui se cargan los datos de la tabla tbl_tipo_activo a el combobox de tipo de activo , desplegando todos los tipos de activos existentes try { OdbcCommand TipoActivos = new OdbcCommand(String.Format("SELECT Nombre_tipoactivo FROM tbl_tipo_activo"), ConectarServidor.conexion()); OdbcDataAdapter da1 = new OdbcDataAdapter(TipoActivos); DataSet ds1 = new DataSet(); da1.Fill(ds1); for (int i = 0; i < ds1.Tables[0].Rows.Count; i++) { Cbo_TipoActivo.Items.Add(ds1.Tables[0].Rows[i][0]); } } catch (Exception) { throw; } }
//ingresamos el codigo del empleado al que se le asginara el activo y se buscara en la base de datos para luego ser asignado private void button1_Click_2(object sender, EventArgs e) { if (Txt_NumInventario.Text == "" && Txt_CodEmpleado.Text == "") { MessageBox.Show("Favor Llenar los campos requeridos"); } try { OdbcCommand noencargado = new OdbcCommand(String.Format("SELECT Nombre FROM tbl_empleados Where " + Txt_CodEmpleado.Text + "= ID_Empleado"), ConectarServidor.conexion()); OdbcDataReader leer; leer = noencargado.ExecuteReader(); while (leer.Read() == true) { Txt_PersonaEncargada.Text = leer["Nombre"].ToString(); } } catch (Exception) { MessageBox.Show("El empleado no existe"); } }
public void CalcularAvanceDominios(ListBox datos_a_graficar) { /* Autor: Victor Fernandez * Fecha: 29/10/2019 * Descripcion: Funcion para calcular el avance de dominios */ int numeroDominio = 0; int numeroDeDatosAGraficar = datos_a_graficar.Items.Count; double valorPorcentual = 0; double avanceDominio = 0; for (int i = 0; i < numeroDeDatosAGraficar; i++) { try { // Reiniciando el avance para poder calcular el siguiente avance avanceDominio = 0; ConectarServidor cn = new ConectarServidor(); // Obteniendo el valor porcentual de cada subobjetivo // Obteniedo el numero de subobjetivos de cada objetivo string comando_obtener_id_dominio = "SELECT PK_Id_dominio FROM tbl_dominio " + " WHERE Nombre = " + "'" + datos_a_graficar.Items[i] + "'"; OdbcCommand command = new OdbcCommand(comando_obtener_id_dominio, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { // Numero de subobjetivos numeroDominio = (Convert.ToInt32(queryResultsReader.GetString(0))); } cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error MessageBox.Show(ex.Message); MessageBox.Show("CalcularAvanceDominios"); } try { ConectarServidor cn = new ConectarServidor(); valorPorcentual = calcularValorPorcentualObjetivo(numeroDominio); string comando = "SELECT Progreso FROM tbl_objetivo " + "WHERE tbl_dominio_PK_Id_dominio = " + "(SELECT PK_Id_dominio FROM tbl_dominio " + "WHERE Nombre = " + "'" + datos_a_graficar.Items[i] + "')"; // Sumando el valor de cada subobjetivo perteneciente al respectivo objetivo OdbcCommand command = new OdbcCommand(comando, cn.Conexion()); OdbcDataReader queryResultsReader = command.ExecuteReader(); while (queryResultsReader.Read()) { avanceDominio += (Convert.ToDouble(queryResultsReader.GetString(0)) / 100) * valorPorcentual; } comando = "UPDATE tbl_dominio " + " SET Progreso = " + Convert.ToString(avanceDominio) + " WHERE Nombre = " + "'" + datos_a_graficar.Items[i] + "'"; command = new OdbcCommand(comando, cn.Conexion()); queryResultsReader = command.ExecuteReader(); cn.CerrarConexion(); } catch (Exception ex) { // Mostrando mensaje que indica el error //MessageBox.Show(ex.Message); //MessageBox.Show("CalcularAvanceObjetivos2"); } } }
private void btEnviar_Click(object sender, EventArgs e) { try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_InsertarCotizacionEncabezado"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@Fecha_Cotizacion", txtFecha.Text); sql.Parameters.AddWithValue("@Id_Cliente", txtMembresia.Text); sql.Parameters.AddWithValue("@Id_Empleado", "1"); sql.Parameters.AddWithValue("@Total", txt_totalAPagar.Text); sql.ExecuteNonQuery(); foreach (DataGridViewRow row in dg_Cotizacion.Rows) { double cantidad = Convert.ToDouble(row.Cells["CantidadCotizacion"].Value); double codigoo = Convert.ToDouble(row.Cells["codigoCotizacion"].Value); double sub = Convert.ToDouble(row.Cells["SubTotalCotizacion"].Value); try { //nombre del procedimiento MySqlCommand sql2 = new MySqlCommand(String.Format("pd_InsertarDetalleCotizacion"), ConectarServidor.conexion()); sql2.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql2.Parameters.AddWithValue("@Id_Cotizacion", txtCodigoCotizacion.Text); sql2.Parameters.AddWithValue("@Id_Video", codigoo.ToString()); sql2.Parameters.AddWithValue("@Cantidad", cantidad.ToString()); sql2.Parameters.AddWithValue("@SubTotal", sub.ToString()); sql2.ExecuteNonQuery(); } catch (Exception ex) { MessageBox.Show("el detalle NO SE PUDO GENERAR! " + ex); } string nombreArchivo = "cotizacion" + txtCodigoCotizacion.Text + ".png"; using (Bitmap bmp = CaptureControl(panel6)) { bmp.Save(nombreArchivo, ImageFormat.Png); } } // limpiarText(); // obtenerCodigoCotizacion(); MessageBox.Show("COTIZACION GENERADA CORRECTAMENTE!"); } catch (Exception ex) { MessageBox.Show("LA COTIZACION NO SE PUDO GENERAR!" + ex); } }
private void obtenerCategorias() { try { MySqlCommand cmc = new MySqlCommand("Select Categoria from Categoria_Video", ConectarServidor.conexion()); MySqlDataReader almacenac = cmc.ExecuteReader(); while (almacenac.Read()) { categoriaVideo.Refresh(); categoriaVideo.Items.Add(almacenac.GetValue(0).ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button47_Click(object sender, EventArgs e) { double suma = 0; foreach (DataGridViewRow row in dgv_Peliculas.Rows) { double valor = Convert.ToDouble(row.Cells["subtotal"].Value); suma += valor; } txtTotal.Text = Convert.ToString(suma); string cod = cbo_formasPago.SelectedItem.ToString(); cod = cod.Substring(0, cod.IndexOf(" ")); try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_InsertarEncabezadoFactura"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@fecha", txtFecha.Text); sql.Parameters.AddWithValue("@idMembresia", txtMembresia.Text); sql.Parameters.AddWithValue("@nit", txt_Nit.Text); sql.Parameters.AddWithValue("@pago", cod); sql.Parameters.AddWithValue("@vendedor", txtVendedor.Text); sql.Parameters.AddWithValue("@total", txtTotal.Text); sql.ExecuteNonQuery(); MessageBox.Show("FACTURA GENERADA CORRECTAMENTE!"); } catch (Exception ex) { MessageBox.Show("LA FACTURA NO SE PUDO GENERAR!"); } this.Hide(); menuPrincipal menu = new menuPrincipal(user); menu.Show(); }
private void gridConsultaCotizacion() { double suma = 0; double iva = 0; double total = 0; try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarIdCotizacionDetalle"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@codigo", txtCodigoCotizacion.Text); MySqlDataReader reader = sql.ExecuteReader(); while (reader.Read() == true) { DataGridViewRow filas = new DataGridViewRow(); filas.CreateCells(dg_Cotizacion); filas.Cells[0].Value = reader.GetString(0); // filas.Cells[1].Value = reader.GetString(1); filas.Cells[2].Value = reader.GetString(1); filas.Cells[4].Value = reader.GetString(3); dg_Cotizacion.Rows.Add(filas); } reader.Close(); double total2 = 0; foreach (DataGridViewRow row in dg_Cotizacion.Rows) { double cantidad = Convert.ToDouble(row.Cells["CantidadCotizacion"].Value); double sub = Convert.ToDouble(row.Cells["SubTotalCotizacion"].Value); total2 = sub / cantidad; row.Cells["PrecioCotizacion"].Value = total2; double valor = Convert.ToDouble(row.Cells["SubtotalCotizacion"].Value); suma += valor; double codC = Convert.ToDouble(row.Cells["codigoCotizacion"].Value); try { //nombre del procedimiento MySqlCommand sql3 = new MySqlCommand(String.Format("pd_BuscarVideoCodigo"), ConectarServidor.conexion()); sql3.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql3.Parameters.AddWithValue("@codigo", codC); MySqlDataReader reader3 = sql3.ExecuteReader(); while (reader3.Read() == true) { row.Cells["nombreVideoCotizacion"].Value = reader3.GetString(1); } reader3.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } iva = suma * 0.12; txt_subTotal.Text = Convert.ToString(suma); total = iva + suma; txt_iva.Text = Convert.ToString(iva); txt_totalAPagar.Text = Convert.ToString(total); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btBusqueda_Click(object sender, EventArgs e) { try { MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarMembresia"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; sql.Parameters.AddWithValue("@codigo", txtMembresia.Text); MySqlDataReader reader = sql.ExecuteReader(); if (reader.Read() == true) { txt_Nit.Text = reader.GetString(0); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } try { MySqlCommand sql2 = new MySqlCommand(String.Format("pd_BuscarClienteCodigo"), ConectarServidor.conexion()); sql2.CommandType = CommandType.StoredProcedure; sql2.Parameters.AddWithValue("@codigo", txt_Nit.Text); MySqlDataReader reader2 = sql2.ExecuteReader(); if (reader2.Read() == true) { txt_nombreCliente.Text = (reader2.GetString(1) + " " + reader2.GetString(2)); txt_direccion.Text = reader2.GetString(4); } reader2.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void btConsulta_Click(object sender, EventArgs e) { // char fecharestringida= [9]; limpiarText(); try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarMembresiaCotizacion"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@codigo", txtCodigoCotizacion.Text); MySqlDataReader reader = sql.ExecuteReader(); while (reader.Read() == true) { txtFecha.Text = reader.GetString(1); txtMembresia.Text = reader.GetString(2); txt_totalAPagar.Text = reader.GetString(4); } reader.Close(); ConsultaMembresia(); gridConsultaCotizacion(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void button2_Click(object sender, EventArgs e) { string cod = cobVideo.SelectedItem.ToString(); cod = cod.Substring(0, cod.IndexOf(" ")); try { //nombre del procedimiento MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarVideoCodigo"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; //nombre de los parametros que recibe el procedimiento sql.Parameters.AddWithValue("@codigo", int.Parse(cod)); MySqlDataReader reader = sql.ExecuteReader(); if (reader.Read() == true) { DataGridViewRow filas = new DataGridViewRow(); filas.CreateCells(dgv_Peliculas); filas.Cells[0].Value = reader.GetString(0); filas.Cells[1].Value = reader.GetString(1); filas.Cells[2].Value = txtCantidad.Text; filas.Cells[3].Value = reader.GetString(7); double subTotal = double.Parse(txtCantidad.Text) * double.Parse(reader.GetString(7)); filas.Cells[4].Value = subTotal; dgv_Peliculas.Rows.Add(filas); } reader.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } txtCantidad.Clear(); }
private void btn_buscar_Click(object sender, EventArgs e) { try { MySqlCommand sql = new MySqlCommand(String.Format("SELECT AUTO_INCREMENT FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'Encabezado_Renta'"), ConectarServidor.conexion()); MySqlDataReader reader = sql.ExecuteReader(); if (reader.Read() == true) { lblidRenta.Text = reader.GetString(0); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } if (txt_nombrePelicula.Text == "") { try { MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarVideoCodigo"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; sql.Parameters.AddWithValue("@codigo", txt_codigo.Text); MySqlDataReader reader = sql.ExecuteReader(); if (reader.Read() == true) { txt_nombrePelicula.Text = reader.GetString(1); txt_directorPelicula.Text = reader.GetString(6); txt_actor.Text = reader.GetString(9); txt_disponible.Text = reader.GetString(3); txt_formato.Text = reader.GetString(8); txt_descripcionPelicula.Text = reader.GetString(2); txtAño.Text = reader.GetString(5); txt_precioRenta.Text = reader.GetString(7); txtGenero.Text = reader.GetString(4); txtDuracion.Text = reader.GetString(10); } else { MessageBox.Show("El Nombre que busca no se encontro."); txt_codigo.Clear(); txt_directorPelicula.Clear(); txt_actor.Clear(); txt_disponible.Clear(); txt_formato.Clear(); txt_descripcionPelicula.Clear(); txtAño.Clear(); txt_precioRenta.Clear(); txtGenero.Clear(); txtDuracion.Clear(); txt_nombrePelicula.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } else if (txt_codigo.Text == "") { try { MySqlCommand sql = new MySqlCommand(String.Format("pd_BuscarVideoNombre"), ConectarServidor.conexion()); sql.CommandType = CommandType.StoredProcedure; sql.Parameters.AddWithValue("@nombre", txt_nombrePelicula.Text); MySqlDataReader reader = sql.ExecuteReader(); if (reader.Read() == true) { txt_codigo.Text = reader.GetString(0); txt_directorPelicula.Text = reader.GetString(6); txt_actor.Text = reader.GetString(9); txt_disponible.Text = reader.GetString(3); txt_formato.Text = reader.GetString(8); txt_descripcionPelicula.Text = reader.GetString(2); txtAño.Text = reader.GetString(5); txt_precioRenta.Text = reader.GetString(7); txtGenero.Text = reader.GetString(4); txtDuracion.Text = reader.GetString(10); } else { MessageBox.Show("El Nombre que busca no se encontro."); txt_codigo.Clear(); txt_directorPelicula.Clear(); txt_actor.Clear(); txt_disponible.Clear(); txt_formato.Clear(); txt_descripcionPelicula.Clear(); txtAño.Clear(); txt_precioRenta.Clear(); txtGenero.Clear(); txtDuracion.Clear(); txt_nombrePelicula.Clear(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
public void autocompletarcodigo() { try { MySqlCommand sql = new MySqlCommand(String.Format("Select idMembresia from Membresia"), ConectarServidor.conexion()); MySqlDataReader dr = sql.ExecuteReader(); AutoCompleteStringCollection mycollection = new AutoCompleteStringCollection(); while (dr.Read() == true) { mycollection.Add(dr.GetString(0)); } txtMembresia.AutoCompleteCustomSource = mycollection; dr.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }