protected void BtnAceptar_Click(object sender, EventArgs e)
        {
            try{
                if (DDLCategorias.SelectedValue == "0")
                {
                    throw new Exception("Por favor seleccione la categoría.");
                }
                if (TxNombre.Text == "" || TxNombre.Text == string.Empty)
                {
                    throw new Exception("Por favor ingrese el nombre.");
                }

                String vQuery = "[ActivosGenerales] 3" +
                                "," + DDLCategorias.SelectedValue +
                                ",'" + TxNombre.Text + "'" +
                                ",'" + Session["USUARIO"].ToString() + "'";
                int vInfo = vConexion.ejecutarSql(vQuery);
                if (vInfo == 1)
                {
                    Mensaje("Registro creado con éxito.", WarningType.Success);
                }
                else
                {
                    Mensaje("Hubo un problema al crear el registro. Comuníquese con sistemas.", WarningType.Danger);
                }

                ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "closeModal();", true);
                cargarDatos();
                UpdateDivBusquedas.Update();
            }catch (Exception ex) {
                LbMensaje.Text     = ex.Message;
                DivMensaje.Visible = true;
            }
        }
        void CargarAutorizaciones()
        {
            try{
                String    vQuery = "RSP_ObtenerPermisos 1," + Session["USUARIO"];
                DataTable vDatos = vConexion.obtenerDataTable(vQuery);

                //begin wpadilla
                vDatos.Columns.Add("Detalle");

                for (int i = 0; i < vDatos.Rows.Count; i++)
                {
                    DateTime desde = Convert.ToDateTime(vDatos.Rows[i]["FechaInicio"]);
                    DateTime hasta = Convert.ToDateTime(vDatos.Rows[i]["FechaRegreso"]);

                    DateTime inicio = desde;
                    int      dias   = 0;

                    while (inicio <= hasta)
                    {
                        if (inicio.DayOfWeek != DayOfWeek.Saturday && inicio.DayOfWeek != DayOfWeek.Sunday)
                        {
                            dias++;
                        }

                        inicio = inicio.AddDays(1);
                    }

                    TimeSpan ts   = Convert.ToDateTime(hasta) - Convert.ToDateTime(desde);
                    int      days = 1;
                    if (ts.Days >= 1)
                    {
                        days = dias; //ts.Days + 1 -
                    }
                    else if (ts.Hours > 0 || ts.Minutes > 0)
                    {
                        days = 0;
                    }

                    vDatos.Rows[i]["Detalle"] = days + " días, " + ts.Hours + " horas, " + ts.Minutes + " minutos";
                }
                //end wpadilla

                GVBusqueda.DataSource = vDatos;
                GVBusqueda.DataBind();
                drawActions();
                DataTable vDatosLogin = (DataTable)Session["AUTHCLASS"];
                if (!vDatosLogin.Rows[0]["tipoEmpleado"].ToString().Equals(""))
                {
                    if (vDatosLogin.Rows[0]["tipoEmpleado"].ToString().Equals("1"))
                    {
                        GVBusqueda.Columns[0].Visible = true;
                    }
                }

                Session["DATOSAUTORIZAR"] = vDatos;
                UpdateDivBusquedas.Update();
            }catch (Exception Ex) {
                Mensaje(Ex.Message, WarningType.Danger);
            }
        }
        protected void BtnEnviar_Click(object sender, EventArgs e)
        {
            try{
                validarDatos();

                String vAccion = DDLAccion.SelectedValue == "0" ? "Entrada" : "Salida";
                String vUser   = Session["USUARIO"].ToString();
                String vQuery  = "[RSP_Seguridad] 17" +
                                 "," + vUser +
                                 "," + DDLArticulo.SelectedValue +
                                 "," + DDLAccion.SelectedValue +
                                 ",'" + TxSerie.Text + "'" +
                                 ",'" + TxObservaciones.Text + "'";
                int vInfo = vConexion.ejecutarSql(vQuery);
                if (vInfo == 1)
                {
                    Mensaje("Aprobacion de " + vAccion + " de equipo exitosa.", WarningType.Success);
                }
                else
                {
                    Mensaje("Hubo un problema al aprobar la " + vAccion + ". Comuníquese con Sistemas.", WarningType.Danger);
                }

                limpiarFormulario();
                cargarDatos();
                UpdateDivBusquedas.Update();
            }catch (Exception ex) {
                Mensaje(ex.Message, WarningType.Danger);
            }
        }
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            try{
                String vQuery = "";
                if (Convert.ToBoolean(Session["ACTIVOS_PI_PERSONAL"]))
                {
                    validarPersonal();
                    vQuery = "[RSP_ActivosPI] 11" +
                             "," + DDLCategoria.SelectedValue +
                             "," + DDLTipo.SelectedValue +
                             ",'" + TxMarca.Text + "'" +
                             ",'" + TxSerie.Text + "'" +
                             ",'" + TxModelo.Text + "'" +
                             "," + Session["USUARIO"].ToString() +
                             "," + DDLEmpleado.SelectedValue +
                             ",1";
                }
                else
                {
                    vQuery = "[RSP_ActivosPI] 6" +
                             "," + LbIdEquipoEnt.Text +
                             ",1," + Session["USUARIO"].ToString() + "";
                }

                int vInfo = vConexion.ejecutarSql(vQuery);
                if (vInfo > 0)
                {
                    cargarDatos();
                    UpdateDivBusquedas.Update();
                    Mensaje("Entrada guardada con éxito", WarningType.Success);
                }
                else
                {
                    Mensaje("Hubo un error al guardar la entrada.", WarningType.Danger);
                }

                limpiarFormulario();
                LbMensaje.Text            = "";
                DivResultado.Visible      = false;
                DivRegistrar.Visible      = false;
                DivEquipoPersonal.Visible = false;
                UpdatePanel7.Update();
                TxBusqueda.Focus();
            }catch (Exception ex) {
                Mensaje(ex.Message, WarningType.Danger);
            }
        }
        protected void TxBuscarSalida_TextChanged(object sender, EventArgs e)
        {
            try{
                if (TxBuscarSalida.Text != "" || TxBuscarSalida.Text != string.Empty)
                {
                    String    vQuery = "[RSP_ActivosPI] 5,'" + TxBuscarSalida.Text + "'";
                    DataTable vDatos = vConexion.obtenerDataTable(vQuery);
                    DivInfoOUT.Visible        = vDatos.Rows.Count > 0 ? true : false;
                    DivRegistroSalida.Visible = vDatos.Rows.Count > 0 ? true : false;
                    if (vDatos.Rows.Count > 0)
                    {
                        LbNombreOut.Text     = vDatos.Rows[0]["nombre"].ToString();
                        LbIdEquipoOut.Text   = vDatos.Rows[0]["idEquipo"].ToString();
                        LbTipoOut.Text       = vDatos.Rows[0]["TipoEquipo"].ToString();
                        LbMarcaOut.Text      = vDatos.Rows[0]["marca"].ToString();
                        LbSerieOut.Text      = vDatos.Rows[0]["serie"].ToString();
                        LbInventarioOut.Text = vDatos.Rows[0]["inventario"].ToString();

                        vQuery = "[RSP_ActivosPI] 14," + vDatos.Rows[0]["idEquipo"].ToString();
                        vDatos = vConexion.obtenerDataTable(vQuery);
                        if (vDatos.Rows.Count > 0)
                        {
                            LbFechaIn.Text = vDatos.Rows[0]["fechaRegistro"].ToString();
                        }
                    }
                    else
                    {
                        Mensaje("Este equipo no ha sido registrado.", WarningType.Danger);
                    }
                    UpdatePanel4.Update();
                }
                else
                {
                    cargarDatos();
                }

                UpdateDivBusquedas.Update();
            }catch (Exception Ex) {
                Mensaje(Ex.Message, WarningType.Danger);
            }
        }
        protected void TxBuscaSerie_TextChanged(object sender, EventArgs e)
        {
            try{
                if (TxBuscaSerie.Text != "" || TxBuscaSerie.Text != string.Empty)
                {
                    String    vQuery = "[RSP_Seguridad] 8,'" + TxBuscaSerie.Text + "'";
                    DataTable vDatos = vConexion.obtenerDataTable(vQuery);

                    GVBusqueda.DataSource = vDatos;
                    GVBusqueda.DataBind();
                    Session["SEG_SALIDAS"] = vDatos;
                }
                else
                {
                    cargarDatos();
                }

                UpdateDivBusquedas.Update();
            }catch (Exception Ex) {
                Mensaje(Ex.Message, WarningType.Danger);
            }
        }
        protected void TxBuscaAsignacion_TextChanged(object sender, EventArgs e)
        {
            try{
                if (TxBuscaAsignacion.Text != "" || TxBuscaAsignacion.Text != string.Empty)
                {
                    String    vQuery = "[RSP_ActivosPI] 9,'" + TxBuscaAsignacion.Text + "'";
                    DataTable vDatos = vConexion.obtenerDataTable(vQuery);

                    GvAsignaciones.DataSource = vDatos;
                    GvAsignaciones.DataBind();
                    Session["ACTIVOS_PI_ASIGNACIONES"] = vDatos;
                }
                else
                {
                    cargarDatos();
                }

                UpdateDivBusquedas.Update();
            }catch (Exception Ex) {
                Mensaje(Ex.Message, WarningType.Danger);
            }
        }
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            try{
                validaciones();
                String    vQuery = "";
                DataTable vInfo  = new DataTable();
                DataTable vAprob = (DataTable)Session["SEC_APROBACION_SALIDA"];

                if (Session["ID_ENTRADA"] != null)
                {
                    String vId = Session["ID_ENTRADA"].ToString();
                    vQuery = "[RSP_Seguridad] 10," + vId +
                             ",'" + TxNombre.Text + "'" +
                             "," + DDLMotivo.SelectedValue +
                             ",'" + TxObservaciones.Text + "'" +
                             "," + vAprob.Rows[0]["id"].ToString();

                    vInfo = vConexion.obtenerDataTable(vQuery);
                    if (vInfo.Rows.Count > 0)
                    {
                        if (vAprob != null)
                        {
                            String vIdAprob = vAprob.Rows[0]["id"].ToString();
                            vQuery = "[RSP_Seguridad] 20," + vIdAprob;
                            vConexion.ejecutarSql(vQuery);
                        }
                        //else
                        //    enviaCorreo(vInfo);

                        cargarDatos();
                        UpdateDivBusquedas.Update();
                        Mensaje("Salida guardada con éxito", WarningType.Success);
                    }
                    else
                    {
                        Mensaje("Hubo un error al guardar la salida.", WarningType.Danger);
                    }
                }
                else
                {
                    String vRSP = DDLMotivo.SelectedValue == "9" ? "[RSP_Seguridad] 13" : "[RSP_Seguridad] 2";

                    vQuery = vRSP +
                             ",'" + TxNombre.Text + "'" +
                             "," + DDLArticulo.SelectedValue +
                             ",'" + TxSerie.Text + "'" +
                             ",'" + TxInventario.Text + "'" +
                             "," + DDLMotivo.SelectedValue +
                             ",'" + TxObservaciones.Text + "'" +
                             ",'" + Session["USUARIO"].ToString() + "'";
                    vInfo = vConexion.obtenerDataTable(vQuery);
                    if (vInfo.Rows.Count > 0)
                    {
                        if (vAprob != null)
                        {
                            String vIdAprob = vAprob.Rows[0]["id"].ToString();
                            vQuery = "[RSP_Seguridad] 20," + vIdAprob;
                            vConexion.ejecutarSql(vQuery);
                        }//else
                         //enviaCorreo(vInfo);

                        cargarDatos();
                        UpdateDivBusquedas.Update();
                        Mensaje("Salida guardada con éxito", WarningType.Success);
                    }
                    else
                    {
                        Mensaje("Hubo un error al guardar la entrada.", WarningType.Danger);
                    }
                }

                limpiarFormulario();
                TxBusqueda.Focus();
            }catch (Exception Ex) {
                Mensaje(Ex.Message, WarningType.Danger);
            }
        }
示例#9
0
        void CargarAutorizaciones()
        {
            try{
                String    vQuery = "RSP_ObtenerPermisos 5," + Session["USUARIO"];
                DataTable vDatos = vConexion.obtenerDataTable(vQuery);

                //begin wpadilla
                vDatos.Columns.Add("Detalle");

                for (int i = 0; i < vDatos.Rows.Count; i++)
                {
                    DateTime desde = Convert.ToDateTime(vDatos.Rows[i]["FechaInicio"]);
                    DateTime hasta = Convert.ToDateTime(vDatos.Rows[i]["FechaRegreso"]);

                    DateTime inicio = desde;
                    int      dias   = 0;

                    while (inicio <= hasta)
                    {
                        if (inicio.DayOfWeek != DayOfWeek.Saturday && inicio.DayOfWeek != DayOfWeek.Sunday)
                        {
                            dias++;
                        }

                        inicio = inicio.AddDays(1);
                    }

                    TimeSpan ts   = Convert.ToDateTime(hasta) - Convert.ToDateTime(desde);
                    int      days = 1;
                    if (ts.Days >= 1)
                    {
                        days = dias; //ts.Days + 1 -
                    }
                    else if (ts.Hours > 0 || ts.Minutes > 0)
                    {
                        days = 0;
                    }

                    vDatos.Rows[i]["Detalle"] = days + " días, " + ts.Hours + " horas, " + ts.Minutes + " minutos";
                }
                //end wpadilla

                GVBusqueda.DataSource = vDatos;
                GVBusqueda.DataBind();
                foreach (GridViewRow row in GVBusqueda.Rows)
                {
                    vQuery = "RSP_ObtenerPermisos 3," + Session["USUARIO"] + "," + row.Cells[5].Text;
                    DataTable vDatosBusqueda = vConexion.obtenerDataTable(vQuery);

                    foreach (DataRow item in vDatosBusqueda.Rows)
                    {
                        if (item["Autorizado"].ToString().Equals("True"))
                        {
                            Button button = row.FindControl("BtnAutorizar") as Button;
                            button.Text        = "Listo";
                            button.CssClass    = "btn btn-inverse-success mr-2 ";
                            button.Enabled     = false;
                            button.CommandName = "Cerrado";
                        }

                        if (item["autorizadoSAP"].ToString().Equals("True"))
                        {
                            Button button = row.FindControl("BtnAutorizarRecursosHumanos") as Button;
                            button.Text        = "Listo";
                            button.CssClass    = "btn btn-inverse-success mr-2 ";
                            button.Enabled     = false;
                            button.CommandName = "Cerrado";
                        }
                    }
                }

                Session["DATOSAUTORIZAR"] = vDatos;
                UpdateDivBusquedas.Update();
            }
            catch (Exception Ex) { Mensaje(Ex.Message, WarningType.Danger); }
        }
示例#10
0
        protected void BtnGuardar_Click(object sender, EventArgs e)
        {
            try{
                validaciones();
                String    vQuery = "";
                DataTable vInfo  = new DataTable();

                if (Session["ID_SALIDA"] != null)
                {
                    vQuery = "[RSP_Seguridad] 7" +
                             "," + Session["ID_SALIDA"].ToString() +
                             ",'" + TxNombre.Text + "'" +
                             ",'" + TxDestinatario.Text + "'" +
                             "," + DDLDepartamento.SelectedValue +
                             "," + DDLMotivo.SelectedValue +
                             ",'" + TxObservaciones.Text + "'";
                    vInfo = vConexion.obtenerDataTable(vQuery);
                    if (vInfo.Rows.Count > 0)
                    {
                        //enviaCorreo(vInfo);
                        cargarDatos();
                        UpdateDivBusquedas.Update();
                        Mensaje("Entrada guardada con éxito", WarningType.Success);
                    }
                    else
                    {
                        Mensaje("Hubo un error al guardar la entrada.", WarningType.Danger);
                    }
                }
                else
                {
                    String vRSP = DDLMotivo.SelectedValue == "9" ? "[RSP_Seguridad] 12," : "[RSP_Seguridad] 1,";

                    if (DDLMotivo.SelectedValue == "13")
                    {
                        vQuery = "[RSP_Seguridad] 17" +
                                 ",'" + Session["USUARIO"].ToString() + "'" +
                                 "," + DDLArticulos.SelectedValue +
                                 "," + 1 +
                                 ",'" + TxSerie.Text + "'" +
                                 ",'" + TxObservaciones.Text + "'";
                        vConexion.ejecutarSql(vQuery);
                    }

                    vQuery = vRSP + "'" + TxNombre.Text + "'" +
                             "," + DDLArticulos.SelectedValue +
                             ",'" + TxSerie.Text + "'" +
                             ",'" + TxInventario.Text + "'" +
                             ",'" + TxDestinatario.Text + "'" +
                             ",'" + Session["USUARIO"].ToString() + "'" +
                             "," + DDLMotivo.SelectedValue +
                             ",'" + TxObservaciones.Text + "'" +
                             "," + DDLDepartamento.SelectedValue;
                    vInfo = vConexion.obtenerDataTable(vQuery);
                    if (vInfo.Rows.Count > 0)
                    {
                        cargarDatos();
                        UpdateDivBusquedas.Update();
                        Mensaje("Entrada guardada con éxito", WarningType.Success);
                    }
                    else
                    {
                        Mensaje("Hubo un error al guardar la entrada.", WarningType.Danger);
                    }
                }
                limpiarFormulario();
                TxBusqueda.Focus();
            }catch (Exception ex) {
                Mensaje(ex.Message, WarningType.Danger);
            }
        }