Exemplo n.º 1
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Session["idUser"] != null)
         {
             DB_AdminUser User = new DB_AdminUser();
             DataTable    dt   = User.DB_Desplegar_USUARIO(Session["IdUser"].ToString());
             LblUser.Text     = dt.Rows[0][1].ToString();
             LblCargo.Text    = dt.Rows[0][3].ToString();
             LblRegional.Text = dt.Rows[0][5].ToString();
             int rol = Convert.ToInt16(dt.Rows[0][6]);
             Tipo_SITEMA(Convert.ToInt16(dt.Rows[0][7]));
             TreeNode nodo = new TreeNode();
             TreeVMenu.Nodes.Clear();
             nodo.Value = "0";
             nodo.Text  = " .: MENU :. ";
             TreeVMenu.Nodes.Add(nodo);
             User.MostrarNodos(nodo, rol);
         }
         else
         {
             Response.Redirect("~/Default.aspx");
         }
     }
 }
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         if (!IsPostBack)
         {
             LblAux.Text    = DateTime.Now.ToString();
             LblIdUser.Text = Session["IdUser"].ToString();
             DB_AdminUser User     = new DB_AdminUser();
             DataTable    dt       = User.DB_Desplegar_USUARIO(LblIdUser.Text);
             string       name_reg = dt.Rows[0][5].ToString();
             Inicializar_ComboReg(name_reg);
             DDLDepart.SelectedValue = "0";
             Inicializar_ComboDep(DDLDepart.SelectedValue, LblZona.Text);/**************** cambio el value del combo ******************/
             DataTable dtListaPartida = new DataTable();
             dtListaPartida.Columns.AddRange(new DataColumn[10] {
                 new DataColumn("Tramo"), new DataColumn("Zona"), new DataColumn("Destino"), new DataColumn("Lugar"), new DataColumn("Objetivo"), new DataColumn("Fecha Salida"), new DataColumn("Via"), new DataColumn("Tipo"), new DataColumn("Nombre"), new DataColumn("IdenTifi")
             });
             GridView1.DataSource = dtListaPartida;
             GridView1.DataBind();
             Session["datos"] = dtListaPartida;
         }
     }
     catch (Exception ex)
     {
         //Response.Redirect("~/About.aspx");
         string script = @"<script type='text/javascript'>alert('{0}');</script>";
         script = string.Format(script, ex.Message);
         ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
     }
 }
        private void Llenar_DDLRegional()
        {
            DB_AdminUser User = new DB_AdminUser();
            DataTable    dt   = User.DB_Desplegar_USUARIO(LblIdUser.Text);

            LblRegional.Text = dt.Rows[0][5].ToString();
            LblIdReg.Text    = dt.Rows[0][4].ToString();
        }
        protected void Desplegar_SOLICITUD_USUARIO_FIN()
        {
            DB_AdminUser    User  = new DB_AdminUser();
            DataTable       dt    = User.DB_Desplegar_USUARIO(Session["IdUser"].ToString());
            DB_VT_Viaticos  List  = new DB_VT_Viaticos();
            DB_VT_Solicitud lista = new DB_VT_Solicitud();

            GVListSegSolicitFin.DataSource = lista.DB_Desplegar_SOLICITUD_USUARIO(dt.Rows[0][10].ToString(), "", "HISTORIAL_APROBADOS");
            GVListSegSolicitFin.DataBind();
        }
        protected void Desplegar_SEGUIMIENTO_SOLICITUD()
        {
            DB_AdminUser    User  = new DB_AdminUser();
            DataTable       dt    = User.DB_Desplegar_USUARIO(Session["IdUser"].ToString());
            DB_VT_Viaticos  List  = new DB_VT_Viaticos();
            DB_VT_Solicitud lista = new DB_VT_Solicitud();

            GVListSegSolicit.DataSource = lista.DB_Desplegar_SOLICITUD_USUARIO(dt.Rows[0][10].ToString(), "INF-ENVIADO", "APROBADOR");
            GVListSegSolicit.DataBind();
        }
        private void Llenar_DDLRegional()
        {
            DB_AdminUser User = new DB_AdminUser();
            DataTable    dt   = User.DB_Desplegar_USUARIO(LblIdUser.Text);

            if (Convert.ToInt32(dt.Rows[0][6].ToString()) == 15 || Convert.ToInt32(dt.Rows[0][6].ToString()) == 5)
            {
                //DDLRegional.Items.Insert(0, new ListItem(dt.Rows[0][5].ToString(), dt.Rows[0][4].ToString(), true));
                //DDLRegional.Enabled = false;
                DDLRegion.Items.Insert(0, new ListItem(dt.Rows[0][13].ToString(), dt.Rows[0][13].ToString(), true));
                DDLRegion.Enabled = false;
            }
        }
        protected void GVListSolicitud_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            try
            {
                string tipo     = Convert.ToString(e.CommandName);
                int    rowIndex = Convert.ToInt32(e.CommandArgument);
                //Session.Add("IdSolicitud", GVListSolicitud.Rows[rowIndex].Cells[0].Text);
                switch (tipo)
                {
                case "DarCurso":

                    DB_VT_Solicitud s     = new DB_VT_Solicitud();
                    DataTable       dt_dh = new DataTable();

                    string Idsolicitud = GVListSolicitud.Rows[rowIndex].Cells[0].Text;
                    string id_user     = GVListSolicitud.Rows[rowIndex].Cells[9].Text;

                    Desplegar_SEGUIMIENTO_SOLICITUD();

                    DB_AdminUser User     = new DB_AdminUser();
                    DataTable    dt       = User.DB_Desplegar_USUARIO(Session["IdUser"].ToString());
                    string       Regional = dt.Rows[0][5].ToString();

                    DB_VT_Solicitud lista       = new DB_VT_Solicitud();
                    DataTable       DTSolicitud = lista.DB_Desplegar_SOLICITUD_USUARIO("0", Regional, "PROCESAR");

                    Cargar_PLANILLA(id_user, Idsolicitud);            //se agrego metodo en formulario
                    s.DB_Cambiar_ESTADO(Idsolicitud, "APROBADO");

                    Desplegar_SOLICITUD_USUARIO();
                    Desplegar_SOLICITUD_USUARIO_FIN();

                    break;

                case "Ver":
                    Session.Add("IdSolicitud", GVListSolicitud.Rows[rowIndex].Cells[0].Text);
                    StringBuilder sbMensaje = new StringBuilder();
                    sbMensaje.Append("<script type='text/javascript'>");
                    sbMensaje.AppendFormat("window.open('{0}','Titulo','top=0,left=0,width=1000,height=600,scrollbars=yes,resizable=no,directories=no,location=no,menubar=no,status=no,Titlebar=yes,toolbar=no');", "../Viaticos/repSolicitud.aspx?ci=" + GVListSolicitud.Rows[rowIndex].Cells[0].Text);
                    sbMensaje.Append("</script>");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "Mensaje", sbMensaje.ToString());
                    break;
                }
            }
            catch (Exception ex)
            {
                string script = @"<script type='text/javascript'>alert('{0}');</script>";
                script = string.Format(script, ex.Message);
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
            }
        }
        protected void Inicializar_ComboReg(string name_reg)
        {
            /************** DEPARTAMENTOS **************/
            DB_Regional     r      = new DB_Regional();
            List <Regional> listaR = r.DB_Desplegar_REGIONAL();

            DDLDepart.Items.Clear();

            DB_AdminUser User = new DB_AdminUser();
            DataTable    dt   = User.DB_Desplegar_USUARIO(Session["IdUser"].ToString());

            string regional = dt.Rows[0][5].ToString();

            DDLDepart.Items.Add(new ListItem(regional, regional));
            //lrojas: se agrego listado den la bd tbl regional
            this.LlenaCombosRegionales(name_reg);
            DDLDepart.DataBind();
        }
Exemplo n.º 9
0
        private void Llenar_DDLRegional()
        {
            DB_AdminUser User = new DB_AdminUser();
            DataTable    dt   = User.DB_Desplegar_USUARIO(LblIdUser.Text);

            if (Convert.ToInt32(dt.Rows[0][6].ToString()) == 15 || Convert.ToInt32(dt.Rows[0][6].ToString()) == 5)
            {
                DDLRegional.Items.Insert(0, new ListItem(dt.Rows[0][5].ToString(), dt.Rows[0][4].ToString(), true));
                DDLRegional.Enabled = false;
            }
            else
            {
                DB_Regional     reg   = new DB_Regional();
                List <Regional> Lista = reg.DB_Desplegar_REGIONAL();
                DDLRegional.DataSource     = Lista;
                DDLRegional.DataValueField = "Id_Regional";
                DDLRegional.DataTextField  = "Nombre";
                DDLRegional.DataBind();
            }
        }
Exemplo n.º 10
0
        protected void Cargar_PLANILLA(string idUser, string idSolicitud)
        {
            string              lugar = "";
            DB_VT_Planilla      regP  = new DB_VT_Planilla();
            VT_Planilla         p     = new VT_Planilla();
            VT_PlanillaDia      pd    = new VT_PlanillaDia();
            VT_SolicitudDestino sd1   = new VT_SolicitudDestino();
            VT_SolicitudDestino sd2   = new VT_SolicitudDestino();
            DB_VT_Solicitud     s1    = new DB_VT_Solicitud();
            DB_AP_Registro_Org  aux   = new DB_AP_Registro_Org();
            DataTable           dt    = new DataTable();
            DataTable           dt1   = new DataTable();
            DataTable           dt2   = new DataTable();
            int     numero            = s1.DB_Numero_Filas_SOLICITUD(idSolicitud);// se modifico query con  'cont>0'
            decimal contdias          = Convert.ToDecimal("0");

            p.Id_Solicitud    = idSolicitud;
            p.Tot_Num_Dias    = 0;
            p.Tot_Num_Dias15  = 0;
            p.Pago_Total      = 0;
            p.Pago_Total15    = 0;
            p.Rc_Iva          = 13; /*********************************************************** OJO AQUI HAY QUE PONER LOS PARAMETROS DE GESTION ******/
            p.Liquido_Pagable = 0;
            p.Num_Cheque      = "0";
            p.Tasa_Cambio     = 0;
            p.Fecha           = DateTime.Now;
            p.Fecha_Atendido  = DateTime.Now;
            p.MontoPorDia     = 1;
            regP.DB_Registrar_PLANILLA(p);
            int idplani = Convert.ToInt32(aux.DB_MaxId("VIAT_PLANILLA", "Id_Planilla"));
            /**************************************************************/
            DB_VT_Solicitud sol = new DB_VT_Solicitud();

            dt = sol.DB_Seleccionar_SOLICITUD(idSolicitud);
            /************************************************************/
            DB_AdminUser us = new DB_AdminUser();

            dt1 = us.DB_Desplegar_USUARIO(idUser);
            /******************************************************/
            DB_VT_Categoria cat  = new DB_VT_Categoria();
            string          aux1 = dt1.Rows[0][11].ToString();
            string          aux2 = dt.Rows[0][3].ToString();

            dt2 = cat.DB_Seleccionar_CATEGORIA(Convert.ToInt32(dt1.Rows[0][11].ToString()), dt.Rows[0][3].ToString());
            /***************************************************************/
            //DB_VT_Solicitud sol = new DB_VT_Solicitud();
            int contador = 1;
            int auxiliar = 0;

            for (int i = 1; i <= (numero); i++)
            {
                sd1 = s1.DB_Seleccionar_SOLICITUD_DESTINO(idSolicitud, i);
                sd2 = s1.DB_Seleccionar_SOLICITUD_DESTINO(idSolicitud, (i + 1));
                int dias = sol.DB_NumDHM(Convert.ToDateTime(sd1.Fecha_Salida.ToString()), Convert.ToDateTime(sd2.Fecha_Salida.ToString()), "DD");
                if (sd1.Fecha_Salida.ToString("dd/MM/yyyy") == sd2.Fecha_Salida.ToString("dd/MM/yyyy"))
                {
                    if (numero == 2)
                    {
                        contdias       = Convert.ToDecimal("0.5");
                        pd.Id_Planilla = idplani;
                        pd.Cont        = contador;
                        pd.Num_Dias    = contdias;
                        if (sd1.Zona == "Interdepartamental")
                        {
                            pd.Area  = "Interdepartamental";
                            pd.Monto = contdias * Convert.ToDecimal(dt2.Rows[0][3].ToString());
                        }
                        else
                        {
                            pd.Area  = "Al interior del Departamento";
                            pd.Monto = contdias * Convert.ToDecimal(dt2.Rows[0][4].ToString());
                        }
                        pd.Destino     = sd1.Destino + " " + sd1.Lugar;
                        pd.Observacion = "SIN PERNOCTE";
                        pd.FechaDia    = sd1.Fecha_Salida;
                        regP.DB_Registrar_PLANILLADIA(pd);
                        contador++;
                        break;
                    }
                    else
                    {
                        pd.Destino = sd1.Destino + " " + sd1.Lugar;
                    }
                }
                else
                {
                    if (sd1.Tramo == "Salida")
                    {
                        contdias = s1.DB_NumDHM(sd1.Fecha_Salida, sd2.Fecha_Salida, "DD");
                        for (int j = 0; j < contdias; j++)
                        {
                            pd.Id_Planilla = idplani;
                            pd.Cont        = contador;
                            pd.Num_Dias    = 1;
                            if (sd1.Zona == "Interdepartamental")
                            {
                                pd.Area  = "Interdepartamental";
                                pd.Monto = 1 * Convert.ToDecimal(dt2.Rows[0][3].ToString());
                            }
                            else
                            {
                                pd.Area  = "Al interior del Departamento";
                                pd.Monto = 1 * Convert.ToDecimal(dt2.Rows[0][4].ToString());
                            }
                            pd.Destino     = sd1.Destino + " " + sd1.Lugar;
                            pd.Observacion = "CON PERNOCTE";
                            pd.FechaDia    = sd1.Fecha_Salida.AddDays(j);
                            regP.DB_Registrar_PLANILLADIA(pd);
                            auxiliar = j;
                            contador++;
                        }
                    }
                    else
                    {
                        contdias = s1.DB_NumDHM(Convert.ToDateTime(sd1.Fecha_Salida.ToString("dd/MM/yyyy") + " " + "08:00:00"), sd1.Fecha_Salida, "HH");
                        if (contdias > 4) /*************************************** OJO aqui calculamos por hora mayor a 4 horas se contabiliza como medio dia*/
                        {
                            contdias       = Convert.ToDecimal("0.5");
                            pd.Id_Planilla = idplani;
                            pd.Cont        = contador;
                            pd.Num_Dias    = contdias;
                            if (sd1.Zona == "Interdepartamental")
                            {
                                pd.Area  = "Interdepartamental";
                                pd.Monto = contdias * Convert.ToDecimal(dt2.Rows[0][3].ToString());
                            }
                            else
                            {
                                pd.Area  = "Al interior del Departamento";
                                pd.Monto = contdias * Convert.ToDecimal(dt2.Rows[0][4].ToString());
                            }
                            pd.Destino     = sd1.Destino + " " + sd1.Lugar;
                            pd.Observacion = "SIN PERNOCTE";
                            pd.FechaDia    = sd1.Fecha_Salida.AddDays(0);
                            regP.DB_Registrar_PLANILLADIA(pd);
                            contador++;
                        }
                        else
                        {
                            contdias       = Convert.ToDecimal("0.0");
                            pd.Id_Planilla = idplani;
                            pd.Cont        = contador;
                            pd.Num_Dias    = contdias;
                            if (sd1.Zona == "Interdepartamental")
                            {
                                pd.Area  = "Interdepartamental";
                                pd.Monto = contdias * Convert.ToDecimal(dt2.Rows[0][3].ToString());
                            }
                            else
                            {
                                pd.Area  = "Al interior del Departamento";
                                pd.Monto = contdias * Convert.ToDecimal(dt2.Rows[0][4].ToString());
                            }
                            pd.Destino     = sd1.Destino + " " + sd1.Lugar;
                            pd.Observacion = "No se cumplió el periodo de 4 horas que se considera como  medio día de viatico";
                            pd.FechaDia    = sd1.Fecha_Salida.AddDays(0);
                            regP.DB_Registrar_PLANILLADIA(pd);
                            contador++;
                        }
                    }
                }
            }
        }
        protected void TxtFecha_TextChanged(object sender, EventArgs e)
        {
            try
            {
                if (DDLTipSol.SelectedItem.Text == "DESEMBOLSO")
                {
                    //*ini* lrojas: 05/09/2016 validacion de fechas-feriados
                    DB_AdminUser User       = new DB_AdminUser();
                    DataTable    dt         = User.DB_Desplegar_USUARIO(LblIdUser.Text);
                    string       Regional   = dt.Rows[0][5].ToString();
                    string       IdRegional = dt.Rows[0][4].ToString();
                    //DateTime fechaSeleccionada = Convert.ToDateTime(TxtFecha.Text);
                    //****************************************************************************************************
                    DataTable dtDestino = Session["datos"] as DataTable;
                    List <VT_SolicitudDestino> ColSD = new List <VT_SolicitudDestino>();
                    if (dtDestino.Rows.Count > 0)
                    {
                        DDLFeriados.Items.Clear();
                        foreach (DataRow dtRow in dtDestino.Rows)
                        {
                            if (dtRow["Tramo"].ToString() == "Salida")
                            {
                                VT_SolicitudDestino ObjSD = new VT_SolicitudDestino();
                                ObjSD.Tramo                   = dtRow["Tramo"].ToString();
                                ObjSD.Zona                    = dtRow["Zona"].ToString();
                                ObjSD.Destino                 = dtRow["Destino"].ToString();
                                ObjSD.Lugar                   = dtRow["Lugar"].ToString();
                                ObjSD.Objetivo                = dtRow["Objetivo"].ToString();
                                ObjSD.Fecha_Salida            = Convert.ToDateTime(dtRow["Fecha Salida"].ToString());
                                ObjSD.Via_Transporte          = dtRow["Via"].ToString();
                                ObjSD.Tipo_Transporte         = dtRow["Tipo"].ToString();
                                ObjSD.Nombre_Transporte       = dtRow["Nombre"].ToString();
                                ObjSD.Identificador_Trasporte = dtRow["IdenTifi"].ToString();
                                //ObjSD.Cont = Convert.ToInt32(dtRow["Cont"].ToString());
                                ColSD.Add(ObjSD);
                            }
                        }
                        DateTime ultima_f_salida = ColSD.OrderByDescending(x => x.Fecha_Salida).FirstOrDefault().Fecha_Salida;;
                        if (Convert.ToDateTime(TxtFecha.Text) < Convert.ToDateTime(ultima_f_salida.ToShortDateString()))
                        {
                            Response.Write("<script>window.alert('La fecha debe ser mayor o igual a " + ultima_f_salida.ToShortDateString() + "');</script>");
                            TxtFecha.Text = string.Empty;
                        }
                    }
                    else
                    {
                        fecha_feriado_val(IdRegional, TxtFecha.Text);//** lrojas: 13/09/2016
                    }
                    //****************************************************************************************************
                    //Validaciones_feriados(IdRegional, TxtFecha.Text);
                }
                else
                {
                    if (Convert.ToDateTime(TxtFecha.Text + " " + DDLHora.SelectedValue + ":" + DDLMinuto.SelectedValue) > Convert.ToDateTime(LblAux.Text))
                    {
                        //LblMsj1.Text = "La fecha No puede ser mayor a la fecha actual, para una solicitud de Reembolso";
                        Response.Write("<script>window.alert('La fecha No puede ser mayor a la fecha actual, para una solicitud de Reembolso');</script>");
                        TxtFecha.Text = string.Empty;
                    }
                    else
                    {
                        LblMsj1.Text = string.Empty;
                    }
                }

                var dtListaPartida = Session["datos"] as DataTable;
                var fechaActual    = DateTime.Today.ToShortDateString();
                if (dtListaPartida.Rows.Count > 0)
                {
                    var fechaInicial = Convert.ToDateTime(dtListaPartida.Rows[0].ItemArray[5].ToString()).ToShortDateString();
                    this.tipoViajexFecha(fechaInicial, fechaActual);
                }
                else
                {
                    this.tipoViajexFecha(TxtFecha.Text, fechaActual);
                }
            }
            catch (Exception ex)
            {
                string script = @"<script type='text/javascript'>alert('{0}');</script>";
                script = string.Format(script, ex.Message);
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false);
            }
        }