protected void Button_RegistrarActividad_Click(object sender, EventArgs e) { string colaboradorSeleccionado = DropDownList_Colaboradores.SelectedValue; string actividadSeleccionada = DropDownList_Actividades.SelectedValue; string descripcion = TextBox_Descripcion.Text; if (!BuscarColaborador(colaboradorSeleccionado)) { ListItem item = new ListItem(); item.Value = colaboradorSeleccionado; item.Text = colaboradorSeleccionado + " -> " + actividadSeleccionada; ListBox_Registro.Items.Add(item); ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.ObtenerMuestreoPreliminarId(); DataTable tablaMuestroPreliminarId = ds.Tables[0]; DataSet ds_2 = WS.ObtenerActividad(actividadSeleccionada); DataTable tablaActividad = ds_2.Tables[0]; DataSet ds_1 = WS.RegistrarRevisionColaborador(Int32.Parse(tablaMuestroPreliminarId.Rows[0][0].ToString()), colaboradorSeleccionado, Int32.Parse(tablaActividad.Rows[0][2].ToString()), IniciarSesion.usuarioActual[0].ToString(), descripcion); MessageBox("Se ha registrado la revisión para " + colaboradorSeleccionado); } else { MessageBox("Ya se ha registrado el colaborador."); } }
protected void Button_Crear_Click(object sender, EventArgs e) { if (!TextBox_NombreActividad.Text.Equals("")) { try { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.CrearActividad(TextBox_NombreActividad.Text, Int32.Parse(DropDownList_TipoActividad.SelectedItem.Value), TextBox_DescripcionActividad.Text); if (!ds.Tables[0].Rows[0].ToString().Equals("error")) { MessageBox_2("Se ha creado la Actividad correctamente", "Actividades.aspx"); } else { MessageBox("Error al crear la actividad"); } } catch { MessageBox("Error"); } } else { MessageBox("Ingrese un nombre para la actividad."); } }
protected void Button_Eliminar_Click(object sender, EventArgs e) { //var text = (listBox1.SelectedItem as DataRowView)["columnName"].ToString(); // string actividadAEliminar = String.Join(", ",ListBox_Actividades.Items.Cast<ListItem>().Where(i=>i.Selected).Select(i => i.Value).ToString()); int aux = 0; if (itemSeleccionado == null) { MessageBox("Seleccione un colaborador para poder eliminarlo."); } else { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.EliminarColaborador(itemSeleccionado.Value.ToString()); if (!ds.Tables[0].Rows[0].Equals("error")) { MessageBox_2("Se ha eliminado al colaborador correctamente.", "Colaboradores.aspx"); } else { MessageBox("Error al eliminar"); } } }
protected void Page_Load(object sender, EventArgs e) { if (IniciarSesion.usuarioActual[2].ToString().Equals("2")) { Button_Actividades.Visible = false; Button_AgregarUsuario.Visible = false; Button_Colaboradores.Visible = false; Button_Muestreo.Visible = false; } try { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.BuscarUltimoMuestreo(); if (Int32.Parse(ds.Tables[0].Rows[0][5].ToString()) == 1) { Button_CrearRevision.Enabled = false; } else { Button_CrearRevision.Enabled = true; } } catch { Button_CrearRevision.Enabled = false; // no hay muestreos } }
protected void Button_CrearMP_Click(object sender, EventArgs e) { if (!TextBox_Humedad.Text.Equals("")) { if (!TextBox_Temperatura.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.CrearMuestreoPreliminar(NuevoMuestreo.muestreoActual[1].ToString(), DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLongTimeString(), TextBox_Temperatura.Text, TextBox_Humedad.Text); DataTable firsttable = ds.Tables[0]; DataRow row = firsttable.Rows[0]; if (row[0].ToString().Equals("exito")) { Response.Redirect("MuestreoPreliminar2.aspx"); } else { MessageBox("Los datos ingresados no son válidos"); } } else { MessageBox("Por favor, ingrese la temperatura."); } } else { MessageBox("Por favor, ingrese la humedad."); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.Params["parametro"] != null) { ActividadAModificar = Request.Params["parametro"].ToString(); TextBox_NombreActividad.Text = ActividadAModificar; } try { ServicioRef_WebService_BD.WS_Base_DatosSoapClient asd = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = new DataSet(); ds = asd.ObtenerActividad(ActividadAModificar); DataRow row = ds.Tables[0].Rows[0]; TextBox_Descripcion.Text = row["Observacion"].ToString(); foreach (ListItem item in DropDownList_TipoActividad.Items) { if (row["IdTipoActividad"].ToString().Equals(item.Value)) { DropDownList_TipoActividad.SelectedValue = item.Value; break; } } } catch { MessageBox("Error"); } } }
protected void Button_FinalizarMuestreo_Click(object sender, EventArgs e) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.FinalizarMuestreo(WS.BuscarUltimoMuestreo().Tables[0].Rows[0][0].ToString(), DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLongTimeString()); //DateTime.Now.ToString()); //MessageBox("El muestreo ha sido finalizado!."); VerificarMuestreoTerminado(); WS.EliminarMuestreoPreliminar(WS.BuscarUltimoMuestreoPreliminar().Tables[0].Rows[0][0].ToString()); MessageBox_2("El muestreo ha sido finalizado!.", "MainAdministrador.aspx"); //Response.Redirect(Request.Url.AbsoluteUri); // Refrescar la pagina actual }
protected void Button_Finalizar_Click(object sender, EventArgs e) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.BuscarUltimoMuestreo(); Random rdn = new Random(); int miValor = rdn.Next(Int32.Parse(ds.Tables[0].Rows[0][2].ToString()), Int32.Parse(ds.Tables[0].Rows[0][3].ToString()) + 1); WS.CrearMuestreoPreliminar(WS.BuscarUltimoMuestreo().Tables[0].Rows[0][0].ToString(), (DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.AddMinutes(miValor).ToLongTimeString()), "", ""); MessageBox_2("Se ha finalizado correctamente el muestreo preliminar!.", "MainAdministrador.aspx"); }
protected void Button_Modificar_Click(object sender, EventArgs e) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient asd = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = new DataSet(); string nombre = TextBox_NombreActividad.Text; string descripcion = TextBox_Descripcion.Text; ds = asd.ModificarActividad(Request.Params["parametro"], nombre, descripcion, Int32.Parse(DropDownList_TipoActividad.SelectedItem.Value)); if (ds.Tables[0].Rows[0][0].ToString().Equals("exito")) { MessageBox_2("Se ha modificado la actividad correctamente!", "Actividades.aspx"); } else { MessageBox("Error al modificar la actividad"); } }
protected void Button_CrearRevision_Click(object sender, EventArgs e) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds_2 = WS.BuscarUltimoMuestreoPreliminar(); DateTime fechaMP = Convert.ToDateTime(ds_2.Tables[0].Rows[0][2].ToString()); // 7:30 DateTime FechActual = DateTime.Now; // 7:15 if (fechaMP <= FechActual) // 7:15 menor 7:30 { Response.Redirect("MuestreoPreliminar.aspx"); } else { MessageBox("El muestreo preliminar se habilitará a las " + fechaMP); } //Response.Redirect("MuestreoPreliminar.aspx"); }
protected void Button_CrearMuestreo_Click(object sender, EventArgs e) { if (!TextBox_NombreNuevoMuestreo.Text.Equals("") && !TextBox_DescripcionNuevoMuestreo.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.ModificarMuestreo(Int32.Parse(WS.BuscarUltimoMuestreo().Tables[0].Rows[0][0].ToString()), TextBox_NombreNuevoMuestreo.Text, DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLongTimeString(), // DateTime.Now.ToString(), rangoInicial, rangoFinal, "", 2, TextBox_DescripcionNuevoMuestreo.Text, IniciarSesion.usuarioActual[0].ToString(), 1); //CREAR MUESTREO PRELIMINAR VACIO WS.CrearMuestreoPreliminar(WS.BuscarUltimoMuestreo().Tables[0].Rows[0][0].ToString(), "", "", ""); string horaRandomFinal = ""; //DateTime.Now.ToString("yyyy-MM-dd") + " "; Random rdn = new Random(); int miValor = rdn.Next(rangoInicial, rangoFinal + tiempoExtra + 1); DateTime horaRandom = DateTime.Now.AddMinutes(miValor); DataSet dsHL = WS.BuscarHorasNoLaborables(); foreach (DataRow row in dsHL.Tables[0].Rows) { DateTime horaInicio = Convert.ToDateTime(row[2].ToString()); DateTime horaFinal = Convert.ToDateTime(row[3].ToString()); if (horaRandom >= horaInicio && horaRandom <= horaFinal) { //ESTA DENTRO DE LAS HORAS DE DESCANSO horaRandom = horaFinal.AddMinutes(miValor + 5); } } horaRandomFinal = horaRandom.ToString("yyyy-MM-dd H:mm:ss");//horaRandom.ToLongTimeString(); //() WS.ModificarMuestreoPreliminarHoras(WS.BuscarUltimoMuestreoPreliminar().Tables[0].Rows[0][0].ToString(), horaRandomFinal); MessageBox_2("El muestreo se ha creado correctamente!. El primer muestreo preliminar se habilitará a las: " + horaRandomFinal, "MainAdministrador.aspx"); } }
protected void Button_Agregar_Click(object sender, EventArgs e) { if (!TextBox_Identificador.Text.Equals("")) { if (!TextBox_Salario.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); int IdPuesto = ObtenerIdPuesto(DropDownList_Puesto.Text); if (IdPuesto != -1) { DataSet ds = WS.InsertarColaborador(TextBox_Identificador.Text, TextBox_Salario.Text, IdPuesto); DataTable tablaColaborador = ds.Tables[0]; DataRow row = tablaColaborador.Rows[0]; if (row[0].ToString().Equals("exito")) { MessageBox("Colaborador agregado satisfactoriamente"); } else { MessageBox("Error, el colaborador ya existe!"); } } else { MessageBox("Error en la busqueda del puesto!"); // inesperado } } else { MessageBox("Por favor, ingrese el salario del colaborador"); } } else { MessageBox("Por favor, ingrese el identificador del colaborador"); } }
private void VerificarMuestreoTerminado() { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.BuscarUltimoMuestreo();// = WS.CrearMuestreoPreliminar(NuevoMuestreo.muestreoActual[1].ToString(), DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLongTimeString(), TextBox_Temperatura.Text, TextBox_Humedad.Text); try { if (ds.Tables[0].Rows[0][5].Equals(2)) // Muestreo en proceso { Button_NuevoMuestreo.Enabled = false; } else { Button_NuevoMuestreo.Enabled = true; } } catch { // no existen muestreos } }
protected void Page_Load(object sender, EventArgs e) { try { DropDownList_Puesto.Items.Clear(); // Agregar puestos de trabajo al Drop List ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.BuscarPuestos(); DataTable tablaPuestos = ds.Tables[0]; tablaPuestosActuales = tablaPuestos; foreach (DataRow row in tablaPuestos.Rows) { DropDownList_Puesto.Items.Add(row["Nombre"].ToString()); } } catch { MessageBox("Error"); } }
protected void button_Ingresar_Click(object sender, EventArgs e) { if (!TextBox_NombreUsuario.Text.Equals("")) { if (!TextBox_Contrasenia.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.VerificarCredenciales(TextBox_NombreUsuario.Text, TextBox_Contrasenia.Text); DataTable firsttable = ds.Tables[0]; DataRow row = firsttable.Rows[0]; usuarioActual = row; if (!row[0].ToString().Equals("error")) { if (row[2].ToString().Equals("1")) { Response.Redirect("MainAdministrador.aspx"); } else { Response.Redirect("MainAdministrador.aspx"); } } else { MessageBox("El nombre de usuario o contraseña no coincide con ninguna cuenta registrada."); } } else { MessageBox("Por favor, ingrese la contraseña."); } } else { MessageBox("Por favor, ingrese el nombre de usuario."); } }
protected void Button_Crear_Click(object sender, EventArgs e) { if (!TextBox_Humedad.Text.Equals("")) { if (!TextBox_Temperatura.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds_2 = WS.BuscarUltimoMuestreoPreliminar(); DataSet ds = WS.ModificarMuestreoPreliminar(ds_2.Tables[0].Rows[0][0].ToString(), TextBox_Temperatura.Text, TextBox_Humedad.Text); Response.Redirect("MuestreoPreliminar2.aspx"); } else { MessageBox("Por favor, ingrese la temperatura."); } } else { MessageBox("Por favor, ingrese la humedad."); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { ListBox_Actividades.Items.Clear(); ServicioRef_WebService_BD.WS_Base_DatosSoapClient asd = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = new DataSet(); ds = asd.ObtenerActividades(); DataTable tablaActividades = ds.Tables[0]; ListBox_Actividades.DataMember = ds.Tables[0].Columns[0].ColumnName; ListBox_Actividades.DataValueField = ds.Tables[0].Columns[0].ColumnName; ListBox_Actividades.DataSource = ds.Tables[0]; ListBox_Actividades.DataBind(); } catch { MessageBox("Error al cargar los datos."); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { ListBox_Colaboradores.Items.Clear(); ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds = WS.BuscarColaboradores(); DataTable tablaColaboradores = ds.Tables[0]; foreach (DataRow row in tablaColaboradores.Rows) { ListBox_Colaboradores.Items.Add(row["Nombre"].ToString()); } } catch { MessageBox("Hubo un error cargando los colaboradores!."); } } }
protected void Button_CrearUsuario_Click(object sender, EventArgs e) { if (!TextBox_Nombre.Text.Equals("") && !TextBox_Apellidos.Text.Equals("") && !TextBox_CorreoElectronico.Text.Equals("") && !TextBox_NombreUsuario.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); int tipoUsuario = Convert.ToInt32(DropDownList_TipoUsuario.SelectedValue); string contraseñaTemporal = generarContraseniaTemporal(); DataSet ds = WS.RegistrarNuevoUsuario(TextBox_Nombre.Text, TextBox_Apellidos.Text, TextBox_CorreoElectronico.Text, TextBox_NombreUsuario.Text, contraseñaTemporal, tipoUsuario); DataTable firsttable = ds.Tables[0]; DataRow row = firsttable.Rows[0]; if (!ds.Tables[0].Rows[0][0].ToString().Equals("error")) // row[0].ToString() { string correoResultado = EnviarCorreo(TextBox_CorreoElectronico.Text, contraseñaTemporal); if (correoResultado.Equals("exito")) { MessageBox("Se ha registrado con éxito el usuario!. Por favor, verifique la bandeja del correo electronico " + TextBox_CorreoElectronico.Text + " para obtener la contraseña asociada a la cuenta."); } else { MessageBox("Error al enviar el correo electrónico, contacte con soporte técnico."); } } else { MessageBox("Error, el usuario o correo electrónico ya se ha registrado en el sistema. Por favor, ingrese nuevamente los datos."); } } else { MessageBox("Por favor, rellene todos los campos."); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { DropDownList_Actividades.Items.Clear(); DropDownList_Colaboradores.Items.Clear(); //Colaboradores ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); DataSet ds_1 = WS.BuscarColaboradores(); DataTable tablaColaboradores = ds_1.Tables[0]; foreach (DataRow row in tablaColaboradores.Rows) { DropDownList_Colaboradores.Items.Add(row["Nombre"].ToString()); } //Actividades DataSet ds_2 = WS.ObtenerActividades(); DataTable tablaActividades = ds_2.Tables[0]; foreach (DataRow row in tablaActividades.Rows) { DropDownList_Actividades.Items.Add(row["Nombre"].ToString()); } } catch { MessageBox("Hubo un error cargando la información, reintente nuevamente!."); } } }
protected void Button_NuevoMuestreo_Click(object sender, EventArgs e) { int temp; if (CheckBox1_LapsoAleatorio.Checked) { if (!TextBox_LapsoExtra.Text.Equals("") && int.TryParse(TextBox_LapsoExtra.Text, out temp) || TextBox_LapsoExtra.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); WS.CrearMuestreo(DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLongTimeString(), 0, 0, "", "", ""); //DateTime.Now.ToString() Response.Redirect("DefinirHorasLibres.aspx?" + "TiempoExtra=" + TextBox_LapsoExtra.Text + "&" + "TiempoAleatorio=True" + "&Valida=true"); } else { MessageBox("Formato inválido del lapso de tiempo."); } } else { if (!TextBox_RangoInicial.Text.Equals("") && !TextBox_RangoFinal.Text.Equals("") && int.TryParse(TextBox_RangoInicial.Text, out temp) && int.TryParse(TextBox_RangoFinal.Text, out temp)) { int rangoInicial = Int32.Parse(TextBox_RangoInicial.Text); int rangoFinal = Int32.Parse(TextBox_RangoFinal.Text); if (rangoInicial < rangoFinal) { string tiempoExtra = TextBox_LapsoExtra.Text; if ((!TextBox_LapsoExtra.Text.Equals("") && int.TryParse(TextBox_LapsoExtra.Text, out temp)) || TextBox_LapsoExtra.Text.Equals("")) { ServicioRef_WebService_BD.WS_Base_DatosSoapClient WS = new ServicioRef_WebService_BD.WS_Base_DatosSoapClient(); WS.CrearMuestreo(DateTime.Now.ToString("yyyy-MM-dd") + " " + DateTime.Now.ToLongTimeString(), 0, 0, "", "", ""); //DateTime.Now.ToString() Response.Redirect("DefinirHorasLibres.aspx?" + "RangoInicial=" + TextBox_RangoInicial.Text + "&" + "RangoFinal=" + TextBox_RangoFinal.Text + "&" + "TiempoExtra=" + TextBox_LapsoExtra.Text + "&" + "TiempoAleatorio=False" + "&Valida=true"); } else { MessageBox("Formato inválido en los rangos de tiempo."); } } else { MessageBox("Error, el rango inicial debe ser menor que el rango final."); } } else { MessageBox("Indique el lapso de tiempo que se desea manejar o verifique que los rangos ingresados sean numeros enteros."); } } }