private void AltaProfesor_Load(object sender, EventArgs e) { sql = "Select * from localidades"; DataSet ds = new DataSet(); SqlConnection cx = new SqlConnection(); conexion c = new conexion(); //cx.ConnectionString = c.getCadena(); SqlDataAdapter da = new SqlDataAdapter(sql, cx); da.Fill(ds, "localidades"); cmbLocalidades.DataSource = ds.Tables[0].DefaultView; cmbLocalidades.DisplayMember ="nombre"; cmbLocalidades.ValueMember = "id_localidad"; // ----------------------------------------- sql = "Select * from deportes"; DataSet ds2 = new DataSet(); SqlDataAdapter da2 = new SqlDataAdapter(sql, cx); da2.Fill(ds2, "deportes"); cmbDeporte.DataSource = ds2.Tables[0].DefaultView; cmbDeporte.DisplayMember = "nombre"; cmbDeporte.ValueMember = "id_deporte"; }
private void btnCategoria_Click(object sender, EventArgs e) { id_deporte = Int32.Parse(cmbDeporte.SelectedValue.ToString()); sql = "Select * from CategoriasDeporte where id_deporte="+ id_deporte+""; DataSet ds4 = new DataSet(); SqlConnection cx = new SqlConnection(); conexion c = new conexion(); //cx.ConnectionString = c.getCadena(); SqlDataAdapter da4 = new SqlDataAdapter(sql, cx); da4.Fill(ds4, "CategoriasDeporte"); cmbCategoriaDeporte.DataSource = ds4.Tables[0].DefaultView; cmbCategoriaDeporte.DisplayMember = "nombre"; cmbCategoriaDeporte.ValueMember = "id_categoriaDeporte"; }
public int update(estilos estilo) { int a = 0; String query = "UPDATE estilos SET NomEstilo = @NomEstilo, Descripcíon = @Descripcíon, GeneroEstilo = @GeneroEstilo WHERE id_estilo = @id_estilo"; conn = new conexion(); SqlCommand command = conn.getConn().CreateCommand(); SqlTransaction trans = conn.getConn().BeginTransaction("simpleTrans"); try { command.Connection = conn.getConn(); command.CommandText = query; command.Transaction = trans; command.Parameters.Add("@id_estilo", SqlDbType.Int); command.Parameters["@id_estilo"].Value = estilo.Id_estilo; command.Parameters.Add("@NomEstilo", SqlDbType.VarChar, 50); command.Parameters.Add("@Descripcíon", SqlDbType.VarChar); command.Parameters.Add("@GeneroEstilo", SqlDbType.VarChar, 50); command.Parameters["@NomEstilo"].Value = estilo.NomEstilo1; command.Parameters["@Descripcíon"].Value = estilo.Descripcíon1; command.Parameters["@GeneroEstilo"].Value = estilo.GeneroEstilo1; command.ExecuteNonQuery(); trans.Commit(); a = 1; } catch (Exception e) { trans.Rollback(); } finally { conn.cerrar(); } return(a); }
public int update(cargos cargos) { int a = 0; String query = "UPDATE cargos SET NomCargo = @NomCargo, Salario = @Salario, DescripcionCargo = @DescripcionCargo WHERE id_cargo = @id_cargo"; conn = new conexion(); SqlCommand command = conn.getConn().CreateCommand(); SqlTransaction trans = conn.getConn().BeginTransaction("simpleTrans"); try { command.Connection = conn.getConn(); command.CommandText = query; command.Transaction = trans; command.Parameters.Add("@id_cargo", SqlDbType.Int); command.Parameters["@id_cargo"].Value = cargos.Id_cargo; command.Parameters.Add("@NomCargo", SqlDbType.VarChar, 50); command.Parameters["@NomCargo"].Value = cargos.NomCargo1; command.Parameters.Add("@Salario", SqlDbType.Decimal); command.Parameters["@Salario"].Value = cargos.Salario1; command.Parameters.Add("@DescripcionCargo", SqlDbType.Text); command.Parameters["@DescripcionCargo"].Value = cargos.DescripcionCargo1; command.ExecuteNonQuery(); trans.Commit(); a = 1; } catch (Exception e) { trans.Rollback(); } finally { conn.cerrar(); } return(a); }
protected void Page_Load(object sender, EventArgs e) { conexion conexionSQL = new conexion(); conexionSQL.conectar(); if (!Page.IsPostBack) { if (Request.QueryString["codi"] != null) { String codi = Request.QueryString["codi"]; conexionSQL.getAspectosAll(ref ddlAspectos); int resp = conexionSQL.verificarExistenciaBecario(codi); conexionSQL.desconectar(); if (resp <= 0) { Response.Redirect("PresupuestoBecario.aspx"); } } else { Response.Redirect("PresupuestoBecario.aspx"); } } }
public void verifica() { conexion con = new conexion(); con.Conectar(); try { con.consulta_log(text_user.Text, text_pas.Text); if (con.id.Equals("1")) { VentanaAdmin frm = new VentanaAdmin(); frm.Show(); this.Hide(); } if (con.id.Equals("2")) { VentanaUser frm = new VentanaUser(); frm.Show(); this.Hide(); } } catch { MessageBox.Show("Error al iniciar session"); text_user.Text = ""; text_pas.Text = ""; } con.Desconectar(); }
public void modificarCuenta(int documento, string tipo, string periodo) { List <EDocumentos> lstDoc = buscarDocumento(documento, tipo, periodo); double suma = 0; string debito = "debito" + periodo; string credito = "credito" + periodo; string saldo = "saldo" + periodo; string sql; int reg = 0; if (lstDoc.Count > 0) { using (conexion cnx = new conexion()) { cnx.cadena = Configuracion.Instanciar.conexionBD(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.Connection = cnx.getConexion(); if (cnx.abrirConexion()) { foreach (var item in lstDoc) { suma = item.debito - item.credito; sql = "UPDATE selpuc SET saldo=saldo - " + suma + ", " + saldo + "=" + saldo + " - " + suma + ", " + debito + "=" + debito + " - " + item.debito + ", " + credito + "=" + credito + " - " + item.credito + " " + " WHERE codigo='" + item.codigo + "'"; cmd.CommandText = sql; reg = cmd.ExecuteNonQuery(); } cnx.cerrarConexion(); } } } } }
public pedidos findById(int id_pedido) { pedidos pedido = null; String sqlString = "SELECT * FROM pedidos WHERE id_pedido = @id_pedido"; conn = new conexion(); SqlCommand command = new SqlCommand(sqlString, conn.getConn()); command.Parameters.Add("@id_pedido", SqlDbType.Int); command.Parameters["@id_pedido"].Value = id_pedido; SqlDataReader rd = command.ExecuteReader(); while (rd.Read()) { pedido.Id_pedido = rd.GetInt32(0); pedido.Viajeros = rd.GetInt32(1); pedido.Zapatos = rd.GetInt32(2); pedido.CantidadPedido1 = rd.GetInt32(3); pedido.CostoTotal1 = rd.GetDouble(4); } rd.Close(); conn.cerrar(); return(pedido); }
public int add(pedidos pedido) { int a = 0; conn = new conexion(); SqlTransaction tran; SqlCommand command = conn.getConn().CreateCommand(); tran = conn.getConn().BeginTransaction("simpleTransicion"); try { command.Connection = conn.getConn(); command.Transaction = tran; command.CommandText = "INSERT INTO pedidos(viajeros,zapatos,CantidadPedido,CostoTotal) VALUES(@viajeros,@zapatos,@CantidadPedido,@CostoTotal)"; command.Parameters.Add("@viajeros", SqlDbType.Int); command.Parameters.Add("@zapatos", SqlDbType.Int); command.Parameters.Add("@CantidadPedido", SqlDbType.Int); command.Parameters.Add("@CostoTotal", SqlDbType.Decimal); command.Parameters["@viajeros"].Value = pedido.Viajeros; command.Parameters["@zapatos"].Value = pedido.Zapatos; command.Parameters["@CantidadPedido"].Value = pedido.CantidadPedido1; command.Parameters["@CostoTotal"].Value = pedido.CostoTotal1; command.ExecuteNonQuery(); tran.Commit(); a = 1; } catch (Exception e) { tran.Rollback(); } finally { conn.cerrar(); } return(a); }
public int update(proveedores proveedor) { int a = 0; String query = "UPDATE proveedores SET NomEmpresa = @NomEmpresa, TelefonoEmpresa = @TelefonoEmpresa, CorreoEmpresa = @CorreoEmpresa WHERE id_proveedor = @id_proveedor"; conn = new conexion(); SqlCommand command = conn.getConn().CreateCommand(); SqlTransaction trans = conn.getConn().BeginTransaction("simpleTrans"); try { command.Connection = conn.getConn(); command.CommandText = query; command.Transaction = trans; command.Parameters.Add("@id_proveedor", SqlDbType.Int); command.Parameters["@id_proveedor"].Value = proveedor.Id_proveedor; command.Parameters.Add("@NomEmpresa", SqlDbType.VarChar); command.Parameters.Add("@TelefonoEmpresa", SqlDbType.VarChar); command.Parameters.Add("@CorreoEmpresa", SqlDbType.VarChar); command.Parameters["@NomEmpresa"].Value = proveedor.NomEmpresa1; command.Parameters["@TelefonoEmpresa"].Value = proveedor.TelefonoEmpresa1; command.Parameters["@CorreoEmpresa"].Value = proveedor.CorreoEmpresa1; command.ExecuteNonQuery(); trans.Commit(); a = 1; } catch (Exception e) { trans.Rollback(); } finally { conn.cerrar(); } return(a); }
public int insertar(EArea obj) { int reg = 0; // Obtiene el numero de Registros afectados string sql = "INSERT INTO afarea (codigo, nombre, responsable) VALUES (?codigo, ?nombre, ?responsable)"; using (conexion cnx = new conexion()) { cnx.cadena = Configuracion.Instanciar.conexionBD(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.CommandText = sql; cmd.Connection = cnx.getConexion(); cmd.Parameters.Add("?codigo", MySqlDbType.String).Value = obj.codigo; cmd.Parameters.Add("?nombre", MySqlDbType.String).Value = obj.nombre; cmd.Parameters.Add("?responsable", MySqlDbType.String).Value = obj.responsable; if (cnx.abrirConexion()) { reg = cmd.ExecuteNonQuery(); cnx.cerrarConexion(); } } } return(reg); }
public int update(comisiones comision) { int a = 0; String query = "UPDATE comisiones SET empleados = @empleados, ValorComision = @ValorComision, ventas = @ventas WHERE id_comision = @id_comision"; conn = new conexion(); SqlCommand command = conn.getConn().CreateCommand(); SqlTransaction trans = conn.getConn().BeginTransaction("simpleTrans"); try { command.Connection = conn.getConn(); command.CommandText = query; command.Transaction = trans; command.Parameters.Add("@id_comision", SqlDbType.Int); command.Parameters["@id_comision"].Value = comision.Id_comision; command.Parameters.Add("@empleados", SqlDbType.Int); command.Parameters.Add("@ValorComision", SqlDbType.Decimal); command.Parameters.Add("@ventas", SqlDbType.Int); command.Parameters["@empleados"].Value = comision.Empleados; command.Parameters["@ValorComision"].Value = comision.ValorComision1; command.Parameters["@ventas"].Value = comision.Ventas; command.ExecuteNonQuery(); trans.Commit(); a = 1; } catch (Exception e) { trans.Rollback(); } finally { conn.cerrar(); } return(a); }
public int update(prestamos prestamo) { int a = 0; String query = "UPDATE prestamos SET ventas = @ventas, AbonoDeuda = @AbonoDeuda, SaldoPendiente = @SaldoPendiente WHERE id_prestamo = @id_prestamo"; conn = new conexion(); SqlCommand command = conn.getConn().CreateCommand(); SqlTransaction trans = conn.getConn().BeginTransaction("simpleTrans"); try { command.Connection = conn.getConn(); command.CommandText = query; command.Transaction = trans; command.Parameters.Add("@id_prestamo", SqlDbType.Int); command.Parameters["@id_prestamo"].Value = prestamo.Id_prestamo; command.Parameters.Add("@ventas", SqlDbType.Int); command.Parameters.Add("@AbonoDeuda", SqlDbType.Decimal); command.Parameters.Add("@SaldoPendiente", SqlDbType.Decimal); command.Parameters["@ventas"].Value = prestamo.Ventas; command.Parameters["@AbonoDeuda"].Value = prestamo.AbonoDeuda1; command.Parameters["@SaldoPendiente"].Value = prestamo.SaldoPendiente1; command.ExecuteNonQuery(); trans.Commit(); a = 1; } catch (Exception e) { trans.Rollback(); } finally { conn.cerrar(); } return(a); }
protected void modificarUsuario_Click(object sender, EventArgs e) { int id = int.Parse(Request.QueryString["id"]); String nomb = txtNombUsu.Text; String apel = txtApelUsu.Text; int combo = ddlTipoUsu.SelectedIndex + 1; conexion conexionSQL = new conexion(); conexionSQL.conectar(); try { if (nomb != null) { if (apel != null) { int resp = conexionSQL.modificarUsuario(id, nomb, apel, combo); if (resp == 1) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarUsuario();", true); conexionSQL.desconectar(); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); conexionSQL.getTipoEmpleado(ref ddlTipoUsu); conexionSQL.readUsuario(id, ref txtNombUsu, ref txtApelUsu, ref ddlTipoUsu); conexionSQL.desconectar(); } } } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } }
public List <resultview> getResultadosByEstudio(int orden, string prueba) { List <resultview> resultadosLista = new List <resultview>(); conOpenf = new conexion(); conOpenf.conectar(); cone = conOpenf.getConexion(); string query = "select * from ResultHIS_view where Orden=" + orden + " and Estudio='" + prueba + "'"; cmd = new SqlCommand(query, cone); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { resultview resultado = new resultview(); resultado.Orden = reader["Orden"].ToString(); resultado.Identificacion = reader["Identificacion"].ToString(); resultado.Fecha = reader.GetDateTime(2).ToString("yyyyMMdd"); string horaYminuto = DateTime.Now.ToString("HHmm"); resultado.Fecha = resultado.Fecha + horaYminuto; resultado.Parametro = reader["Parametro"].ToString(); resultado.Resultado = reader["Resultado"].ToString(); resultado.Comentario = reader["Comentario"].ToString(); resultado.Estudio = reader["Estudio"].ToString(); resultado.Plantilla = reader["Plantilla"].ToString(); resultado.B_Elemento = reader["B_Elemento"].ToString(); resultado.B_SubElemento = reader["B_SubElemento"].ToString(); resultado.E_Elemento = reader["E_Elemento"].ToString(); resultado.Responsable = reader["Responsable"].ToString(); resultado.T_from_his = reader["t_from_his"].ToString(); resultado.T_validado = reader["t_validado"].ToString(); resultadosLista.Add(resultado); } return(resultadosLista); }
public cargos findById(int id_cargo) { cargos cargos = new cargos(); String sqlString = "SELECT * FROM cargos WHERE id_cargo = @id_cargo"; conn = new conexion(); SqlCommand command = new SqlCommand(sqlString, conn.getConn()); command.Parameters.Add("@id_cargo", SqlDbType.Int); command.Parameters["@id_cargo"].Value = id_cargo; SqlDataReader rd = command.ExecuteReader(); while (rd.Read()) { cargos = new cargos(); cargos.Salario1 = rd.GetDecimal(3); cargos.DescripcionCargo1 = rd.GetString(2); cargos.NomCargo1 = rd.GetString(1); cargos.Id_cargo = rd.GetInt32(0); } rd.Close(); conn.cerrar(); return(cargos); }
protected void Page_Load(object sender, EventArgs e) { conexion conexionSQL = new conexion(); conexionSQL.conectar(); if (!Page.IsPostBack) { try { conexionSQL.getProgramasAll(ref ddlProgramasBecas); conexionSQL.getUniversidadesAll(ref ddlUniversidad); conexionSQL.getCarrerasAll(ref ddlCarrera); int programa = int.Parse(ddlProgramasBecas.SelectedValue); int universidad = int.Parse(ddlUniversidad.SelectedValue); int carrera = int.Parse(ddlCarrera.SelectedValue); int estado = int.Parse(ddlEstado.SelectedValue); conexionSQL.getAlumnosContador(ref ddlAlumnos, programa, universidad, carrera, estado); conexionSQL.desconectar(); } catch (Exception ex) { } } }
private void cerrarSesionToolStripMenuItem_Click(object sender, EventArgs e) { //Autor: Diego Gomez conexion nueva = new conexion(); OdbcCommand cmd; cmd = new OdbcCommand("INSERT INTO tbl_bitacora (" + "PK_idUsuario, " + "accion, " + "fecha, " + "hora, " + "tabla," + "host) " + "VALUES('" + usuario + "' ," + ",'Salida Del Sistema de Usuarios' " + ",'" + DateTime.Now.ToString("yyy/MM/dd") + "'" + ",'" + DateTime.Now.ToString("hh:mm:ss") + "'" + ",'Menu'" + ",' ')" , conexion.conectar()); cmd.ExecuteNonQuery(); Application.Exit(); }
private void button2_Click(object sender, EventArgs e) { Coneccion_de_Director conexionbdd = new Coneccion_de_Director(); conexion conectar = new conexion(); int temp = 0; l_curso.Visible = "---- seleccione curso ----" == curso.Text; l_ci.Visible = !int.TryParse(CI_de_tutor.Text, out temp); if (!l_ci.Visible && !l_ci.Visible && Nombre_del_estudiante.Text != "" && Apellido_paterno.Text != "" && Apellido_materno.Text != "") { if (conexionbdd.Verificador_de_estudiante(Nombre_del_estudiante.Text, Apellido_paterno.Text, Apellido_materno.Text) < 1) { MessageBox.Show("Guardado.." + conectar.insertar("INSERT INTO Estudiante (Nombre_del_estudiante, Apellido_paterno, Apellido_materno, CI_de_tutor, curso) VALUES ('" + Nombre_del_estudiante.Text + "', '" + Apellido_paterno.Text + "', '" + Apellido_materno.Text + "', " + Convert.ToInt32(CI_de_tutor.Text) + ", '" + curso.Text + "')")); } else { MessageBox.Show("ERROR... Ingrese datos validos"); } } else { MessageBox.Show("ERROR... Ingrese datos validos"); } }
public int add(cargos cargo) { int a = 0; conn = new conexion(); SqlTransaction tran; SqlCommand command = conn.getConn().CreateCommand(); tran = conn.getConn().BeginTransaction("simpleTransicion"); try { command.Connection = conn.getConn(); command.Transaction = tran; command.CommandText = "INSERT INTO cargos(NomCargo,Salario,DescripcionCargo) VALUES(@NomCargo,@Salario,@DescripcionCargo)"; command.Parameters.Add("@NomCargo", SqlDbType.VarChar, 50); command.Parameters.Add("@Salario", SqlDbType.Decimal); command.Parameters.Add("@DescripcionCargo", SqlDbType.Text); command.Parameters["@NomCargo"].Value = cargo.NomCargo1; command.Parameters["@Salario"].Value = cargo.Salario1; command.Parameters["@DescripcionCargo"].Value = cargo.DescripcionCargo1; command.ExecuteNonQuery(); tran.Commit(); a = 1; } catch (Exception e) { tran.Rollback(); } finally { conn.cerrar(); } return(a); }
public List <EDocumentos> getAll(string mes, string filtro) { List <EDocumentos> lstDocumentos = new List <EDocumentos>(); EDocumentos objDoc = null; string sql; if (filtro == "Todos") { sql = "SELECT * FROM documentos" + mes + " WHERE tipodoc in ('AF')"; } else { sql = " SELECT d.doc, d.tipodoc, CONCAT(d.dia, '/',d.periodo) fecha, d.nit, CONCAT(t.nombre,' ',t.apellidos) AS nombre, " + " IF(SUM(d.debito)=0,SUM(d.credito),SUM(d.debito)) AS debito FROM documentos" + mes + " " + " d INNER JOIN terceros t ON d.nit= t.nit WHERE tipodoc in (" + filtro + ") GROUP BY tipodoc, doc ORDER BY tipodoc,doc "; } using (conexion cnx = new conexion()) { cnx.cadena = Configuracion.Instanciar.conexionBD(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.CommandText = sql; cmd.Connection = cnx.getConexion(); if (cnx.abrirConexion()) { MySqlDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { objDoc = mapearObj(dr); lstDocumentos.Add(objDoc); } cnx.cerrarConexion(); } } } return(lstDocumentos); }
public int insertar(EMovimientos obj) { int reg = 0; // Obtiene el numero de Registros afectados string sql = "INSERT INTO afmovimientos (idMovimiento, documento, tipodoc,periodo," + " fecha, tipoMov, descripcion, codActivo, valTotal, estado, ccosto, nitc) " + " VALUES (null, ?documento, ?tipodoc, ?periodo, ?fecha, ?tipoMov," + " ?descripcion, ?codActivo, ?valTotal, ?estado, ?ccosto, ?nitc)"; using (conexion cnx = new conexion()) { cnx.cadena = Configuracion.Instanciar.conexionBD(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.CommandText = sql; cmd.Connection = cnx.getConexion(); cmd.Parameters.Add("?documento", MySqlDbType.String).Value = obj.documento; cmd.Parameters.Add("?tipodoc", MySqlDbType.String).Value = obj.tipoDoc; cmd.Parameters.Add("?periodo", MySqlDbType.String).Value = obj.periodo; cmd.Parameters.Add("?fecha", MySqlDbType.DateTime).Value = obj.fecha; cmd.Parameters.Add("?tipoMov", MySqlDbType.String).Value = obj.tipoMov; cmd.Parameters.Add("?codActivo", MySqlDbType.String).Value = obj.codActivo; cmd.Parameters.Add("?descripcion", MySqlDbType.String).Value = obj.descripcion; cmd.Parameters.Add("?valTotal", MySqlDbType.String).Value = obj.valor; cmd.Parameters.Add("?estado", MySqlDbType.String).Value = obj.estado; cmd.Parameters.Add("?ccosto", MySqlDbType.String).Value = obj.cCosto; cmd.Parameters.Add("?nitc", MySqlDbType.String).Value = obj.nit; if (cnx.abrirConexion()) { reg = cmd.ExecuteNonQuery(); cnx.cerrarConexion(); } } } return(reg); }
public List <string> Get(string id) { if (id.Equals("1")) { conexion con = new conexion(); SqlDataReader dr = con.get_lugares(); if (dr.HasRows) { List <String> lista = new List <string>(); while (dr.Read()) { //lista.Add("{"); lista.Add("codigo: 1"); lista.Add("TOTAL: " + dr[0]); // lista.Add("}"); } return(lista); } else { return(new List <string> { "codigo: 0", "mensaje: Existe un error, intentalo de nuevo", }); } } if (id.Equals("2")) { conexion con = new conexion(); SqlDataReader dr = con.get_usuario(); if (dr.HasRows) { List <String> lista = new List <string>(); while (dr.Read()) { //lista.Add("{"); lista.Add("codigo: 1"); lista.Add("TOTAL: " + dr[0]); // lista.Add("}"); } return(lista); } else { return(new List <string> { "codigo: 0", "mensaje: Existe un error, intentalo de nuevo", }); } } if (id.Equals("3")) { conexion con = new conexion(); SqlDataReader dr = con.get_hot_desk_disponibles(); if (dr.HasRows) { List <String> lista = new List <string>(); while (dr.Read()) { //lista.Add("{"); lista.Add("codigo: 1"); lista.Add("TOTAL: " + dr[0]); // lista.Add("}"); } return(lista); } else { return(new List <string> { "codigo: 0", "mensaje: Existe un error, intentalo de nuevo", }); } } if (id.Equals("4")) { conexion con = new conexion(); SqlDataReader dr = con.get_usuarios_en_la_oficina(); if (dr.HasRows) { List <String> lista = new List <string>(); while (dr.Read()) { //lista.Add("{"); lista.Add("codigo: 1"); lista.Add("TOTAL: " + dr[0]); // lista.Add("}"); } return(lista); } else { return(new List <string> { "codigo: 0", "mensaje: Existe un error, intentalo de nuevo", }); } } if (id.Equals("5")) { conexion con = new conexion(); SqlDataReader dr = con.get_usuarios_activos(); if (dr.HasRows) { List <String> lista = new List <string>(); while (dr.Read()) { //lista.Add("{"); lista.Add("codigo: 1"); lista.Add("NOMBRE: " + dr["NOMBRE"]); lista.Add("AREA: " + dr["AREA"]); lista.Add("NUM_EMPLEADO: " + dr["NUMERO_EMPLEADO"]); lista.Add("|"); } return(lista); } else { return(new List <string> { "codigo: 0", "mensaje: Correo o password incorrectos", }); } } else { return(new List <string> { "codigo: 0", "mensaje: Existe un error, intentalo de nuevo", }); } }
public Boolean nuevaPeticion(PeticionEntrante datos) { conOpenf = new conexion(); conOpenf.conectar(); cone = conOpenf.getConexion(); int afectadas = 0; string fechaNacimiento = datos.Pid7_datetimeBirth; DateTime nacimiento = DateTime.ParseExact(fechaNacimiento + " 00:00:00", "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); DateTime fecha_Actual = DateTime.Now; int edad = (fecha_Actual - nacimiento).Days / 365; foreach (Peticion_obr orb_detalle in datos.ListaORB) { DateTime fechaActualCodigo = DateTime.Now; System.DateTime dateTimeTransaction = DateTime.Now; string fechaFormateada = dateTimeTransaction.ToString("yyyy-MM-dd"); cmd = null; //query = "INSERT INTO HIS2LIS (Orden, FSolicitud, Origen, Servicio, Doctor, Libre, Identificacion, Nombre, Apell1, Apell2, Sexo, Codigo, Edad) " + // "VALUES (@POrdens, '"+ fechaFormateada + "' , @POrigens, @PServicios, @PDoctors, @Plibres, @PIdentificacions, @PNombres, @PApell1s, @PApell2s, @PSexos, @PCodigos, @Pedad)"; query = "INSERT INTO HIS2LIS (Orden, FSolicitud, Origen, Servicio, Doctor, Libre, Identificacion, Nombre, Apell1, Apell2, Sexo, Codigo) " + "VALUES (@POrdens, '" + fechaFormateada + " 00:00:00' , @POrigens, @PServicios, @PDoctors, @Plibres, @PIdentificacions, @PNombres, @PApell1s, @PApell2s, @PSexos, @PCodigos)"; try { cmd = new SqlCommand(query, cone); string[] apellidos = datos.Pid5_1_familyName.Split(' '); string ordenFinal = fechaActualCodigo.ToString("yyMMdd") + datos.Orc2_placerOrderNumer + int.Parse(datos.Msh10_messageControlID); cmd.Parameters.Add(new SqlParameter("@POrdens", ordenFinal)); var salaryParam = new SqlParameter("PFSolicituds", SqlDbType.SmallDateTime); salaryParam.Value = dateTimeTransaction.ToShortDateString(); cmd.Parameters.Add(new SqlParameter("@POrigens", datos.Pv2_patientClass)); cmd.Parameters.Add(new SqlParameter("@PServicios", datos.Orc13_1_pointOfCare)); cmd.Parameters.Add(new SqlParameter("@PDoctors", datos.Orc12_1_idNumber)); cmd.Parameters.Add(new SqlParameter("@Plibres", 1)); cmd.Parameters.Add(new SqlParameter("@PIdentificacions", datos.Pid3_1_idNumber)); //paciente ID cmd.Parameters.Add(new SqlParameter("@PNombres", datos.Pid5_2_givenName + " " + datos.Pid5_3_secondName)); cmd.Parameters.Add(new SqlParameter("@PApell1s", apellidos[0])); //Hacer split de los apellidos cmd.Parameters.Add(new SqlParameter("@PApell2s", apellidos[1])); //cmd.Parameters.Add(new SqlParameter("@Pedad", edad)); //cmd.Parameters.Add(new SqlParameter("@Pedad", null)); if (datos.Pid8_AdministrativeSex == "2") { cmd.Parameters.Add(new SqlParameter("@PSexos", "F")); //Revisar tabla Masculino = M, Femenino = F } else { cmd.Parameters.Add(new SqlParameter("@PSexos", "M")); //Revisar tabla Masculino = M, Femenino = F } //cmd.Parameters.Add(new SqlParameter("@PCodigos", orb_detalle.Obr4_4_AlternateIdentifier)); cmd.Parameters.Add(new SqlParameter("@PCodigos", orb_detalle.Obr4_4_AlternateIdentifier)); afectadas += cmd.ExecuteNonQuery(); System.Diagnostics.Debug.WriteLine("Afectadas " + afectadas); System.Diagnostics.Debug.WriteLine(cmd.CommandText); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine(ex.Message); cone.Close(); } } cone.Close(); if (afectadas > 0) { return(true); } return(true); }
public Rango getRangos(int cod, int EdadDias, float lectura) { Rango rangosAdecuados = new Rango(); conOpenf = new conexion(); conOpenf.conectar(); cone = conOpenf.getConexion(); string query = "select valor_inferior1, valor_inferior2, valor_inferior3, valor_inferior4, valor_superior1, valor_superior2, valor_superior3, valor_superior4 from operfil_data where par_codigo=" + cod; cmd = new SqlCommand(query, cone); SqlDataReader reader = cmd.ExecuteReader(); float rangoin1 = 0; float rangoin2 = 0; float rangoin3 = 0; float rangoin4 = 0; float rangosup1 = 0; float rangosup2 = 0; float rangosup3 = 0; float rangosup4 = 0; if (reader.Read()) { rangoin1 = float.Parse(reader["valor_inferior1"].ToString()); rangoin2 = float.Parse(reader["valor_inferior2"].ToString()); rangoin3 = float.Parse(reader["valor_inferior3"].ToString()); rangoin4 = float.Parse(reader["valor_inferior4"].ToString()); rangosup1 = float.Parse(reader["valor_superior1"].ToString()); rangosup2 = float.Parse(reader["valor_superior2"].ToString()); rangosup3 = float.Parse(reader["valor_superior3"].ToString()); rangosup4 = float.Parse(reader["valor_superior4"].ToString()); } if (EdadDias >= 0 && EdadDias <= 54750) { rangosAdecuados.RangoInferior = rangoin3; rangosAdecuados.RangoSuperior = rangosup3; } if (EdadDias <= 30) //1 { rangosAdecuados.RangoInferior = rangoin4; rangosAdecuados.RangoSuperior = rangoin4; } if (EdadDias >= 31 && EdadDias <= 4380)//2 { rangosAdecuados.RangoInferior = rangoin2; rangosAdecuados.RangoSuperior = rangosup2; } if (EdadDias >= 4381 && EdadDias <= 54750) { rangosAdecuados.RangoInferior = rangoin1; rangosAdecuados.RangoSuperior = rangosup1; } if (lectura >= rangosAdecuados.RangoInferior && lectura <= rangosAdecuados.RangoSuperior) { rangosAdecuados.Comentario = "Normal"; rangosAdecuados.IdComentario = 1; } else { rangosAdecuados.Comentario = "Anormal"; rangosAdecuados.IdComentario = 3; } cone.Close(); return(rangosAdecuados); } //min y max
private void button1_Click(object sender, EventArgs e) { nombre = txtNombre.Text; nombre2 = txtNombre2.Text; apellido = txtApellido.Text; fec_nac = txtFechaNacimiento.Text; email = txtEmail.Text; id_localidad = Int32.Parse(cmbLocalidades.SelectedValue.ToString()); id_deporte = Int32.Parse(cmbDeporte.SelectedValue.ToString()); if(txtDNI.Text != "") dni = Int32.Parse(txtDNI.Text); if(txtTel.Text != "") tel = Int32.Parse(txtTel.Text); ; sql = "INSERT INTO Profesores (dni, tel, nombre, nombre2, apellido, fec_nac, email, id_localidad, id_deporte) VALUES ('"+ dni + "','"+ tel +"','" + nombre + "','" + nombre2 + "','" + apellido + "','" + fec_nac + "','" + email + "','"+ id_localidad + "','" + id_deporte + "' )"; DataSet ds = new DataSet(); SqlConnection cx = new SqlConnection(); conexion c = new conexion(); //cx.ConnectionString = c.getCadena(); SqlDataAdapter da = new SqlDataAdapter(sql, cx); da.Fill(ds, "profesores"); lblGuardado.Visible = true; }
protected void guardar_Click(object sender, EventArgs e) { try { string consulta; MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); builder.Server = "mysql5013.smarterasp.net"; builder.UserID = "a131fe_bd"; builder.Password = "******"; builder.Database = "db_a131fe_bd"; MySqlConnection con = new MySqlConnection(builder.ToString()); MySqlCommand query = con.CreateCommand(); con.Open(); consulta = "SELECT cod_user FROM usuarios WHERE cod_user='******'"; query.CommandText = consulta; MySqlDataReader leer = query.ExecuteReader(); //SqlCommand query; //SqlConnection con = new SqlConnection("Data Source=sql5019.smarterasp.net;Persist Security Info=True;User ID=DB_A132F9_SistemaCecees_admin;Password=sistema1234"); //query = new SqlCommand(consulta, con); //SqlDataReader leer = query.ExecuteReader(); bool validar = leer.HasRows; if (validar) { string script = "alert('¡El usuario " + txtCodUser.Text + " ya existe!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script, true); } else { if (txtCodUser.Text == "" || txtEmail.Text == "" || txtFirstLastName.Text == "" || txtFirstName.Text == "" || txtSecondLastName.Text == "" || txtSecondName.Text == "") { string script2 = "alert('¡No puede dejar ningún campo vacío!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script2, true); } else { string sql = "INSERT INTO usuarios (ID_USUARIO, cod_user, contra, nombre_user, correo, tipo_user, primer_nombre, segundo_nombre, primer_apellido, segundo_apellido) values ('" + txtCodUser.Text + "','" + txtCodUser.Text + "','" + txtPassword.Text + "','" + txtFirstName.Text + " " + txtFirstLastName.Text + "','" + txtEmail.Text + "', '" + txtTipoUser.Text + "','" + txtFirstName.Text + "', '" + txtSecondName.Text + "', '" + txtFirstLastName.Text + "', '" + txtSecondLastName.Text + "');"; conexion con2 = new conexion(); con2.insert(sql); string script = "alert('¡El usuario se registró exitosamente!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script, true); bool guardarAcc = true; borrar(guardarAcc); } } txtTipoUser.Items.Remove("VIP"); } catch (Exception ex) { string script = "alert('¡ERROR!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script, true); } }
protected void guardarUsuario_Click(object sender, EventArgs e) { String nombre = this.txtNombre.Text; String apellido = this.txtApellidos.Text; String correo = this.txtCorreo.Text; String fecha = this.txtFechaN.Text; String tel = this.txtTelefono.Text; String direccion = this.txtDireccion.Text; String duracion = this.txtContra.Text; String dui = this.txtDui.Text; String fechai = this.fechaInicio.Text; String fechaf = this.fechaFin.Text; int univ = int.Parse(ddlUniversidades.SelectedValue); int carr = int.Parse(ddlCarreras.SelectedValue); int nivel = int.Parse(ddlNivel.SelectedValue); int beca = int.Parse(this.ddlPrograma.SelectedValue); if (nombre != "") { if (apellido != "") { if (correo != "" && fecha != "" && tel != "" && direccion != "" && dui != "" && fechai != "" && fechaf != "") { if (beca > 0 && nivel > 0 && carr > 0 && univ > 0) { conexion conexionSQL = new conexion(); conexionSQL.conectar(); generadorContra c = new generadorContra(); String contra = c.generarContra(); encriptacion enc = new encriptacion(); String contraEnc = enc.encriptarContra(contra); String codB = conexionSQL.getCodigoB(beca); int codigo = conexionSQL.codigoMax() + 1; this.metodoCodigo(codB, codigo); int resp = conexionSQL.agregarBecario(nombre, apellido, correo, contra, univ, nivel, carr, beca, fecha, fechai, fechaf, tel, direccion, this.codigoB, dui, duracion); conexionSQL.desconectar(); if (resp > 0) { correo enviarCo = new correo(correo, "Credeciales de Usuario", "Estimado/a: " + nombre + ". Su password es: " + contra); if (enviarCo.Estado) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "modificarCarrera();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } }
private void button1_Click(object sender, EventArgs e) { //Autor: Diego Gomez conexion nueva = new conexion(); OdbcCommand cmd; string User = this.Txt_usuario.Text; string Password = this.Txt_clave.Text; if (User == "" || Password == "") { MessageBox.Show("Ingrese Usuario y Contraseña", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Txt_usuario.Focus(); return; } else { string host = Dns.GetHostName(); IPAddress[] IP = Dns.GetHostAddresses(host); cmd = new OdbcCommand("INSERT INTO tbl_bitacora (PK_idBitacora," + "PK_idUsuario, " + "accion, " + "fecha, " + "hora, " + "tabla," + "host) " + "VALUES('' ,(SELECT PK_idUsuario FROM tbl_usuarios WHERE Pk_idUsuario = '" + Txt_usuario.Text + "')" + ",'Ingreso Al Sistema Administrativo' " + ",'" + DateTime.Now.ToString("yyy/MM/dd") + "'" + ",'" + DateTime.Now.ToString("hh:mm:ss") + "'" + ",' '" + ",'" + host + "'" + ")" , conexion.conectar()); cmd.ExecuteNonQuery(); cmd = new OdbcCommand("SELECT PK_id_tipo_usuario FROM tbl_usuarios WHERE PK_idUsuario='" + Txt_usuario.Text + "'" , conexion.conectar()); OdbcDataReader reader1 = cmd.ExecuteReader(); String nombre = ""; if (reader1.HasRows) { while (reader1.Read()) { nombre = reader1.GetString(0); if (nombre == "1") { cmd = new OdbcCommand("{ call procedimientoLoginAdministrador (?,?)}", conexion.conectar()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@usuario1", OdbcType.Text).Value = Txt_usuario.Text; cmd.Parameters.Add("@contraseña", OdbcType.Text).Value = Txt_clave.Text; frm_seleccionarEquipo seleccionar = new frm_seleccionarEquipo("Login", null, Txt_usuario.Text); seleccionar.Show(); Hide(); Txt_usuario.Clear(); Txt_clave.Clear(); } if (nombre == "2") { cmd = new OdbcCommand("{ call procedimientoLoginEntrenador (?,?)}", conexion.conectar()); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@usuario1", OdbcType.Text).Value = Txt_usuario.Text; cmd.Parameters.Add("@contraseña", OdbcType.Text).Value = Txt_clave.Text; frm_seleccionarEquipo seleccionar = new frm_seleccionarEquipo("Login", null, Txt_usuario.Text); seleccionar.Show(); Hide(); Txt_usuario.Clear(); Txt_clave.Clear(); } } } else { MessageBox.Show("Usuario o Contraseña equivocados,Vuelva a Intentar"); cmd = new OdbcCommand("INSERT INTO tbl_bitacora (PK_idBitacora," + "PK_idUsuario, " + "accion, " + "fecha, " + "hora, " + "tabla," + "host) " + "VALUES('' ,(SELECT PK_idUsuario FROM tbl_usuarios WHERE Pk_idUsuario = '" + Txt_usuario.Text + "')" + ",'Error al ingresar al sistema' " + ",'" + DateTime.Now.ToString("yyy/MM/dd") + "'" + ",'" + DateTime.Now.ToString("hh:mm:ss") + "'" + ",' '" + ",'" + host + "'" + ")" , conexion.conectar()); cmd.ExecuteNonQuery(); Txt_usuario.Clear(); Txt_clave.Clear(); } } }
private void btnCrear_Click(object sender, EventArgs e) { bool usernameOK = false, passwordOK = false, preguntaOK = false, respuestaOK = false; if (txtUsuario.Text != "") { usernameOK = true; lblUsuario.ForeColor = Color.Black; } else { usernameOK = false; lblUsuario.ForeColor = Color.Red; } if (txtPassword.Text != "") { passwordOK = true; lblPassword.ForeColor = Color.Black; } else { passwordOK = false; lblPassword.ForeColor = Color.Red; } if (txtPreguntaSec.Text != "") { preguntaOK = true; lblPregunta.ForeColor = Color.Black; } else { preguntaOK = false; lblPregunta.ForeColor = Color.Red; } if (txtRespuestaSec.Text != "") { respuestaOK = true; lblRespuesta.ForeColor = Color.Black; } else { respuestaOK = false; lblRespuesta.ForeColor = Color.Red; } if (usernameOK && passwordOK && preguntaOK && respuestaOK) { string resul; try { string nombreSP = "SARASA.comprobar_usuario_existente"; List <SqlParameter> listaParametros = Herramientas.GenerarListaDeParametros( "@username", txtUsuario.Text); conexion cn = new conexion(); SqlCommand query = new SqlCommand(nombreSP, cn.abrir_conexion()); query.CommandType = CommandType.StoredProcedure; // Agregar los parametros del tipo INPUT query.Parameters.AddRange(listaParametros.ToArray()); // Definir el parametro del tipo OUTPUT SqlParameter factura = new SqlParameter("@resul", 0); factura.Direction = ParameterDirection.Output; query.Parameters.Add(factura); query.ExecuteNonQuery(); resul = (query.Parameters["@resul"].SqlValue.ToString()); if (resul == "0") { List <SqlParameter> lista = Herramientas.GenerarListaDeParametros( "@Usuario_Username", txtUsuario.Text, "@Usuario_Password", Herramientas.sha256_hash(txtPassword.Text.ToString()), "@Usuario_Pregunta_Sec", txtPreguntaSec.Text, "@Usuario_Respuesta_Sec", Herramientas.sha256_hash(txtRespuestaSec.Text.ToString()), "@Rol_Id", ((KeyValuePair <string, string>)cbxRol.SelectedItem).Key); if (Herramientas.EjecutarStoredProcedure("SARASA.crear_usuario", lista) == null) { } else { this.Dispose(); formPadre.Show(); } } else { lblUsuario.ForeColor = Color.Red; Herramientas.msebox_informacion("Nombre de usuario ya existente"); } } catch (Exception ex) { MessageBox.Show("Error: " + ex.ToString()); } } }
protected void BtnRegistrar_Click(object sender, EventArgs e) { try { string consulta; MySqlConnectionStringBuilder builder = new MySqlConnectionStringBuilder(); builder.Server = "mysql5013.smarterasp.net"; builder.UserID = "a131fe_bd"; builder.Password = "******"; builder.Database = "db_a131fe_bd"; MySqlConnection con = new MySqlConnection(builder.ToString()); MySqlCommand query = con.CreateCommand(); con.Open(); consulta = "SELECT * FROM grado WHERE grado='" + DpdGrado.SelectedItem.Text + "' AND seccion='" + DpdSeccion.SelectedItem.Text + "' AND tipo_grado='" + DpdEducacion.SelectedItem.Text + "'; SELECT ID_DOCENTE FROM docentes WHERE nombre_completo_doc='" + DpdOrientador.SelectedItem.Text + "'"; query.CommandText = consulta; MySqlDataReader leer = query.ExecuteReader(); bool validar = leer.HasRows; if (validar) { leer.Read(); if (leer["tipo_grado"].ToString() == "Bachillerato") { string script = "alert('¡El " + DpdGrado.SelectedItem.Text + "º año de Bachillerato Sección " + leer["seccion"].ToString() + " ya está registrado!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script, true); } else { string script = "alert('¡El " + DpdGrado.SelectedItem.Text + "º Grado Sección " + leer["seccion"].ToString() + " ya está registrado!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script, true); } } else { if (txtHorasClase.Text == "" || DpdEducacion.SelectedIndex == 0 || DpdGrado.SelectedIndex == 0 || DpdSeccion.SelectedIndex == 0 || DpdOrientador.SelectedIndex == 0) { string script = "alert('¡No puede dejar campos vacíos!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Alerta", script, true); } else { //string sql = "INSERT INTO grado (horas_clase, grado, seccion, nombre_grado, id_orientador, tipo_grado) values ('" + txtHorasClase.Text + "','" + DpdGrado.SelectedItem.Text + "', '" + DpdSeccion.SelectedItem.Text+ "','" + txtNombreAbreviado.Text + "','" + txtPrimerApellido.Text + "','" + txtSegundoApellido.Text + "','" + txtEspecialidad.Text + "','" + txtTelefono.Text + "','" + txtDireccion.Text + "', '" + DpdEducacion.SelectedItem.Text + "', '" + DpdTurno.SelectedItem.Text + "');"; conexion con2 = new conexion(); //con2.insert(sql); string script = "alert('¡El/la docente se registró exitosamente!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script, true); } } } catch (Exception ex) { string script2 = "alert('¡El/la docente NO se registró!');"; ScriptManager.RegisterStartupScript(this, typeof(Page), "Información", script2, true); } }
public int insertar(EActivos act) { int reg = 0; string sql = "INSERT INTO afactivos (codigo, nombre, descripcion,marca, modelo, numSerie, referencia, " + " vidaUtil, propiedad, fechaCompra, areaLoc, responsable, proveedor, ccosto, " + " estado, valComercial, valSalvamento, valLibros, valMejoras, valHistorico, " + "depajustada, depAcumulada, grupo, subgrupo, ctaActivo, ctadepreciacion, ctagastos, " + "ctaPerdida, ctaGanancia, ctaMantenimiento, metodoDep, fechamaxDep, mantenimiento, poliza, nFactura) " + " VALUES (?codigo, ?nombre, ?descripcion, ?marca, ?modelo, ?numSerie, ?referencia, " + " ?vidaUtil, ?propiedad, ?fechaCompra, ?areaLoc, ?responsable, ?proveedor, ?ccosto, " + " ?estado, ?valComercial, ?valSalvamento, ?valLibros, ?valMejoras, ?valHistorico, " + " ?depajustada, ?depAcumulada, ?grupo, ?subgrupo, ?ctaActivo, ?ctadepreciacion, ?ctagastos, " + "?ctaPerdida, ?ctaGanancia, ?ctaMantenimiento, ?metodoDep, ?fechamaxDep, ?mantenimiento, ?poliza, ?nFactura)"; using (conexion cnx = new conexion()) { cnx.cadena = Configuracion.Instanciar.conexionBD(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.CommandText = sql; cmd.Connection = cnx.getConexion(); cmd.Parameters.Add("?codigo", MySqlDbType.String).Value = act.codigo; cmd.Parameters.Add("?nombre", MySqlDbType.String).Value = act.nombre; cmd.Parameters.Add("?descripcion", MySqlDbType.String).Value = act.descripcion; cmd.Parameters.Add("?marca", MySqlDbType.String).Value = act.marca; cmd.Parameters.Add("?modelo", MySqlDbType.String).Value = act.modelo; cmd.Parameters.Add("?numSerie", MySqlDbType.String).Value = act.numSerie; cmd.Parameters.Add("?referencia", MySqlDbType.String).Value = act.referencia; cmd.Parameters.Add("?grupo", MySqlDbType.String).Value = act.grupo; cmd.Parameters.Add("?subgrupo", MySqlDbType.String).Value = act.subGrupo; cmd.Parameters.Add("?vidaUtil", MySqlDbType.Int32).Value = act.vidaUtil; cmd.Parameters.Add("?metodoDep", MySqlDbType.VarChar).Value = act.metodoDep; cmd.Parameters.Add("?propiedad", MySqlDbType.String).Value = act.propiedad; cmd.Parameters.Add("?fechaCompra", MySqlDbType.Date).Value = act.fecha; cmd.Parameters.Add("?areaLoc", MySqlDbType.String).Value = act.area; cmd.Parameters.Add("?responsable", MySqlDbType.String).Value = act.responsable; cmd.Parameters.Add("?proveedor", MySqlDbType.String).Value = act.proveedor; cmd.Parameters.Add("?ccosto", MySqlDbType.String).Value = act.centrocosto; cmd.Parameters.Add("?estado", MySqlDbType.String).Value = act.estado; cmd.Parameters.Add("?valComercial", MySqlDbType.Double).Value = act.valComercial; cmd.Parameters.Add("?valSalvamento", MySqlDbType.Double).Value = act.valSalvamento; cmd.Parameters.Add("?valLibros", MySqlDbType.Double).Value = act.valLibros; cmd.Parameters.Add("?valMejoras", MySqlDbType.Double).Value = act.valMejoras; cmd.Parameters.Add("?valHistorico", MySqlDbType.Double).Value = act.valHistorico; cmd.Parameters.Add("?depajustada", MySqlDbType.Double).Value = act.depAjustada; cmd.Parameters.Add("?depAcumulada", MySqlDbType.Double).Value = act.depAcumulada; cmd.Parameters.Add("?ctaActivo", MySqlDbType.String).Value = act.ctaActivo; cmd.Parameters.Add("?ctadepreciacion", MySqlDbType.String).Value = act.ctaDepreciacion; cmd.Parameters.Add("?ctagastos", MySqlDbType.String).Value = act.ctaGastos; cmd.Parameters.Add("?ctaPerdida", MySqlDbType.String).Value = act.ctaPerdida; cmd.Parameters.Add("?ctaGanancia", MySqlDbType.String).Value = act.ctaGanancia; cmd.Parameters.Add("?ctaMantenimiento", MySqlDbType.String).Value = act.ctaMantenimiento; cmd.Parameters.Add("?fechamaxDep", MySqlDbType.Date).Value = act.fechaDep; cmd.Parameters.Add("?mantenimiento", MySqlDbType.String).Value = act.mantenimiento; cmd.Parameters.Add("?poliza", MySqlDbType.String).Value = act.poliza; cmd.Parameters.Add("?nFactura", MySqlDbType.String).Value = act.nFactura; if (cnx.abrirConexion()) { reg = cmd.ExecuteNonQuery(); cnx.cerrarConexion(); } } return(reg); } }
protected void guardarDesembolso_Click(object sender, EventArgs e) { conexion conexionSQL = new conexion(); conexionSQL.conectar(); try { int aspe = int.Parse(ddlAspectos.SelectedValue); double mont = double.Parse(txtMonto.Text); int resp1 = conexionSQL.verificarExistenciaMonto(aspe); conexionSQL.desconectar(); if (resp1 > 0) { conexion conexionSQL2 = new conexion(); conexionSQL2.conectar(); int res = conexionSQL2.verificarMontoIngresado(aspe, mont); conexionSQL2.desconectar(); if (res == 1) { conexion conexionSQL4 = new conexion(); conexionSQL4.conectar(); int res4 = conexionSQL4.agregarDesembolso(aspe, mont); conexionSQL4.desconectar(); if (res4 > 0) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "agregarDesembolso();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } } else { conexion conexionSQL3 = new conexion(); conexionSQL3.conectar(); int res2 = conexionSQL3.verificarMontoIngresadoNUll(aspe, mont); conexionSQL3.desconectar(); if (res2 == 1) { conexion conexionSQL5 = new conexion(); conexionSQL5.conectar(); int res5 = conexionSQL5.agregarDesembolso(aspe, mont); conexionSQL5.desconectar(); if (res5 > 0) { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "agregarDesembolso();", true); } else { ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), "Popup", "error();", true); } } } } catch (Exception ex) { txtMonto.Text = ex.Source.ToString(); } }