private void modificarItem() { clsFunciones clsFunc = new clsFunciones(); String respuesta = String.Empty; clsSQL clsSQL = new clsSQL(); int activo = 0; if (this.chkActivo.Checked == true) { activo = 1; } respuesta = clsSQL.ejecutarSP("SP_Man_Rutas", "@opcion=3=System.Int32", "@id_key_ruta=" + this.id_key_ruta.ToString() + "=System.Int32", "@origen=" + this.txtOrigen.Text.Trim() + "=System.String", "@destino=" + this.txtDestino.Text.Trim() + "=System.String", "@km=" + this.txtKm.Text.Trim() + "=System.Int32", "@peajes=" + this.txtPeajes.Text.Trim() + "=System.String", "@precios=" + this.txtPrecio.Text.Trim() + "=System.String", "@vehiculo_activo=" + activo.ToString() + "=System.Int32"); if (respuesta != "OK") { MessageBox.Show("Error al modificar el registro.", mdPrincipal.Error_SQL, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Registro modificado correctamente."); } this.Close(); }
public void recogerDatos(int _id_key_articulo) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_articulo != 0) { dt = clsSQL.devolverDataTable("select * from articulos where id_key_articulo = " + _id_key_articulo.ToString()); this.id_key_articulo = _id_key_articulo; foreach (DataRow dr in dt.Rows) { //this.txtDescripcion.Text = dr["descripcion"].ToString(); //this.cmbProveedor.SelectedValue = dr["id_key_proveedor"].ToString(); } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { //nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
public void recogerDatos(int _id_key_usuario) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_usuario != 0) { dt = clsSQL.devolverDataTable("select * from usuarios where id_key_usuario = " + _id_key_usuario.ToString()); this.id_key_usuario = _id_key_usuario; foreach (DataRow dr in dt.Rows) { //this.txtNombre.Text = dr["nombre"].ToString(); //this.txtPassword.Text = dr["password"].ToString(); //cargaPermisos(); } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { //nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
public void recogerDatos(int _id_key_proveedor) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_proveedor != 0) { dt = clsSQL.devolverDataTable("select * from proveedores where id_key_proveedor = " + _id_key_proveedor.ToString()); this.id_key_proveedor = _id_key_proveedor; foreach (DataRow dr in dt.Rows) { //Carga datos proveedor //this.txtNombre.Text = dr["Nombre"].ToString(); //this.txtCIF.SelectedValue = dr["CIF"].ToString(); } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; } else { //nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
public void cargarCombos() { clsFunciones clsFunc = new clsFunciones(); clsFunc.cargarCombos(cmbTipoVehiculo, "select id_key_tipo_vehiculo,tipo_vehiculo from tg_tipos_vehiculo", "tipo_vehiculo", "id_key_tipo_vehiculo", true); clsFunc.cargarCombos(cmbTipoRuedas, "select id_key_tipo_ruedas,descripcion from ruedas", "descripcion", "id_key_tipo_ruedas", true); }
private void addItem() { clsFunciones clsFunc = new clsFunciones(); String respuesta = String.Empty; clsSQL clsSQL = new clsSQL(); int activo = 0; if (this.chkActivo.Checked == true) { activo = 1; } respuesta = clsSQL.ejecutarSP("SP_Man_Vehiculos", "@opcion=1=System.Int32", "@id_key_vehiculo=0=System.Int32", "@matricula=" + this.txtMatricula.Text.Trim() + "=System.String", "@num_bastidor=" + this.txtNumBastidor.Text.Trim() + "=System.String", "@id_key_tipo_vehiculo=" + this.cmbTipoVehiculo.SelectedValue + "=System.Int32", "@marca=" + this.txtMarca.Text.Trim() + "=System.String", "@modelo=" + this.txtModelo.Text.Trim() + "=System.String", "@fecha_matriculacion=" + this.fechaMatriculacion.Value + "=System.Datetime", "@id_key_tipo_ruedas=" + this.cmbTipoRuedas.SelectedValue + "=System.Int32", "@vehiculo_activo=" + activo.ToString() + "=System.Int32"); if (respuesta != "OK") { MessageBox.Show("Error al crear el registro.", mdPrincipal.Error_SQL, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Registro añadido correctamente."); } this.Close(); }
private void cargarCombos() { clsFunciones clsFunc = new clsFunciones(); clsFunc.cargarCombos(cmbDepartamento, "select id_key_departamento,departamento from tg_departamento order by departamento", "departamento", "id_key_departamento", false); clsFunc.cargarCombos(cmbPuesto, "select id_key_puesto,puesto from tg_puesto order by puesto", "puesto", "id_key_puesto", false); }
//**************************************************** // INICIO METODOS PPALES ALTA, BAJA, MODIFICACION **** //**************************************************** private void addItem() { clsFunciones clsFunc = new clsFunciones(); String respuesta = String.Empty; clsSQL clsSQL = new clsSQL(); int activo = 0; if (this.chkActivo.Checked == true) { activo = 1; } respuesta = clsSQL.ejecutarSP("SP_Man_Empleados", "@opcion=1=System.Int32", "@id_key_empleado=0=System.Int32", "@NIF=" + this.txtNIF.Text.Trim() + "=System.String", "@nombre=" + this.txtNombre.Text.Trim() + "=System.String", "@apellido1=" + this.txtApellido1.Text.Trim() + "=System.String", "@apellido2=" + this.txtApellido2.Text.Trim() + "=System.String", "@num_SS=" + this.txtNumSS.Text.Trim() + "=System.String", "@fecha_alta=" + this.fechaAlta.Value + "=System.Datetime", "@fecha_baja=" + fechaBaja.Value + "=System.Datetime", "@id_key_departamento=" + this.cmbDepartamento.SelectedValue + "=System.Int32", "@id_key_puesto=" + this.cmbPuesto.SelectedValue + "=System.Int32", "@activo=" + activo.ToString() + "=System.Int32"); if (respuesta != "OK") { MessageBox.Show("Error al crear el registro.", mdPrincipal.Error_SQL, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Registro añadido correctamente."); } this.Close(); }
private void addItem() { clsFunciones clsFunc = new clsFunciones(); String respuesta = String.Empty; clsSQL clsSQL = new clsSQL(); respuesta = clsSQL.ejecutarSP("SP_Man_Servicios", "@opcion=1=System.Int32", "@id_key_servicio=0=System.Int32", "@fecha=" + this.Fecha.Value + "=System.Datetime", "@hora=" + this.Hora.Value + "=System.Datetime", "@id_Key_cliente=" + this.cmbClientes.SelectedValue + "=System.Int32", "@id_key_origen=" + this.cmbDesde.SelectedValue + "=System.Int32", "@id_key_destino=" + this.cmbHasta.SelectedValue + "=System.Int32", "@id_key_empleado=" + this.cmbConductor.SelectedValue + "=System.Int32", "@id_key_vehiculo=" + this.cmbVehiculos.SelectedValue + "=System.Int32", "@Menus=" + this.txtMenus.Text.Trim() + "=System.Decimal", "@Km=" + this.txtKm.Text.Trim() + "=System.Decimal", "@id_key_estado=" + this.cmbEstado.SelectedIndex + "=System.Int32", "@notas=" + this.txtNotas.Text.Trim() + "=System.String"); if (respuesta != "OK") { MessageBox.Show("Error al crear el registro.", mdPrincipal.Error_SQL, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Registro añadido correctamente."); } this.Close(); }
private void cargarCombos() { clsFunciones clsFunc = new clsFunciones(); clsFunc.cargarCombos(cmbClientes, "select nombre,id_key_cliente from Clientes", "nombre", "id_key_cliente", true); clsFunc.cargarCombos(cmbDesde, "select ubicacion,id_key_origen_destino from tg_origen_destino where origen_destino=0", "ubicacion", "id_key_origen_destino", true); clsFunc.cargarCombos(cmbHasta, "select ubicacion,id_key_origen_destino from tg_origen_destino where origen_destino=1", "ubicacion", "id_key_origen_destino", true); clsFunc.cargarCombos(cmbConductor, "select (nombre + apellido1) as nombre,id_key_empleado from Empleados", "nombre", "id_key_empleado", true); clsFunc.cargarCombos(cmbVehiculos, "select matricula,id_key_vehiculo from Vehiculos", "matricula", "id_key_vehiculo", true); }
public void recogerDatos(int _id_key_servicio, DateTime _fecha) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); Fecha.Value = _fecha; if (_id_key_servicio != 0) { dt = clsSQL.devolverDataTable("select * from v_servicios where id_key_servicio = " + _id_key_servicio.ToString()); this.id_key_servicio = _id_key_servicio; foreach (DataRow dr in dt.Rows) { this.Hora.Value = Convert.ToDateTime(dr["Hora"].ToString()); this.cmbClientes.SelectedValue = dr["id_key_cliente"].ToString(); //this.txtCIF.Text = dr["CIF"].ToString(); //this.txtNombre.Text = dr["Nombre"].ToString(); //this.txtDireccion.Text = dr["Direccion_fiscal"].ToString(); ////this.cmbProvincias.SelectedValue = dr["Provincia_fiscal"].ToString(); ////this.txtLocalidad.Text = dr["Localidad_fiscal"].ToString(); //this.txtTelefono.Text = dr["Telefono"].ToString(); //this.txtEmail.Text = dr["Email"].ToString(); //if (dr["vehiculo_activo"].ToString() == "1") //{ // this.chkActivo.Checked = true; //} //else //{ // this.chkActivo.Checked = false; //} } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
public void recogerDatos(int _id_key_cliente) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_cliente != 0) { dt = clsSQL.devolverDataTable("select * from Clientes where id_key_cliente = " + _id_key_cliente.ToString()); this.id_key_cliente = _id_key_cliente; foreach (DataRow dr in dt.Rows) { id_key_cliente = dr.Field <int>("id_key_cliente"); this.txtCIF.Text = dr.Field <string>("CIF"); this.txtNombre.Text = dr.Field <string>("Nombre"); this.txtDireccion.Text = dr["Direccion_fiscal"].ToString(); //this.cmbProvincias.SelectedValue = dr["Provincia_fiscal"].ToString(); //this.txtLocalidad.Text = dr["Localidad_fiscal"].ToString(); this.txtTelefono.Text = dr["Telefono"].ToString(); this.txtEmail.Text = dr["Email"].ToString(); //if (dr["vehiculo_activo"].ToString() == "1") //{ // this.chkActivo.Checked = true; //} //else //{ // this.chkActivo.Checked = false; //} } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
private void addItem() { clsFunciones clsFunc = new clsFunciones(); String respuesta = String.Empty; clsSQL clsSQL = new clsSQL(); int activo = 0; if (this.chkActivo.Checked == true) { activo = 1; } respuesta = clsSQL.ejecutarSP("SP_Man_Clientes", "@opcion=1=System.Int32", "@id_key_cliente=0=System.Int32", "@CIF=" + this.txtCIF.Text.Trim() + "=System.String", "@Nombre=" + this.txtNombre.Text.Trim() + "=System.String", "@Direccion_fiscal=" + this.txtDireccion.Text.Trim() + "=System.String", "@id_key_provincia_fiscal=" + this.cmbProvincias.SelectedValue + "=System.Int32", "@pais_fiscal=spain=System.String", "@CP_fiscal=0=System.Int32", "@Direccion_postal=" + this.txtDireccion.Text.Trim() + "=System.String", "@id_key_provincia_postal=" + this.cmbProvincias.SelectedValue + "=System.Int32", "@pais_postal=spain=System.String", "@CP_postal=0=System.Int32", "@Telefono=" + this.txtTelefono.Text.Trim() + "=System.String", "@Fax=" + this.txtTelefono.Text.Trim() + "=System.String", "@Email=" + this.txtEmail.Text.Trim() + "=System.String", "@web=" + this.txtEmail.Text.Trim() + "=System.String", "@notas=" + this.txtEmail.Text.Trim() + "=System.String"); if (respuesta != "OK") { MessageBox.Show("Error al crear el registro.", mdPrincipal.Error_SQL, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else { MessageBox.Show("Registro añadido correctamente."); } this.Close(); }
public void recogerDatos(int _id_key_empleado) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_empleado != 0) { dt = clsSQL.devolverDataTable("select * from Empleados where id_key_empleado = " + _id_key_empleado.ToString()); this.id_key_empleado = _id_key_empleado; foreach (DataRow dr in dt.Rows) { this.txtNombre.Text = dr["nombre"].ToString(); this.txtApellido1.Text = dr["apellido1"].ToString(); this.txtApellido2.Text = dr["apellido2"].ToString(); this.txtNIF.Text = dr["NIF"].ToString(); this.txtNumSS.Text = dr["num_SS"].ToString(); this.cmbPuesto.SelectedValue = dr["id_key_puesto"].ToString(); this.cmbDepartamento.SelectedValue = dr["id_key_departamento"].ToString(); if (dr["activo"].ToString() == "1") { this.chkActivo.Checked = true; this.fechaBaja.Enabled = false; } else { this.chkActivo.Checked = false; this.fechaBaja.Value = DateTime.Parse(dr["fecha_baja"].ToString()); } this.fechaAlta.Value = DateTime.Parse(dr["fecha_alta"].ToString()); } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
/// <summary> /// Accion para exportar los archivos de un grid a Excel /// </summary> /// <param name="sender"></param> /// <param name="e"></param> /// <remarks></remarks> public static void accionExportar(object sender, System.EventArgs e) { //Try if ((gridMenu != null)) { clsFunciones clsFunc = new clsFunciones(); if (gridMenu == null) { return; } if (gridMenu.RowCount > 0) { clsFunc.exportarAExcel(gridMenu, "Excel"); } } //Catch ex As Exception // MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error) //End Try }
public void aceptar() { this.DialogResult = System.Windows.Forms.DialogResult.OK; if (txtUsuario.Text == string.Empty) { MessageBox.Show("Usuario incorrecto", "Usuario incorrecto", MessageBoxButtons.OK, MessageBoxIcon.Information); txtUsuario.Select(); this.DialogResult = System.Windows.Forms.DialogResult.No; return; } else if (txtPassword.Text == string.Empty) { MessageBox.Show("Password incorrecto", "Password incorrecto", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPassword.Select(); this.DialogResult = System.Windows.Forms.DialogResult.No; return; } else { // Ir a formulario principal clsSQL clsSQL = new clsSQL(); existe = clsSQL.existeConsulta("select usuario from usuarios where usuario = '" + txtUsuario.Text + "' and password = '******' AND ESTADO = 'A'"); if (existe == false) { MessageBox.Show("Fallo de acceso", "Fallo de identificación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtUsuario.Select(); this.DialogResult = System.Windows.Forms.DialogResult.No; } else { clsFunciones Fun = new clsFunciones(); mdPrincipal.Id_Usuario = Convert.ToInt32(clsSQL.devolverUnParametro("usuarios where usuario = '" + txtUsuario.Text + "'", "id_key_usuario")); mdPrincipal.Id_Key_Departamento = Convert.ToInt32(clsSQL.devolverUnParametro("usuarios where usuario = '" + txtUsuario.Text + "'", "id_key_departamento")); mdPrincipal.Usuario = this.txtUsuario.Text; //Fun.grabarLogUsuario("Logon Aplicación", "Usuario : " + mdPrincipal.Usuario); this.DialogResult = System.Windows.Forms.DialogResult.OK; respuesta = true; } } }
public void recogerDatos(int _id_key_vehiculo) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_vehiculo != 0) { dt = clsSQL.devolverDataTable("select * from Vehiculos where id_key_vehiculo = " + _id_key_vehiculo.ToString()); this.id_key_vehiculo = _id_key_vehiculo; foreach (DataRow dr in dt.Rows) { this.txtModelo.Text = dr["modelo"].ToString(); this.txtMarca.Text = dr["marca"].ToString(); this.txtNumBastidor.Text = dr["num_bastidor"].ToString(); this.txtMatricula.Text = dr["matricula"].ToString(); this.cmbTipoVehiculo.SelectedValue = dr["id_key_tipo_vehiculo"].ToString(); this.cmbTipoRuedas.SelectedValue = dr["id_key_tipo_ruedas"].ToString(); if (dr["vehiculo_activo"].ToString() == "1") { this.chkActivo.Checked = true; } else { this.chkActivo.Checked = false; } this.fechaMatriculacion.Value = DateTime.Parse(dr["fecha_matriculacion"].ToString()); } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
public void recogerDatos(int _id_key_ruta) { clsFunciones clsFunc = new clsFunciones(); clsSQL clsSQL = new clsSQL(); DataTable dt = new DataTable(); if (_id_key_ruta != 0) { dt = clsSQL.devolverDataTable("select * from Rutas where id_key_ruta = " + _id_key_ruta.ToString()); this.id_key_ruta = _id_key_ruta; foreach (DataRow dr in dt.Rows) { this.txtDescripcion.Text = dr["descripcion"].ToString(); this.txtOrigen.Text = dr["origen"].ToString(); this.txtDestino.Text = dr["destino"].ToString(); this.txtKm.Text = dr["destino"].ToString(); this.txtPrecio.Text = dr["precio"].ToString(); this.txtPeajes.Text = dr["peajes"].ToString(); if (dr["ruta_activa"].ToString() == "1") { this.chkActivo.Checked = true; } else { this.chkActivo.Checked = false; } } //this.btnNuevoTool.Enabled = true; this.btnAddTool.Enabled = false; this.btnModificarTool.Enabled = true; this.btnEliminarTool.Enabled = true; } else { nuevoItem(); //this.btnNuevoTool.Enabled = true; } }
protected void btnGuardar_Click(object sender, EventArgs e) { try { Docente objDocente = new Docente(); String NombreImagen = ""; if (fluFoto.HasFile) { clsFunciones objFunciones = new clsFunciones(); Object[] rimagen = objFunciones.redimencionar(fluFoto, 200, 200, txtDocumento_Numero.Text); Bitmap newImagen = (Bitmap)rimagen[0]; NombreImagen = (String)rimagen[1]; newImagen.Save(Server.MapPath("~/img/fotos/" + NombreImagen)); } OperacionDocente objOperDocente = new OperacionDocente(ConfigurationManager.ConnectionStrings["estigioacademicoConnectionString"].ConnectionString); objDocente.documento_id_tipo = int.Parse(ddlDocumento_Id_Tipo.SelectedValue.ToString()); objDocente.documento_numero = int.Parse(txtDocumento_Numero.Text); objDocente.nombres = txtDescripcion.Text; objDocente.apellidos = txtApellidos.Text; objDocente.fecha_nacimiento = DateTime.Parse(Request.Form[txtFecha_Nacimiento.UniqueID]); objDocente.id_grupo_sanguineo = int.Parse(ddlGrupo_Sanguineo.SelectedValue.ToString()); objDocente.id_genero = int.Parse(ddlGenero.SelectedValue.ToString()); objDocente.id_grupo_sanguineo = int.Parse(ddlGrupo_Sanguineo.SelectedValue.ToString()); objDocente.email = txtEmail.Text; objDocente.direccion_numero = txtDireccion_Numero.Text; objDocente.direccion_id_municipio = int.Parse(ddlMunicipio.SelectedValue.ToString()); objDocente.telefonos = txtTelefonos.Text; objDocente.id_usuario = int.Parse(Session["id_usuario"].ToString()); string accion = Page.RouteData.Values["Accion"].ToString(); if (accion.Equals("Agregar")) { if (fluFoto.FileName.ToString() == "") { objDocente.foto = "~/img/fotos/usuario.jpg"; } else { objDocente.foto = "~/img/fotos/" + NombreImagen; } objOperDocente.InsertarDocente(objDocente); Response.RedirectToRoute("General", new { Modulo = "Usuario", Entidad = "Docente", Pagina = "Busqueda", Accion = "Agrego" }); } else { if (imgDocente.DescriptionUrl == "/Academico/img/fotos/usuario.jpg") { if (fluFoto.FileName.ToString() == "") { objDocente.foto = "~/img/fotos/usuario.jpg"; } else { objDocente.foto = "~/img/fotos/" + NombreImagen; } } else { if (fluFoto.FileName.ToString() == "") { objDocente.foto = imgDocente.DescriptionUrl.Replace("/Academico", "~"); } else { objDocente.foto = "~/img/fotos/" + NombreImagen; } } objDocente.id = int.Parse(Page.RouteData.Values["id"].ToString()); objOperDocente.ActualizarDocente(objDocente); Response.RedirectToRoute("General", new { Modulo = "Usuario", Entidad = "Docente", Pagina = "Busqueda", Accion = "Edito" }); } //clsFunciones.CleanControl(frmDocente.Controls); } catch (Exception) { } }
private void cargarCombos() { clsFunciones clsFunc = new clsFunciones(); //clsFunc.cargarCombos(cmbProveedor, "select id_Key_proveedor from proveedores", "proveedor", "id_key_proveedor", false); }
/// <summary> /// ''' Mostrar informe pasando los valores directamente de la Base de Datos /// ''' </summary> /// ''' <param name="FileReport">Ruta del informe</param> /// ''' <param name="Username">Usuario de la BBDD</param> /// ''' <param name="Password">Password de la BBDD</param> /// ''' <param name="Servername">Servidor SQL</param> /// ''' <param name="Filter">Filtro opcional a pasarle</param> /// ''' <remarks></remarks> public void PrintLogon(string FileReport, string Username, string Password, string Servername, string Filter = "") { clsFunciones clsFunciones = new clsFunciones(); clsFunciones.grabarLogUsuario("Informes", "Visualizacion informe : " + FileReport + " Filtro: " + Filter); frmVerInformes frmCRNet = new frmVerInformes(); bool IsConnecting = true; ReportDocument crNicasoftStandarReport = new ReportDocument(); Sections crSections; ReportObjects crReportObjects; SubreportObject crSubreportObject; ReportDocument crSubreportDocument; Database crDatabase; Tables crTables; //Table crTable; TableLogOnInfo crTableLogOnInfo; ConnectionInfo crConnectioninfo; string BaseDatos = "TRANSPORTES"; while (IsConnecting) { try { Cursor.Current = Cursors.WaitCursor; crConnectioninfo = new ConnectionInfo(); { var withBlock = crConnectioninfo; withBlock.ServerName = Servername; withBlock.DatabaseName = BaseDatos; withBlock.UserID = Username; withBlock.Password = Password; withBlock.IntegratedSecurity = false; } { var withBlock = frmCRNet; crNicasoftStandarReport.Load(FileReport); crDatabase = crNicasoftStandarReport.Database; crTables = crDatabase.Tables; foreach (Table crTable in crTables) { crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectioninfo; crTableLogOnInfo.ConnectionInfo.IntegratedSecurity = false; crTableLogOnInfo.ConnectionInfo.ServerName = Servername; crTableLogOnInfo.ConnectionInfo.UserID = Username; crTableLogOnInfo.ConnectionInfo.Password = Password; crTableLogOnInfo.ConnectionInfo.DatabaseName = BaseDatos; crTableLogOnInfo.ConnectionInfo.Type = ConnectionInfoType.SQL; crTableLogOnInfo.ReportName = FileReport; crTable.ApplyLogOnInfo(crTableLogOnInfo); } crSections = crNicasoftStandarReport.ReportDefinition.Sections; foreach (Section crSection in crSections) { crReportObjects = crSection.ReportObjects; foreach (ReportObject crReportObject in crReportObjects) { if (crReportObject.Kind == ReportObjectKind.SubreportObject) { crSubreportObject = (SubreportObject)crReportObject; crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName); crDatabase = crSubreportDocument.Database; crTables = crDatabase.Tables; foreach (Table crTable in crTables) { { var withBlock1 = crConnectioninfo; withBlock1.ServerName = Servername; withBlock1.DatabaseName = BaseDatos; withBlock1.UserID = Username; withBlock1.Password = Password; } crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectioninfo; crTable.ApplyLogOnInfo(crTableLogOnInfo); } } } } withBlock.visorRPT.ReportSource = crNicasoftStandarReport; withBlock.visorRPT.LogOnInfo[0].ConnectionInfo.Type = ConnectionInfoType.SQL; if (Filter != "") { withBlock.visorRPT.SelectionFormula = Filter; } withBlock.visorRPT.Refresh(); withBlock.Show(); IsConnecting = false; DidPreviouslyConnect = true; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Cursor.Current = Cursors.Default; frmCRNet.Close(); break; } } }
protected void btnGuardarPersonal_Click(object sender, EventArgs e) { try { /*Estudiante*/ Estudiante objEstudiante = new Estudiante(); String NombreImagen = ""; if (fluFoto.HasFile) { clsFunciones objFunciones = new clsFunciones(); Object[] rimagen = objFunciones.redimencionar(fluFoto, 200, 200, txtDocumento_Numero.Text); Bitmap newImagen = (Bitmap)rimagen[0]; NombreImagen = (String)rimagen[1]; newImagen.Save(Server.MapPath("~/img/fotos/" + NombreImagen)); } OperacionEstudiante objOperEstudiante = new OperacionEstudiante(ConfigurationManager.ConnectionStrings["estigioacademicoConnectionString"].ConnectionString); if (int.Parse(ddlDocumento_Id_Tipo.SelectedValue.ToString()) == 0) { objEstudiante.documento_id_tipo = 4; } else { objEstudiante.documento_id_tipo = int.Parse(ddlDocumento_Id_Tipo.SelectedValue.ToString()); } objEstudiante.documento_numero = Convert.ToInt64(txtDocumento_Numero.Text); if (int.Parse(ddlDocumento_Municipio.SelectedValue.ToString()) == 0) { objEstudiante.documento_id_municipio_expedicion = 2; } else { objEstudiante.documento_id_municipio_expedicion = int.Parse(ddlDocumento_Municipio.SelectedValue.ToString()); } objEstudiante.nombre_1 = txtNombre_1.Text; objEstudiante.nombre_2 = txtNombre_2.Text; objEstudiante.apellido_1 = txtApellido_1.Text; objEstudiante.apellido_2 = txtApellido_2.Text; if (int.Parse(ddlGenero.SelectedValue.ToString()) == 0) { objEstudiante.id_genero = 6; } else { objEstudiante.id_genero = int.Parse(ddlGenero.SelectedValue.ToString()); } if (txtEmail.Text == "") { objEstudiante.email = "@"; } else { objEstudiante.email = txtEmail.Text; } if (Request.Form[txtNacimiento_Fecha.UniqueID].ToString() == "") { objEstudiante.nacimiento_fecha = DateTime.Parse(DateTime.Now.ToShortDateString()); } else { objEstudiante.nacimiento_fecha = DateTime.Parse(Request.Form[txtNacimiento_Fecha.UniqueID].ToString()); } if (int.Parse(ddlNacimiento_Municipio.SelectedValue.ToString()) == 0) { objEstudiante.nacimiento_id_municipio = 912; } else { objEstudiante.nacimiento_id_municipio = int.Parse(ddlNacimiento_Municipio.SelectedValue.ToString()); } if (txtDireccion_Numero.Text == "") { objEstudiante.direccion_numero = "CRA"; } else { objEstudiante.direccion_numero = txtDireccion_Numero.Text; } if (txtDireccion_Barrio.Text == "") { objEstudiante.direccion_barrio = "BAR"; } else { objEstudiante.direccion_barrio = txtDireccion_Barrio.Text; } if (int.Parse(ddlDireccion_Municipio.SelectedValue.ToString()) == 0) { objEstudiante.direccion_id_municipio = 912; } else { objEstudiante.direccion_id_municipio = int.Parse(ddlDireccion_Municipio.SelectedValue.ToString()); } if (int.Parse(ddlZona.SelectedValue.ToString()) == 0) { objEstudiante.zona = 7; } else { objEstudiante.zona = int.Parse(ddlZona.SelectedValue.ToString()); } if (txtTelefono_Fijo.Text == "") { objEstudiante.telefono_fijo = 9999; } else { objEstudiante.telefono_fijo = int.Parse(txtTelefono_Fijo.Text); } if (txtTelefono_Celular.Text == "") { objEstudiante.telefono_celular = 9999; } else { objEstudiante.telefono_celular = int.Parse(txtTelefono_Celular.Text); } objEstudiante.id_usuario = int.Parse(Session["id_usuario"].ToString()); if (txtNumero_Documento_Acudiente_1.Text == "") { objEstudiante.id_acudiente_1 = 1; txtNumero_Documento_Acudiente_1.Text = 1.ToString(); } else { objEstudiante.id_acudiente_1 = int.Parse(txtNumero_Documento_Acudiente_1.Text); } if (txtNumero_Documento_Acudiente_2.Text == "") { objEstudiante.id_acudiente_2 = 1; txtNumero_Documento_Acudiente_2.Text = 1.ToString(); } else { objEstudiante.id_acudiente_2 = int.Parse(txtNumero_Documento_Acudiente_2.Text); } if (int.Parse(ddlEps.SelectedValue.ToString()) == 0) { objEstudiante.id_eps = 972; } else { objEstudiante.id_eps = int.Parse(ddlEps.SelectedValue.ToString()); } if (int.Parse(ddlGrupo_Sanguineo.SelectedValue.ToString()) == 0) { objEstudiante.id_grupo_sanguineo = 9; } else { objEstudiante.id_grupo_sanguineo = int.Parse(ddlGrupo_Sanguineo.SelectedValue.ToString()); } if (txtSisben_Numero.Text == "") { objEstudiante.sisben_numero = 1; } else { objEstudiante.sisben_numero = int.Parse(txtSisben_Numero.Text); } if (int.Parse(ddlSisben_Nivel.SelectedValue.ToString()) == 0) { objEstudiante.sisben_nivel = 1; } else { objEstudiante.sisben_nivel = int.Parse(ddlSisben_Nivel.SelectedValue.ToString()); } if (int.Parse(ddlEstrato.SelectedValue.ToString()) == 0) { objEstudiante.estrato = 1; } else { objEstudiante.estrato = int.Parse(ddlEstrato.SelectedValue.ToString()); } string accion = Page.RouteData.Values["Accion"].ToString(); /*Acudiente 1*/ Acudiente objAcudiente_1 = new Acudiente(); OperacionAcudiente objOperAcudiente = new OperacionAcudiente(ConfigurationManager.ConnectionStrings["estigioacademicoConnectionString"].ConnectionString); if (txtNumero_Documento_Acudiente_1.Text != "") { objAcudiente_1.documento_id_tipo = int.Parse(ddlTipo_Documento_Acudiente_1.SelectedValue.ToString()); objAcudiente_1.documento_numero = Convert.ToInt64(txtNumero_Documento_Acudiente_1.Text); objAcudiente_1.nombres = HttpUtility.HtmlDecode(txtNombres_Acudiente_1.Text); objAcudiente_1.apellidos = HttpUtility.HtmlDecode(txtApellidos_Acudiente_1.Text); objAcudiente_1.id_parentesco = int.Parse(ddlParentesco_Acudiente_1.SelectedValue.ToString()); objAcudiente_1.email = txtEmail_Acudiente_1.Text; objAcudiente_1.direccion_numero = txtDireccion_Numero_Acudiente_1.Text; objAcudiente_1.direccion_barrio = txtDireccion_Barrio_Acudiente_1.Text; objAcudiente_1.direccion_id_municipio = int.Parse(ddlDireccion_Municipio_Acudiente_1.SelectedValue.ToString()); objAcudiente_1.telefonos = txtTelefonos_Acudiente_1.Text; objAcudiente_1.id_usuario = int.Parse(Session["id_usuario"].ToString()); } /*Acudiente 2*/ Acudiente objAcudiente_2 = new Acudiente(); if (txtNumero_Documento_Acudiente_2.Text != "") { objAcudiente_2.documento_id_tipo = int.Parse(ddlTipo_Documento_Acudiente_2.SelectedValue.ToString()); objAcudiente_2.documento_numero = Convert.ToInt64(txtNumero_Documento_Acudiente_2.Text); objAcudiente_2.nombres = HttpUtility.HtmlDecode(txtNombres_Acudiente_2.Text); objAcudiente_2.apellidos = HttpUtility.HtmlDecode(txtApellidos_Acudiente_2.Text); objAcudiente_2.id_parentesco = int.Parse(ddlParentesco_Acudiente_2.SelectedValue.ToString()); objAcudiente_2.email = txtEmail_Acudiente_2.Text; objAcudiente_2.direccion_numero = txtDireccion_Numero_Acudiente_2.Text; objAcudiente_2.direccion_barrio = txtDireccion_Barrio_Acudiente_2.Text; objAcudiente_2.direccion_id_municipio = int.Parse(ddlDireccion_Municipio_Acudiente_2.SelectedValue.ToString()); objAcudiente_2.telefonos = txtTelefonos_Acudiente_2.Text; objAcudiente_2.id_usuario = int.Parse(Session["id_usuario"].ToString()); } if (accion.Equals("Agregar")) { if (fluFoto.FileName.ToString() == "") { objEstudiante.foto = "~/img/fotos/usuario.jpg"; } else { objEstudiante.foto = "~/img/fotos/" + NombreImagen; } if (txtNumero_Documento_Acudiente_1.Text != "" && txtNumero_Documento_Acudiente_2.Text != "") { if (validarAcudiente(int.Parse(txtNumero_Documento_Acudiente_1.Text)) == 0) { objOperAcudiente.InsertarAcudiente(objAcudiente_1); } if (validarAcudiente(int.Parse(txtNumero_Documento_Acudiente_2.Text)) == 0) { objOperAcudiente.InsertarAcudiente(objAcudiente_2); } objOperEstudiante.InsertarEstudiante(objEstudiante); Response.RedirectToRoute("General", new { Modulo = "Usuario", Entidad = "Estudiante", Pagina = "Busqueda", Accion = "Agrego" }); } } else { if (imgEstudiante.DescriptionUrl == "/Academico/img/fotos/usuario.jpg") { if (fluFoto.FileName.ToString() == "") { objEstudiante.foto = "~/img/fotos/usuario.jpg"; } else { objEstudiante.foto = "~/img/fotos/" + NombreImagen; } } else { if (fluFoto.FileName.ToString() == "") { objEstudiante.foto = imgEstudiante.DescriptionUrl.Replace("/Academico", "~"); } else { objEstudiante.foto = "~/img/fotos/" + NombreImagen; } } objEstudiante.id = int.Parse(Page.RouteData.Values["id"].ToString()); if (txtNumero_Documento_Acudiente_1.Text != "" && txtNumero_Documento_Acudiente_2.Text != "") { if (validarAcudiente(int.Parse(txtNumero_Documento_Acudiente_1.Text)) == 0) { objOperAcudiente.InsertarAcudiente(objAcudiente_1); } else { objAcudiente_1.id = clsFunciones.documento_acudiente_1; objOperAcudiente.ActualizarAcudiente(objAcudiente_1); } if (validarAcudiente(int.Parse(txtNumero_Documento_Acudiente_2.Text)) == 0) { objOperAcudiente.InsertarAcudiente(objAcudiente_2); } else { objAcudiente_2.id = clsFunciones.documento_acudiente_2; objOperAcudiente.ActualizarAcudiente(objAcudiente_2); } objOperEstudiante.ActualizarEstudiante(objEstudiante); Response.RedirectToRoute("General", new { Modulo = "Usuario", Entidad = "Estudiante", Pagina = "Busqueda", Accion = "Edito" }); } } } catch (Exception) {} }
/// <summary> /// ''' Mostrar informe pasando los valores de un Procedimiento Almacenado de la Base de Datos /// ''' </summary> /// ''' <param name="FileReport">Ruta del informe</param> /// ''' <param name="Username">Usuario de la BBDD</param> /// ''' <param name="Password">Password de la BBDD</param> /// ''' <param name="Servername">Servidor SQL</param> /// ''' <param name="Filter">Filtro opcional a pasarle</param> /// ''' <remarks></remarks> public void PrintLogonSP(string FileReport, string Username, string Password, string Servername, ParameterFields listadeParametros, string Filter = "", bool GuardarPDF = false, string NombrePdf = "") { clsFunciones clsFunciones = new clsFunciones(); clsFunciones.grabarLogUsuario("Informes", "Visualización informe : " + FileReport + " Filtro: " + Filter); frmVerInformes frmCRNet = new frmVerInformes(); // Dim frmStatusMessage As New frmStatus bool IsConnecting = true; ReportDocument crNicasoftStandarReport = new ReportDocument(); Sections crSections; //Section crSection; ReportObjects crReportObjects; //ReportObject crReportObject; SubreportObject crSubreportObject; ReportDocument crSubreportDocument; Database crDatabase; Tables crTables; //Table crTable; TableLogOnInfo crTableLogOnInfo; ConnectionInfo crConnectioninfo; string BaseDatos = "TRANSPORTES"; // If Not DidPreviouslyConnect Then // frmStatusMessage.Show("Estableciendo conexión...") // End If while (IsConnecting) { try { Cursor.Current = Cursors.WaitCursor; crConnectioninfo = new ConnectionInfo(); { var withBlock = crConnectioninfo; withBlock.ServerName = Servername; withBlock.DatabaseName = BaseDatos; withBlock.UserID = Username; withBlock.Password = Password; withBlock.IntegratedSecurity = false; } { var withBlock = frmCRNet; crNicasoftStandarReport.Load(FileReport); crDatabase = crNicasoftStandarReport.Database; crTables = crDatabase.Tables; foreach (Table crTable in crTables) { crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectioninfo; crTableLogOnInfo.ConnectionInfo.IntegratedSecurity = false; crTableLogOnInfo.ConnectionInfo.ServerName = Servername; crTableLogOnInfo.ConnectionInfo.UserID = Username; crTableLogOnInfo.ConnectionInfo.Password = Password; crTableLogOnInfo.ConnectionInfo.DatabaseName = BaseDatos; crTableLogOnInfo.ConnectionInfo.Type = ConnectionInfoType.SQL; crTableLogOnInfo.ReportName = FileReport; crTable.ApplyLogOnInfo(crTableLogOnInfo); } crSections = crNicasoftStandarReport.ReportDefinition.Sections; foreach (Section crSection in crSections) { crReportObjects = crSection.ReportObjects; foreach (ReportObject crReportObject in crReportObjects) { if (crReportObject.Kind == ReportObjectKind.SubreportObject) { crSubreportObject = (SubreportObject)crReportObject; crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName); crDatabase = crSubreportDocument.Database; crTables = crDatabase.Tables; foreach (Table crTable in crTables) { { var withBlock1 = crConnectioninfo; withBlock1.ServerName = Servername; withBlock1.DatabaseName = BaseDatos; withBlock1.UserID = Username; withBlock1.Password = Password; } crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectioninfo; crTable.ApplyLogOnInfo(crTableLogOnInfo); } } } } withBlock.visorRPT.ReportSource = crNicasoftStandarReport; withBlock.visorRPT.LogOnInfo[0].ConnectionInfo.Type = ConnectionInfoType.SQL; if (Filter != "") { withBlock.visorRPT.SelectionFormula = Filter; } withBlock.visorRPT.ParameterFieldInfo = listadeParametros; withBlock.visorRPT.Refresh(); withBlock.Show(); if (GuardarPDF == true) { // guardar como pdf DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); ExportOptions CrExportOptions; CrDiskFileDestinationOptions.DiskFileName = NombrePdf; CrExportOptions = crNicasoftStandarReport.ExportOptions; { var withBlock1 = CrExportOptions; withBlock1.ExportDestinationType = ExportDestinationType.DiskFile; withBlock1.ExportFormatType = ExportFormatType.PortableDocFormat; withBlock1.DestinationOptions = CrDiskFileDestinationOptions; withBlock1.FormatOptions = CrFormatTypeOptions; } // guradamos el documento el el temporal de win crNicasoftStandarReport.ExportToDisk(ExportFormatType.PortableDocFormat, Path.GetTempPath() + @"\" + NombrePdf + ".pdf"); withBlock.Close(); } IsConnecting = false; DidPreviouslyConnect = true; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Cursor.Current = Cursors.Default; frmCRNet.Close(); break; } } }
/// <summary> /// ''' Imprime el Report directamente en archivo con la ruta pasada y el tipo de archivo /// ''' </summary> /// ''' <param name="FileReport">Ruta del Report</param> /// ''' <param name="Username">usuario Base datos</param> /// ''' <param name="Password">password del usuario Base de datos</param> /// ''' <param name="Servername">Servidor de la Base de Datos</param> /// ''' <param name="listadeParametros">parametros para el crystal</param> /// ''' <param name="_rutadestinoAGuardar">Ruta donde se guarda el archivo</param> /// ''' <param name="Export">Tipo de Archivo a guardar</param> /// ''' <remarks></remarks> public void PrintEnArchivoSP(string FileReport, string Username, string Password, string Servername, DataTable dtParametros, string _rutadestinoAGuardar = "", CrystalDecisions.Shared.ExportFormatType Export = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat) { clsFunciones clsFunciones = new clsFunciones(); frmVerInformes frmCRNet = new frmVerInformes(); bool IsConnecting = true; ReportDocument crNicasoftStandarReport = new ReportDocument(); Sections crSections; ReportObjects crReportObjects; SubreportObject crSubreportObject; ReportDocument crSubreportDocument; Database crDatabase; Tables crTables; TableLogOnInfo crTableLogOnInfo; ConnectionInfo crConnectioninfo; string BaseDatos = "TRANSPORTES"; while (IsConnecting) { try { Cursor.Current = Cursors.WaitCursor; crConnectioninfo = new ConnectionInfo(); { var withBlock = crConnectioninfo; withBlock.ServerName = Servername; withBlock.DatabaseName = BaseDatos; withBlock.UserID = Username; withBlock.Password = Password; withBlock.IntegratedSecurity = false; } { var withBlock = frmCRNet; crNicasoftStandarReport.Load(FileReport); crDatabase = crNicasoftStandarReport.Database; crTables = crDatabase.Tables; foreach (Table crTable in crTables) { crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectioninfo; crTableLogOnInfo.ConnectionInfo.IntegratedSecurity = false; crTableLogOnInfo.ConnectionInfo.ServerName = Servername; crTableLogOnInfo.ConnectionInfo.UserID = Username; crTableLogOnInfo.ConnectionInfo.Password = Password; crTableLogOnInfo.ConnectionInfo.DatabaseName = BaseDatos; crTableLogOnInfo.ConnectionInfo.Type = ConnectionInfoType.SQL; crTableLogOnInfo.ReportName = FileReport; crTable.ApplyLogOnInfo(crTableLogOnInfo); } crSections = crNicasoftStandarReport.ReportDefinition.Sections; foreach (Section crSection in crSections) { crReportObjects = crSection.ReportObjects; foreach (ReportObject crReportObject in crReportObjects) { if (crReportObject.Kind == ReportObjectKind.SubreportObject) { crSubreportObject = (SubreportObject)crReportObject; crSubreportDocument = crSubreportObject.OpenSubreport(crSubreportObject.SubreportName); crDatabase = crSubreportDocument.Database; crTables = crDatabase.Tables; foreach (Table crTable in crTables) { { var withBlock1 = crConnectioninfo; withBlock1.ServerName = Servername; withBlock1.DatabaseName = BaseDatos; withBlock1.UserID = Username; withBlock1.Password = Password; } crTableLogOnInfo = crTable.LogOnInfo; crTableLogOnInfo.ConnectionInfo = crConnectioninfo; crTable.ApplyLogOnInfo(crTableLogOnInfo); } } } } withBlock.visorRPT.ReportSource = crNicasoftStandarReport; withBlock.visorRPT.LogOnInfo[0].ConnectionInfo.Type = ConnectionInfoType.SQL; foreach (DataRow dr in dtParametros.Rows) { crNicasoftStandarReport.SetParameterValue(dr["nombre_parametro"].ToString(), dr["valor_parametro"].ToString()); } crNicasoftStandarReport.ExportToDisk(ExportFormatType.PortableDocFormat, _rutadestinoAGuardar); IsConnecting = false; DidPreviouslyConnect = true; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Cursor.Current = Cursors.Default; frmCRNet.Close(); break; } } }
/// <summary> /// Ejecutar sentencia SQL que no sea SELECT (INSERT,UPDATE,DELETE) /// </summary> /// <param name="_sql">Sentencia SQL a ejecutar</param> /// <returns>True si ha hecho bien la ejecución</returns> /// <remarks></remarks> public bool ejecutarQuery(string _sql, bool noImportaFilasProcesadas = false) { SqlConnection conSql = new SqlConnection(mdPrincipal.Cadena_Conexion_SQL); clsFunciones clsFunc = new clsFunciones(); conSql.Open(); try { string tabla = string.Empty; string[] matrizTabla = null; bool devuelve = false; SqlCommand cmdSql = new SqlCommand(_sql, conSql); if (cmdSql.ExecuteNonQuery() > 0) { devuelve = true; } else { if (noImportaFilasProcesadas == false) { devuelve = false; } else { devuelve = true; } } cmdSql.Dispose(); if (_sql.ToUpper().Contains("DELETE") == true) { tabla = _sql.Replace(" ", "|"); matrizTabla = tabla.Split('|'); tabla = matrizTabla[2]; clsFunc.grabarLogUsuario("Delete en tabla: " + tabla, "Delete en la tabla: " + tabla); } if (_sql.ToUpper().Contains("UPDATE") == true) { tabla = _sql.Replace(" ", "|"); matrizTabla = tabla.Split('|'); tabla = matrizTabla[1]; clsFunc.grabarLogUsuario("Modif. tabla: " + tabla, "Modificación en la tabla: " + tabla); } if (_sql.ToUpper().Contains("INSERT") == true) { tabla = _sql.Replace(" ", "|"); matrizTabla = tabla.Split('|'); tabla = matrizTabla[2]; clsFunc.grabarLogUsuario("INSERT en tabla: " + tabla, "INSERT en la tabla: " + tabla); } return(devuelve); } catch (Exception ex) { MessageBox.Show(ex.Message); return(false); } finally { conSql.Dispose(); } }
/// <summary> /// Ejecuta un SP pasando un DataTable con los valores del SP /// </summary> /// <param name="_dt">DataTable con los valores del SP</param> /// <returns>Un DataTable con los valores de retorno</returns> /// <remarks></remarks> public DataTable ejecutarSPdt(DataTable _dt) { DataTable devuelveDT = new DataTable(); clsFunciones clsFunc = new clsFunciones(); SqlConnection conSQL = new SqlConnection(mdPrincipal.Cadena_Conexion_SQL); SqlCommand cmdSQL = new SqlCommand(_dt.TableName, conSQL); cmdSQL.CommandType = CommandType.StoredProcedure; cmdSQL.CommandTimeout = 600; devuelveDT.Columns.Add("retorno", Type.GetType("System.String")); SqlParameterCollection paramColl = cmdSQL.Parameters; try { foreach (DataColumn col in _dt.Columns) { SqlParameter valorEntrada = new SqlParameter(); valorEntrada.ParameterName = col.ColumnName; valorEntrada.Direction = ParameterDirection.Input; valorEntrada.Value = _dt.Rows[0][col]; valorEntrada.SqlDbType = verSqlType(col.DataType.ToString()); if (valorEntrada.SqlDbType.ToString().ToUpper() == "SYSTEM.DECIMAL") { valorEntrada.Value = clsFunc.ponerDecimales(_dt.Rows[0][col].ToString()); if ((string)valorEntrada.Value == string.Empty) { valorEntrada.Value = 0; } } paramColl.Add(valorEntrada); } SqlParameter valorRetorno = new SqlParameter("@msgerror", SqlDbType.VarChar, 200); valorRetorno.Direction = ParameterDirection.Output; paramColl.Add(valorRetorno); conSQL.Open(); cmdSQL.ExecuteNonQuery(); devuelveDT.Rows.Add(valorRetorno.Value); return(devuelveDT); } catch (Exception ex) { devuelveDT.Rows.Add(ex.ToString()); return(devuelveDT); } finally { conSQL.Close(); } }
public void CargarCombos() { clsFunciones clsFunc = new clsFunciones(); clsFunc.cargarCombos(cmbProvincias, "select id_key_provincia,provincia from tg_provincias", "provincia", "id_key_provincia", true); }
/// <summary> /// Ejecuta Stored Procedure pasando el Nombre y los parametros con sus valores /// </summary> /// <param name="_nombreSp">Nombre del Stored Procedure de la Base de Datos</param> /// <param name="parametros">Array de los parametros y valores siguiendo el patron "@parametro=valor=System.Tipo"</param> /// <returns>Valor del retorno como String</returns> /// <remarks></remarks> public string ejecutarSP(string _nombreSp, params object[] parametros) { clsFunciones clsFunc = new clsFunciones(); SqlConnection conSQL = new SqlConnection(mdPrincipal.Cadena_Conexion_SQL); SqlCommand cmdSQL = new SqlCommand(_nombreSp, conSQL); cmdSQL.CommandType = CommandType.StoredProcedure; cmdSQL.CommandTimeout = 600; SqlParameterCollection paramColl = cmdSQL.Parameters; try { foreach (object parametro in parametros) { //**** Creamos la matriz cogiendo el primer igual y el último //**** Por si meten algún signo igual en el parámetro a insertar int posprimerIgual = parametro.ToString().IndexOf("="); string primerParametro = parametro.ToString().Substring(0, posprimerIgual); int posultimoIgual = parametro.ToString().LastIndexOf("="); string tercerParametro = parametro.ToString().Substring(posultimoIgual + 1, parametro.ToString().Length - (posultimoIgual + 1)); string segundoParametro = parametro.ToString().Substring(posprimerIgual + 1, posultimoIgual - (posprimerIgual + 1)); string[] matriz = { primerParametro, segundoParametro, tercerParametro }; string parametro_sp = matriz[0]; SqlParameter valorEntrada = new SqlParameter(); valorEntrada.ParameterName = parametro_sp; valorEntrada.Direction = ParameterDirection.Input; valorEntrada.Value = matriz[1]; valorEntrada.SqlDbType = verSqlType(matriz[2]); if (matriz[2].ToString().ToUpper() == "SYSTEM.DECIMAL") { valorEntrada.Value = clsFunc.ponerDecimales(matriz[1]); if ((string)valorEntrada.Value == string.Empty) { valorEntrada.Value = 0; } } if (matriz[2].ToString().ToUpper() == "SYSTEM.IMAGE") { if (valorEntrada.Value.ToString().ToUpper() == "NULL") { valorEntrada.Value = DBNull.Value; } if (valorEntrada.Value.ToString().ToUpper() == string.Empty) { valorEntrada.Value = DBNull.Value; } } paramColl.Add(valorEntrada); } SqlParameter valorRetorno = new SqlParameter("@msgerror", SqlDbType.VarChar, 200); valorRetorno.Direction = ParameterDirection.Output; paramColl.Add(valorRetorno); conSQL.Open(); cmdSQL.ExecuteNonQuery(); return(valorRetorno.Value.ToString()); } catch (Exception ex) { return(ex.ToString()); } finally { conSQL.Close(); } }
private void cargaServicios() { clsFunciones clsFunc = new clsFunciones(); // Hora DataGridViewTextBoxColumn colHora = new DataGridViewTextBoxColumn(); colHora.DataPropertyName = "PropHora"; colHora.HeaderText = "HORA"; colHora.Name = "Hora"; //// Formato hora /////colHora.DefaultCellStyle.Format = "hh:mm"; ///// ////int time = Convert.ToInt32(row.Cells[1].Value); ////var timeSpan = TimeSpan.FromMinutes(time); ////int hh = timeSpan.Hours; ////int mm = timeSpan.Minutes; ////int ss = timeSpan.Seconds; ////string hours = hh.ToString().Length == 1 ? hh.ToString().PadLeft(2, '0') : hh.ToString(); ////string minutes = mm.ToString().Length == 1 ? mm.ToString().PadLeft(2, '0') : mm.ToString(); ////string seconds = ss.ToString().Length == 1 ? ss.ToString().PadLeft(2, '0') : ss.ToString(); ////colHora.DefaultCellStyle.Format = colHora.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; colHora.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdAgenda.Columns.Add(colHora); uneColumnas(); //grdAgenda.Rows[0] //grdAgenda.Columns["Hora"].DefaultCellStyle.Format= @"hh\:mm"; ////grdAgenda.Columns[0].DefaultCellStyle.NullValue = "00:00:00"; //// Cliente DataGridViewComboBoxColumn colCliente = new DataGridViewComboBoxColumn(); colCliente.DataPropertyName = "PropCliente"; colCliente.HeaderText = "CLIENTE"; colCliente.Name = "Cliente"; colCliente.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; colCliente.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdAgenda.Columns.Add(colCliente); // Desde DataGridViewComboBoxColumn colDesde = new DataGridViewComboBoxColumn(); colDesde.DataPropertyName = "PropDesde"; colDesde.HeaderText = "DESDE"; colDesde.Name = "Desde"; colDesde.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; colDesde.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdAgenda.Columns.Add(colDesde); // Hasta DataGridViewComboBoxColumn colHasta = new DataGridViewComboBoxColumn(); colHasta.DataPropertyName = "PropHasta"; colHasta.HeaderText = "HASTA"; colHasta.Name = "Hasta"; colHasta.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; colHasta.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdAgenda.Columns.Add(colHasta); // Conductor DataGridViewComboBoxColumn colConductor = new DataGridViewComboBoxColumn(); colConductor.DataPropertyName = "PropConductor"; colConductor.HeaderText = "CONDUCTOR"; colConductor.Name = "Conductor"; colConductor.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; colConductor.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdAgenda.Columns.Add(colConductor); // Vehiculo DataGridViewComboBoxColumn colVehiculo = new DataGridViewComboBoxColumn(); colVehiculo.DataPropertyName = "PropVehiculo"; colVehiculo.HeaderText = "VEHICULO"; colVehiculo.Name = "Vehiculo"; colVehiculo.DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; colVehiculo.HeaderCell.Style.Alignment = DataGridViewContentAlignment.MiddleCenter; grdAgenda.Columns.Add(colVehiculo); grdAgenda.Rows.Add(); grdAgenda.Rows.Add(); grdAgenda.Rows.Add(); }
/// <summary> /// Ejecuta Stored Procedure pasando el Nombre y los parametros con sus valores /// </summary> /// <param name="_nombreSp">Nombre del Stored Procedure de la Base de Datos</param> /// <param name="parametros">Array de los parametros y valores siguiendo el patron "@parametro=valor=System.Tipo"</param> /// <returns>Valor del retorno como un SqlCommand</returns> /// <remarks></remarks> public SqlCommand ejecutarSPSelect(string _nombreSp, params object[] parametros) { clsFunciones clsFunc = new clsFunciones(); SqlConnection conSQL = new SqlConnection(mdPrincipal.Cadena_Conexion_SQL); SqlCommand cmdSQL = new SqlCommand(_nombreSp, conSQL); cmdSQL.CommandType = CommandType.StoredProcedure; cmdSQL.CommandTimeout = 600; SqlParameterCollection paramColl = cmdSQL.Parameters; try { foreach (object parametro in parametros) { object[] matriz = parametro.ToString().Split('='); string parametro_sp = matriz[0].ToString(); SqlParameter valorEntrada = new SqlParameter(); valorEntrada.ParameterName = parametro_sp; valorEntrada.Direction = ParameterDirection.Input; valorEntrada.Value = matriz[1]; valorEntrada.SqlDbType = verSqlType(matriz[2].ToString()); if (matriz[2].ToString().ToUpper() == "SYSTEM.DECIMAL") { valorEntrada.Value = clsFunc.ponerDecimales(matriz[1].ToString()); if ((string)valorEntrada.Value == string.Empty) { valorEntrada.Value = 0; } } if (matriz[2].ToString().ToUpper() == "SYSTEM.IMAGE") { if (valorEntrada.Value.ToString().ToUpper() == "NULL") { valorEntrada.Value = null; } } paramColl.Add(valorEntrada); } SqlParameter valorRetorno = new SqlParameter("@msgerror", SqlDbType.VarChar, 200); valorRetorno.Direction = ParameterDirection.Output; paramColl.Add(valorRetorno); conSQL.Open(); return(cmdSQL); } catch (SqlException ex) { return(new System.Data.SqlClient.SqlCommand(ex.Message)); } finally { conSQL.Close(); } }