private List <Adelantos> crear_tmp_list(DateTime desde, DateTime hasta, List <DAL.Empleados> lista_asignados) { TimeSpan ts = hasta - desde; int dias = ts.Days; List <Adelantos> lista_adelantos = new List <Adelantos>(); List <Adelantos> lista_tmp = new List <Adelantos>(); Empleados empleados = new Empleados(); try { for (int i = 0; i <= dias; i++) { DateTime fecha = desde.AddDays(i); Adelantos adelanto = new Adelantos(); lista_adelantos = adelanto.obtener_registro_por_fecha(fecha, lista_asignados); lista_tmp.AddRange(lista_adelantos); } } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); } return(lista_tmp); }
private void btnPrint_Click(object sender, System.EventArgs e) { if (!imprimiendo) { if (clbTrabajosPendientes.CheckedItems.Count > 0) { prepararImpresion(); if (richTextBoxPrintCtrl1.Text.Length > 0) { if (printDialog1.ShowDialog() == DialogResult.OK) { try { printDocument1.Print(); } catch (Exception ex) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "btnPrint_Click", 0, "Error al intentar Imprimir: " + printDocument1.PrinterSettings.PrinterName, ex.Message, "", true, LogManager.EMensaje.Critico, ex.StackTrace); Notify(m); } } } } } }
public void mostrar() { List <string> ids = new List <string>(); try { DAL.Empleados empleados = new DAL.Empleados(); DataTable dt = empleados.ObtenerDataTable("DataTable1", txtEmpleadoEstado.Text); rv1.LocalReport.ReportPath = Server.MapPath("~/Reports/PersonalReporte.rdlc"); rv1.ProcessingMode = ProcessingMode.Local; ReportDataSource datasource = new ReportDataSource("DataSet1", dt); rv1.LocalReport.DataSources.Clear(); rv1.LocalReport.DataSources.Add(datasource); rv1.Enabled = true; rv1.Visible = true; rv1.ExportContentDisposition = ContentDisposition.AlwaysInline; } catch (Exception Exception) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.Forms.FrmReporteAdelantos", "mostrar", 0, "Error al intentar mostrar el documento.", Exception.Message, "", true, LogManager.EMensaje.Critico, Exception.StackTrace); //Notify(m); } }
private void btnPrintPreview_Click(object sender, System.EventArgs e) { if (!imprimiendo) { if (clbTrabajosPendientes.CheckedItems.Count > 0) { try { prepararImpresion(); if (richTextBoxPrintCtrl1.Text.Length > 0) { printPreviewDialog1.ShowDialog(); } } catch (Exception ex) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "btnPrintPreview_Click", 0, "Impresora invalida (si es una impresora de red verificar que este encendida)" + printDocument1.PrinterSettings.PrinterName, ex.Message, "", true, LogManager.EMensaje.Critico, ex.StackTrace); Notify(m); } } } }
private void imprimirProximo() { try { clbTrabajosPendientes.SetItemChecked(0, true); prepararImpresion(); if (richTextBoxPrintCtrl1.Text.Length > 0) { printDocument1.Print(); } } catch (Exception ex) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "imprimirProximo", 0, "Impresora invalida (si es una impresora de red verificar que este encendida)" + printDocument1.PrinterSettings.PrinterName, ex.Message, "", true, LogManager.EMensaje.Critico, ex.StackTrace); Notify(m); } }
private void printDocument1_EndPrint(object sender, PrintEventArgs e) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion", "printDocument1_EndPrint", 0, "Se imprimio: " + printDocument1.DocumentName, "", "", true, LogManager.EMensaje.Informativo, ""); Notify(m); if (!btnRefrescar.Enabled) { documentos.quitarDocumento(clbTrabajosPendientes.SelectedValue.ToString()); } else if (MessageBox.Show("El documento fue enviado a la impresora.\n\n" + "¿Desea marcarlo como impreso y quiralo de la cola de impresión?", "Atención", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { documentos.quitarDocumento(clbTrabajosPendientes.SelectedValue.ToString()); } imprimiendo = false; }
/// <summary> /// Limpio los datos de los atributos de la instancia /// </summary> private void limpiaDatos() { this.Id = 0; this.cliente = null; this.nombre = null; this.apellido = null; this.email = null; this.Activo = true; this.password = null; this.usuario = null; this.usu_alta = null; this.usu_baja = null; this.usu_modificacion = null; this.chk_alta_doc = false; this.chk_baja_doc = false; chk_modificacion_doc = false; this.ruta_compartida = null; this.ruta_origen = null; this.nombre_pc = null; this.acceso = EAcceso.Sin_Acceso; this.nivel = EANivel.Usuario; UltimoMensaje = null; this.dir_local = null; }
public void Guardar(int id) { UltimoMensaje = null; DAL.Database db = new Database(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand(); if (id == 0) { comando.CommandText = "INSERT INTO empleados_adelantos (fecha, empleado_id, descripcion, importe) values " + "(@fecha,@empleado_id, @descripcion,@importe)"; } else { comando.CommandText = "UPDATE empleados_adelantos SET fecha = @fecha," + " empleado_id = @empleado_id, descripcion = @descripcion, importe=@importe " + "where adelanto_id = @id"; comando.Parameters.AddWithValue("@id", id); } comando.Parameters.AddWithValue("@fecha", Convert.ToDateTime(fecha)); comando.Parameters.AddWithValue("@empleado_id", empleado_id); comando.Parameters.AddWithValue("@descripcion", descripcion); comando.Parameters.AddWithValue("@importe", Convert.ToDecimal(importe)); comando.Transaction = Database.obtenerTransaccion(); comando.Connection = conexion; try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } var valor = comando.ExecuteScalar(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.StackTrace = ex.StackTrace; UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } }
public Empleados_Adelantos obtener_datos(string id) { Empleados_Adelantos emp_adelanto = new Empleados_Adelantos(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); cmd.CommandText = @"SELECT empleados_adelantos.*, empleados.nombre, empleados.apellido FROM empleados_adelantos join empleados on empleados_adelantos.empleado_id = empleados.id where adelanto_id=@id"; cmd.Parameters.AddWithValue("@id", id); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { emp_adelanto.adelanto_id = Convert.ToInt32(reader["adelanto_id"].ToString()); emp_adelanto.fecha = Convert.ToDateTime(reader["fecha"]).ToShortDateString(); emp_adelanto.empleado_id = Convert.ToInt32(reader["empleado_id"]); emp_adelanto.empleado = reader["apellido"].ToString() + ", " + reader["nombre"].ToString(); emp_adelanto.descripcion = reader["descripcion"].ToString(); emp_adelanto.importe = Convert.ToDecimal(reader["importe"].ToString()); emp_adelanto.asignado_por = reader["asignado_por"].ToString(); } reader.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(emp_adelanto); }
public List <EmpleadosGrupos> obtener(string codigo = "") { string where = ""; if (codigo != "") { where += " where id=@codigo "; } List <EmpleadosGrupos> ret = new List <EmpleadosGrupos>(); UltimoMensaje = null; DAL.Database db = new Database(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); cmd.CommandText = "select * from empleados_grupos" + where + " order by nombre"; cmd.Parameters.AddWithValue("@codigo", codigo); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { EmpleadosGrupos bar = new EmpleadosGrupos(); cargarDatos(bar, reader); ret.Add(bar); } reader.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(ret); }
public bool ObtenerAcceso(string codigo, string acceso) { limpiaDatos(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand( "SELECT * " + "FROM roles " + "WHERE rol_usuario = @rol_usuario " , conexion); comando.Parameters.AddWithValue("@rol_usuario", codigo); comando.Parameters.AddWithValue("@rol_acceso", acceso); comando.Transaction = Database.obtenerTransaccion(); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader dr = comando.ExecuteReader(); if (dr.Read()) { string est = dr[acceso].ToString(); if (est == "1") { return(true); } else { return(false); } } return(true); dr.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); return(false); } }
private List <Gastos> crear_lista_gastos(string desde, string hasta) { List <Gastos> ret = new List <Gastos>(); UltimoMensaje = null; DAL.Database db = new Database(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); cmd.CommandText = @"select * from (SELECT empleados_grupos.*, gastos.fecha, gastos.detalles, gastos.importe from empleados_grupos LEFT JOIN gastos on gastos.grupo = empleados_grupos.id) as base where (fecha BETWEEN @fecha1 AND @fecha2) or fecha IS NULL"; cmd.Parameters.AddWithValue("@fecha1", Convert.ToDateTime(desde)); cmd.Parameters.AddWithValue("@fecha2", Convert.ToDateTime(hasta)); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Gastos bar = new Gastos(); bar.fecha = Convert.ToDateTime(reader["fecha"].ToString()).ToShortDateString(); bar.grupo_nombre = reader["nombre"].ToString(); bar.importe = Convert.ToDecimal(reader["importe"].ToString()); bar.detalles = reader["detalles"].ToString(); ret.Add(bar); } reader.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(ret); }
private void obtenerDatosFiltrados(bool todos, DAL.ItemOrden[] orden, DAL.ItemFiltro[] filtro) { int paginaActual = pagPaginador.obtenerPaginaActual(); int tamañoPagina = pagPaginador.obtenerRegistrosMostrar(); int registroInicio = ((paginaActual - 1) * tamañoPagina) + 1; int registroFin; if (todos) { registroFin = -1; } else { registroFin = tamañoPagina * paginaActual; } DAL.Empleados VistaEmpleados = new DAL.Empleados(); VistaEmpleados.Subscribe(this); double cantidadRegistros = 0; List <DAL.Empleados> datosObtenidos = VistaEmpleados.obtenerFiltrado(filtro, orden, false, registroInicio, registroFin, out cantidadRegistros, false); if (VistaEmpleados.UltimoMensaje != null) { UltimoMensaje = VistaEmpleados.UltimoMensaje; Notify(UltimoMensaje); return; } ArrayList lista = new ArrayList(); foreach (DAL.Empleados item in datosObtenidos) { var itemLista = new { Id = item.Id, Apellido = item.Apellido, Nombre = item.Nombre, Mail = item.Mail, Grupo = item.Grupo }; lista.Add(itemLista); } cargarGrilla(lista); calcularTotalPaginas(tamañoPagina, cantidadRegistros); pagPaginador.setPaginaActual(paginaActual); }
public List <Cliente> obtener() { limpiaDatos(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand( "SELECT * " + "FROM vw_cliente " , conexion); comando.Transaction = Database.obtenerTransaccion(); List <Cliente> cli = new List <Cliente>(); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader dr = comando.ExecuteReader(); while (dr.Read()) { Cliente t = new Cliente(); cargarDatos(t, dr); cli.Add(t); } return(cli); dr.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); return(cli); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } }
public List <ComprobanteItem> obtener(ComprobanteEncabezado comprobanteEncabezado) { limpiaDatos(); List <ComprobanteItem> ret = new List <ComprobanteItem>(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand( "SELECT * " + "FROM comprobanteitem " + "WHERE cen_id = @cen_id " + "Order by cim_orden" , conexion); comando.Parameters.AddWithValue("@cen_id", comprobanteEncabezado.Id); comando.Transaction = Database.obtenerTransaccion(); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader dr = comando.ExecuteReader(); while (dr.Read()) { ComprobanteItem ci = new ComprobanteItem(); cargarDatos(ci, dr); ret.Add(ci); } dr.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(ret); }
/// <summary> /// Carga en la instacia actual los atributos del Id pasado por parámetro /// </summary> public static List <IAlicuotaIva> obtenerLista(string texto) { //limpiaDatos(); List <IAlicuotaIva> retorno = new List <IAlicuotaIva>(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand( "SELECT * " + "FROM " + dbTabla + " WHERE " + dbCampoNombre + " LIKE @query " , conexion); comando.Transaction = Database.obtenerTransaccion(); comando.Parameters.AddWithValue("@query", "%" + texto + "%"); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader dr = comando.ExecuteReader(); while (dr.Read()) { AlicuotaIva p = new AlicuotaIva(); cargarDatos(p, dr); retorno.Add(p); } dr.Close(); } catch (Exception ex) { retorno = null; LogManager.Mensaje UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; LogManager.Log.log(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(retorno); }
public string obtener_sitio(DateTime fecha, string empleado_id) { string sitio = "NO TRABAJO"; MySqlConnection conexion = Database.obtenerConexion(true); string consulta = @" SELECT sitio_id, trabajo, sitios.Nombre as sitio_nombre from empleados_tareas left join sitios on sitio_id = sitios.CellID WHERE empleadoId=@empleado_id AND (@fecha BETWEEN fecha_inicio AND fecha_fin) AND trabajo='SI'"; MySqlCommand cmd = new MySqlCommand(consulta, conexion); cmd.Parameters.AddWithValue("@fecha", fecha); cmd.Parameters.AddWithValue("@empleado_id", empleado_id); cmd.Transaction = Database.obtenerTransaccion(); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { sitio = reader["sitio_id"] + " - " + reader["sitio_nombre"].ToString(); } } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(sitio); }
public static string obtenerRutaOrigen() { if (ruta_origen == null) { MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand( "SELECT * " + "FROM parametros " + "WHERE par_pc = @par_pc" , conexion); comando.Parameters.AddWithValue("@par_pc", Environment.MachineName); comando.Transaction = Database.obtenerTransaccion(); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader dr = comando.ExecuteReader(); if (dr.Read()) { ruta_origen = dr["par_rutaCompartida"].ToString(); } dr.Close(); } catch (Exception ex) { LogManager.Mensaje UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; UltimoMensaje.TipoMensaje = LogManager.EMensaje.Critico; LogManager.Log.log(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } } return(ruta_origen); }
/// <summary> /// Limpio los datos de los atributos de la instancia /// </summary> private void limpiaDatos() { this.Id = 0; this.Nombre = null; this.fecha_desde = DateTime.Now; this.fecha_hasta = DateTime.Now; this.titulo = null; UltimoMensaje = null; }
public bool existe_en_otros_registros(string id) { bool ret = false; UltimoMensaje = null; DAL.Database db = new Database(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand(); comando.CommandText = "select count(*) from empleados where grupo = @id"; comando.Parameters.AddWithValue("@id", id); comando.Transaction = Database.obtenerTransaccion(); comando.Connection = conexion; int registros = 0; try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } int.TryParse(comando.ExecuteScalar().ToString(), out registros); if (registros > 0) { ret = true; } } catch (Exception ex) { ret = true; UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.StackTrace = ex.StackTrace; UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(ret); }
/// <summary> /// Limpio los datos de los atributos de la instancia /// </summary> private void limpiaDatos() { Id = 0; Codigo = null; CodigoFabricante = null; Descripcion = null; Costo = 0; UltimoMensaje = null; }
public Empleados login(string usuario, string pass) { Empleados res = new Empleados(); if (!usuario.Contains("@")) { usuario += "@telesoluciones.net"; } MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); cmd.CommandText = "select * from empleados where mail=@usuario and password=@password"; cmd.Parameters.AddWithValue("@usuario", usuario); cmd.Parameters.AddWithValue("@password", pass); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { cargarDatos(res, reader); } } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(res); }
// Unsubscribe #endregion /// <summary> /// Utilizado para quitar un documento por impresión correcta /// </summary> /// <param name="idDocumento">ClassId + _ + Id del registro a quitar </param> public void quitarDocumento(string idDocumento) { if (!idDocumento.StartsWith(classId + "_")) { return; } int id = int.Parse(idDocumento.Replace(classId + "_", "")); //int id = int.Parse(clbTrabajosPendientes.SelectedValue.ToString()); MySqlConnection cone = new MySqlConnection(ConfigurationManager.ConnectionStrings["ce"].ConnectionString); MySqlCommand cmd = new MySqlCommand("UPDATE libroivaventas SET lvt_estadoimpresion = 1, " + "lvt_fechaimpresion = NOW() " + "WHERE lvt_id=@lvt_id", cone); cmd.Parameters.AddWithValue("@lvt_id", id); try { cone.Open(); cmd.ExecuteNonQuery(); LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion.builders.LibroDeIva", "quitarDocumento", 0, "El libro de IVA se quito correctamente de la cola de impresión.", "", "", false, LogManager.EMensaje.Informativo, null); Notify(m); //refrescarLista(); } catch (Exception Exception) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion.builders.LibroDeIva", "quitarDocumento", 0, "Error al intentar quitar el libro de IVA de la cola de impresión.", Exception.Message, "", true, LogManager.EMensaje.Critico, Exception.StackTrace); Notify(m); } finally { if (cone.State != ConnectionState.Closed) { cone.Close(); } } }
} // Unsubscribe #endregion public void obtener(string usuario, string contraseña) { limpiaDatos(); MySqlConnection conexion = Database.obtenerConexion(true); ; MySqlCommand comando = new MySqlCommand( "SELECT * " + "FROM usuarios " + "WHERE usu_usuario = @usu_usuario and usu_password = @usu_password" , conexion); comando.Parameters.AddWithValue("@usu_usuario", usuario); comando.Parameters.AddWithValue("@usu_password", Comun.CryptoUtil.GetMd5Hash(contraseña)); comando.Transaction = Database.obtenerTransaccion(); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader dr = comando.ExecuteReader(); if (dr.Read()) { cargarDatos(this, dr); } dr.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } }
public Gastos obtener_gastos(string id) { Gastos tmp = new Gastos(); UltimoMensaje = null; DAL.Database db = new Database(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); cmd.CommandText = @"select * from gastos where id=@id"; cmd.Parameters.AddWithValue("@id", id); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { tmp.fecha = Convert.ToDateTime(reader["fecha"].ToString()).ToShortDateString(); tmp.grupo_id = reader["grupo"].ToString(); tmp.importe = Convert.ToDecimal(reader["importe"].ToString()); tmp.detalles = reader["detalles"].ToString(); tmp.asignado_por = reader["asignado_por"].ToString(); } reader.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(tmp); }
public bool guardar(bool nuevo) { bool ret = false; Tipos_Gastos bar = new Tipos_Gastos(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); if (nuevo) { cmd.CommandText = "insert into tipos_gastos (detalles) values (@detalles)"; } else { cmd.CommandText = "update tipos_gastos set detalles=@detalles where id=@id"; } cmd.Parameters.AddWithValue("@id", id); cmd.Parameters.AddWithValue("@detalles", detalles); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } cmd.ExecuteNonQuery(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(ret); }
/// <summary> /// Utilizado para quitar un documento en forma manual /// </summary> /// <param name="idDocumento">ClassId + _ + Id del registro a eliminar </param> public void eliminar(string idDocumento) { if (!idDocumento.StartsWith(classId + "_")) { return; } int id = int.Parse(idDocumento.Replace(classId + "_", "")); MySqlConnection cone = new MySqlConnection(ConfigurationManager.ConnectionStrings["ce"].ConnectionString); try { MySqlCommand cmd = new MySqlCommand("UPDATE comprobanteencabezado SET cen_estadoimpresion = 2, " + "cen_fechaimpresion = NOW() " + "WHERE cen_id=@cen_id", cone); cmd.Parameters.AddWithValue("@cen_id", id); cone.Open(); cmd.ExecuteNonQuery(); LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion.builders.Documento", "eliminar", 0, "El documento se quito correctamente de la cola de impresión.", "", "", false, LogManager.EMensaje.Informativo, null); Notify(m); } catch (Exception Exception) { LogManager.Mensaje m = new LogManager.Mensaje("SGECA.ColaDeImpresion.builders.Documento", "eliminar", 0, "Error al intentar quitar documento de la cola de impresión.", Exception.Message, "", true, LogManager.EMensaje.Critico, Exception.StackTrace); Notify(m); } finally { if (cone.State != ConnectionState.Closed) { cone.Close(); } } }
public void actualizarError(int id) { UltimoMensaje = null; MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand comando = new MySqlCommand(); string toFormat = "yyyy-MM-dd HH':'mm':'ss"; DateTime fecha = DateTime.Now; string fecha_conv = fecha.ToString(toFormat); comando.CommandText = "UPDATE transacciones SET tra_estado = true,tra_fechaFin='0000-00-00 00:00:00' WHERE tra_id = @id"; comando.Parameters.AddWithValue("@id", id); comando.Transaction = Database.obtenerTransaccion(); comando.Connection = conexion; try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } comando.ExecuteNonQuery(); limpiaDatos(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; UltimoMensaje.StackTrace = ex.StackTrace; Notify(UltimoMensaje); } finally { comando.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } }
public Tipos_Gastos obtener(string id) { Tipos_Gastos bar = new Tipos_Gastos(); MySqlConnection conexion = Database.obtenerConexion(true); MySqlCommand cmd = new MySqlCommand(); cmd.Connection = conexion; cmd.Transaction = Database.obtenerTransaccion(); cmd.CommandText = "select * from tipos_gastos where id = @filtro"; cmd.Parameters.AddWithValue("@filtro", id); try { if (Database.obtenerTransaccion() == null) { conexion.Open(); } MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { bar.id = Convert.ToInt32(reader["id"].ToString()); bar.detalles = reader["detalles"].ToString(); } reader.Close(); } catch (Exception ex) { UltimoMensaje = GestionErrores.obtenerError(ex); UltimoMensaje.cargar( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString(), System.Reflection.MethodBase.GetCurrentMethod().ToString(), new System.Diagnostics.StackFrame(0, true).GetFileLineNumber()); UltimoMensaje.EsError = true; Notify(UltimoMensaje); } finally { cmd.Parameters.Clear(); if (Database.obtenerTransaccion() == null) { if (conexion.State != ConnectionState.Closed) { conexion.Close(); } } } return(bar); }
/// <summary> /// Limpio los datos de los atributos de la instancia /// </summary> private void limpiaDatos() { this.Codigo = null; this.Descripcion = null; this.Letra = null; this.Nemonico = null; EsConCAE = false; UltimoMensaje = null; //todo:terminar campos faltantes }