protected void gridTipos_RowDeleting(object sender, GridViewDeleteEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; int lena_tipo_ID = Convert.ToInt32(gridTipos.DataKeys[e.RowIndex].Value); using (bonisoftEntities context = new bonisoftEntities()) { lena_tipo obj = context.lena_tipo.First(x => x.Lena_tipo_ID == lena_tipo_ID); context.lena_tipo.Remove(obj); context.SaveChanges(); #region Guardar log try { string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Borra tipo de leña", obj.GetType().Name + ": " + obj.Lena_tipo_ID, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion BindGrid(); lblMessage.Text = "Borrado correctamente."; } }
public static void AddUserLog(string message, string object_ID, string userID_str, string username) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; using (bonisoftEntities context = new bonisoftEntities()) { log new_log = new log(); new_log.Fecha = DateTime.Now; new_log.Usuario = username; new_log.Descripcion = message; new_log.Dato = object_ID; int userID = 0; if (!int.TryParse(userID_str, out userID)) { userID = 0; AddErrorLog("Excepcion. Convirtiendo int. ERROR:", className, methodName, userID_str); } new_log.Usuario_ID = userID; context.logs.Add(new_log); context.SaveChanges(); } }
protected void gridProcesadores_RowCommand(object sender, GridViewCommandEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; if (e.CommandName == "InsertNew") { GridViewRow row = gridProcesadores.FooterRow; TextBox txb1 = row.FindControl("txbNew1") as TextBox; TextBox txb2 = row.FindControl("txbNew2") as TextBox; TextBox txb3 = row.FindControl("txbNew3") as TextBox; TextBox txb4 = row.FindControl("txbNew4") as TextBox; if (txb1 != null && txb2 != null && txb3 != null && txb4 != null) { using (bonisoftEntities context = new bonisoftEntities()) { procesador obj = new procesador(); obj.Nombre = txb1.Text; obj.Comentarios = txb2.Text; obj.Direccion = txb3.Text; obj.Telefono = txb4.Text; context.procesadores.Add(obj); context.SaveChanges(); #region Guardar log try { int id = 1; procesador procesador = (procesador)context.procesadores.OrderByDescending(p => p.Procesador_ID).FirstOrDefault(); if (procesador != null) { id = procesador.Procesador_ID; } string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Agrega procesador", procesador.GetType().Name + ": " + id, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Agregado correctamente."; BindGrid(); } } } else { //BindGrid(); } }
protected void gridProveedores_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; GridViewRow row = gridProveedores.Rows[e.RowIndex]; TextBox txb1 = row.FindControl("txb1") as TextBox; TextBox txb2 = row.FindControl("txb2") as TextBox; TextBox txb3 = row.FindControl("txb3") as TextBox; TextBox txb4 = row.FindControl("txb4") as TextBox; TextBox txb5 = row.FindControl("txb5") as TextBox; TextBox txb10 = row.FindControl("txb10") as TextBox; TextBox txb23 = row.FindControl("txb23") as TextBox; TextBox txb24 = row.FindControl("txb24") as TextBox; TextBox txb20 = row.FindControl("txb20") as TextBox; if (txb1 != null && txb2 != null && txb3 != null && txb4 != null && txb5 != null && txb10 != null && txb23 != null && txb24 != null && txb20 != null) { using (bonisoftEntities context = new bonisoftEntities()) { int proveedor_ID = Convert.ToInt32(gridProveedores.DataKeys[e.RowIndex].Value); proveedor obj = context.proveedores.First(x => x.Proveedor_ID == proveedor_ID); obj.Nombre = txb1.Text; obj.Razon_social = txb2.Text; obj.RUT = txb3.Text; obj.Direccion = txb4.Text; obj.Telefono = txb5.Text; obj.Comentarios = txb10.Text; obj.Email = txb23.Text; obj.Nro_cuenta = txb24.Text; obj.Depto = txb20.Text; context.SaveChanges(); #region Guardar log try { string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Modifica proveedor", obj.GetType().Name + ": " + obj.GetType().Name + ": " + obj.Proveedor_ID, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Guardado correctamente."; gridProveedores.EditIndex = -1; BindGrid(); } } }
protected void gridUsuarios_RowCommand(object sender, GridViewCommandEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; if (e.CommandName == "InsertNew") { GridViewRow row = gridUsuarios.FooterRow; TextBox txb1 = row.FindControl("txbNew1") as TextBox; TextBox txb2 = row.FindControl("txbNew2") as TextBox; CheckBox chk = row.FindControl("chkNew") as CheckBox; if (txb1 != null && txb2 != null && chk != null) { using (bonisoftEntities context = new bonisoftEntities()) { usuario obj = new usuario(); obj.Usuario1 = txb1.Text; obj.Clave = txb2.Text; obj.EsAdmin = chk.Checked; context.usuarios.Add(obj); context.SaveChanges(); #region Guardar log try { int id = 1; usuario usuario1 = (usuario)context.usuarios.OrderByDescending(p => p.Usuario_ID).FirstOrDefault(); if (usuario1 != null) { id = usuario1.Usuario_ID; } string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Agrega variedad", usuario1.GetType().Name + ": " + id, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Agregado correctamente."; BindGrid(); } } } }
protected void gridUsuarios_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; GridViewRow row = gridUsuarios.Rows[e.RowIndex]; TextBox txb1 = row.FindControl("txb1") as TextBox; TextBox txb2 = row.FindControl("txb2") as TextBox; CheckBox chk = row.FindControl("chk1") as CheckBox; if (txb1 != null && txb2 != null && chk != null) { using (bonisoftEntities context = new bonisoftEntities()) { int Usuario_ID = Convert.ToInt32(gridUsuarios.DataKeys[e.RowIndex].Value); usuario obj = context.usuarios.First(x => x.Usuario_ID == Usuario_ID); obj.Usuario1 = txb1.Text; obj.Clave = txb2.Text; obj.EsAdmin = chk.Checked; context.SaveChanges(); #region Guardar log try { string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Modifica usuario", obj.GetType().Name + ": " + obj.Usuario_ID, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Guardado correctamente."; gridUsuarios.EditIndex = -1; BindGrid(); } } }
protected void gridCamiones_RowUpdating(object sender, GridViewUpdateEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; GridViewRow row = gridCamiones.Rows[e.RowIndex]; TextBox txb1 = row.FindControl("txb1") as TextBox; TextBox txb2 = row.FindControl("txb2") as TextBox; TextBox txb6 = row.FindControl("txb6") as TextBox; TextBox txb7 = row.FindControl("txb7") as TextBox; TextBox txb9 = row.FindControl("txb9") as TextBox; DropDownList ddlEjes2 = row.FindControl("ddlEjes1") as DropDownList; if (txb1 != null && txb2 != null && txb6 != null && txb7 != null && txb9 != null && ddlEjes2 != null) { using (bonisoftEntities context = new bonisoftEntities()) { int camion_ID = Convert.ToInt32(gridCamiones.DataKeys[e.RowIndex].Value); camion obj = context.camiones.First(x => x.Camion_ID == camion_ID); obj.Matricula_camion = txb1.Text; obj.Matricula_zorra = txb2.Text; obj.Marca = txb6.Text; obj.Comentarios = txb9.Text; decimal value = obj.Tara; if (!decimal.TryParse(txb7.Text, out value)) { value = obj.Tara; } obj.Tara = value; #region DDL logic int ddl1 = obj.Ejes_ID; if (!int.TryParse(ddlEjes2.SelectedValue, out ddl1)) { ddl1 = obj.Ejes_ID; } obj.Ejes_ID = ddl1; #endregion context.SaveChanges(); #region Guardar log try { string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Modifica camión", obj.GetType().Name + ": " + obj.Camion_ID, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Guardado correctamente."; gridCamiones.EditIndex = -1; BindGrid(); } } }
protected void gridCamiones_RowCommand(object sender, GridViewCommandEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; if (e.CommandName == "InsertNew") { GridViewRow row = gridCamiones.FooterRow; TextBox txb1 = row.FindControl("txbNew1") as TextBox; TextBox txb2 = row.FindControl("txbNew2") as TextBox; TextBox txb6 = row.FindControl("txbNew6") as TextBox; TextBox txb7 = row.FindControl("txbNew7") as TextBox; TextBox txb9 = row.FindControl("txbNew9") as TextBox; DropDownList ddlEjes2 = row.FindControl("ddlEjes2") as DropDownList; if (txb1 != null && txb2 != null && txb6 != null && txb7 != null && txb9 != null && ddlEjes2 != null) { using (bonisoftEntities context = new bonisoftEntities()) { camion obj = new camion(); obj.Matricula_camion = txb1.Text; obj.Matricula_zorra = txb2.Text; obj.Marca = txb6.Text; obj.Comentarios = txb9.Text; decimal value = 0; if (!decimal.TryParse(txb7.Text, out value)) { value = 0; } obj.Tara = value; #region DDL logic int ddl1 = 0; if (!int.TryParse(ddlEjes2.SelectedValue, out ddl1)) { ddl1 = 0; } obj.Ejes_ID = ddl1; #endregion context.camiones.Add(obj); context.SaveChanges(); #region Guardar log try { int id = 1; camion camion1 = (camion)context.camiones.OrderByDescending(p => p.Camion_ID).FirstOrDefault(); if (camion1 != null) { id = camion1.Camion_ID; } string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Agrega camión", camion1.GetType().Name + ": " + id, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Agregado correctamente."; BindGrid(); } } } else if (e.CommandName == "View") { string[] values = e.CommandArgument.ToString().Split(new char[] { ',' }); if (values.Length > 1) { string tabla = values[0]; string dato = values[1]; if (!string.IsNullOrWhiteSpace(tabla) && !string.IsNullOrWhiteSpace(dato)) { Response.Redirect("Listados.aspx?tabla=" + tabla + "&dato=" + dato); } } } }
protected void gridClientes_RowCommand(object sender, GridViewCommandEventArgs e) { // Logger variables System.Diagnostics.StackTrace stackTrace = new System.Diagnostics.StackTrace(true); System.Diagnostics.StackFrame stackFrame = new System.Diagnostics.StackFrame(); string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name; string methodName = stackFrame.GetMethod().Name; if (e.CommandName == "InsertNew") { GridViewRow row = gridClientes.FooterRow; TextBox txb1 = row.FindControl("txbNew1") as TextBox; TextBox txb3 = row.FindControl("txbNew3") as TextBox; TextBox txb5 = row.FindControl("txbNew5") as TextBox; TextBox txb7 = row.FindControl("txbNew7") as TextBox; TextBox txb13 = row.FindControl("txbNew13") as TextBox; TextBox txb14 = row.FindControl("txbNew14") as TextBox; TextBox txb15 = row.FindControl("txbNew15") as TextBox; TextBox txb16 = row.FindControl("txbNew16") as TextBox; TextBox txb17 = row.FindControl("txbNew17") as TextBox; TextBox txb22 = row.FindControl("txbNew22") as TextBox; TextBox txb23 = row.FindControl("txbNew23") as TextBox; TextBox txb24 = row.FindControl("txbNew24") as TextBox; TextBox txb20 = row.FindControl("txbNew20") as TextBox; if (txb1 != null && txb3 != null && txb5 != null && txb13 != null && txb14 != null && txb15 != null && txb16 != null && txb17 != null && txb22 != null && txb23 != null && txb24 != null && txb20 != null) { using (bonisoftEntities context = new bonisoftEntities()) { cliente obj = new cliente(); obj.Dueno_nombre = txb1.Text; obj.Encargado_lena_nombre = txb3.Text; obj.Encargado_pagos_nombre = txb5.Text; //obj.Supervisor_lena_nombre = txb7.Text; obj.Supervisor_lena_nombre = string.Empty; obj.Nombre = txb13.Text; obj.Razon_social = txb14.Text; obj.RUT = txb15.Text; obj.Direccion = txb16.Text; obj.Telefono = txb17.Text; obj.Comentarios = txb22.Text; obj.Email = txb23.Text; obj.Nro_cuenta = txb24.Text; obj.Depto = txb20.Text; // obj.Forma_de_pago_ID = 0; obj.Dueno_contacto = string.Empty; obj.Encargado_lena_contacto = string.Empty; obj.Encargado_pagos_contacto = string.Empty; obj.Supervisor_lena_contacto = string.Empty; obj.Periodos_liquidacion = string.Empty; obj.Fechas_pago = string.Empty; // obj.EsBarraca = false; context.clientes.Add(obj); context.SaveChanges(); #region Guardar log try { int id = 1; cliente cliente = (cliente)context.clientes.OrderByDescending(p => p.cliente_ID).FirstOrDefault(); if (cliente != null) { id = cliente.cliente_ID; } string userID1 = HttpContext.Current.Session["UserID"].ToString(); string username = HttpContext.Current.Session["UserName"].ToString(); Global_Objects.Logs.AddUserLog("Agrega cliente", cliente.GetType().Name + ": " + id, userID1, username); } catch (Exception ex) { Global_Objects.Logs.AddErrorLog("Excepcion. Guardando log. ERROR:", className, methodName, ex.Message); } #endregion lblMessage.Text = "Agregado correctamente."; BindGrid(); } } } else if (e.CommandName == "View") { string[] values = e.CommandArgument.ToString().Split(new char[] { ',' }); if (values.Length > 1) { string tabla = values[0]; string dato = values[1]; if (!string.IsNullOrWhiteSpace(tabla) && !string.IsNullOrWhiteSpace(dato)) { Response.Redirect("Listados.aspx?tabla=" + tabla + "&dato=" + dato); } } } else { //BindGrid(); } }