示例#1
0
        private void ListarUsuario()
        {
            try
            {
                cn.Conectar();


                SqlDataAdapter sa = new SqlDataAdapter("select u.id, u.username, u.nombre, u.email, p.descPerfil, u.fecRegistro from usuario u" +
                                                       " inner join perfil p on u.idPerfil=p.idPerfil order by u.fecRegistro desc", cn.getConexion());
                DataTable ds = new DataTable();

                sa.Fill(ds);

                gvUsuario.DataSource = ds;

                gvUsuario.DataBind();
                cn.Cerrar();
            }catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "LISTARUSUARIO");
                }
                return;
            }
        }
示例#2
0
        protected void cboHistorial_Data()
        {
            try
            {
                cn.Conectar();
                SqlCommand sc = new SqlCommand("select idListaTicket, descLarga from ListaTicket " +
                                               " order by idListaTicket asc", cn.getConexion());

                SqlDataAdapter sa = new SqlDataAdapter(sc);
                DataSet        ds = new DataSet();
                sa.Fill(ds);

                cboHistorial.DataSource = ds;

                cboHistorial.DataTextField  = "descLarga";
                cboHistorial.DataValueField = "idListaTicket";
                cboHistorial.DataBind();

                cn.Cerrar();
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "CBOHISTORIAL_DATA");
                }
                return;
            }
        }
示例#3
0
        protected void gvUsuario_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            try
            {
                if (e.Row.RowType == DataControlRowType.DataRow && gvUsuario.EditIndex == e.Row.RowIndex)
                {
                    DropDownList ddlTec = (DropDownList)e.Row.FindControl("cboPerfil");
                    cn.Cerrar();
                    cn.Conectar();
                    SqlCommand cmd = new SqlCommand("select idPerfil, descPerfil from perfil", cn.getConexion());

                    ddlTec.DataSource     = cmd.ExecuteReader();
                    ddlTec.DataTextField  = "descPerfil";
                    ddlTec.DataValueField = "idPerfil";
                    ddlTec.DataBind();

                    cn.Cerrar();
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "GVUSUARIO_ROWDATABOUND");
                }
                return;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.cn = new Conexion();

                //if (!IsPostBack)
                //{
                //   ListarTicketADM();
                //}
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }

                string     login = (string)(Session["username"]);
                SqlCommand sc    = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
                sc.Parameters.AddWithValue("@login", login);
                cn.Conectar();
                SqlDataReader dr = sc.ExecuteReader();

                dr.Read();
                id  = Convert.ToInt32(dr["id"].ToString());
                idP = Convert.ToInt32(dr["idPerfil"].ToString());
                cn.Cerrar();


                if (!this.IsPostBack)
                {
                    using (SqlCommand cmd = new SqlCommand("SELECT id, username FROM usuario where idPerfil in (1,2)"))
                    {
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = cn.getConexion();
                        cn.Conectar();
                        cboTecnico.DataSource     = cmd.ExecuteReader();
                        cboTecnico.DataTextField  = "username";
                        cboTecnico.DataValueField = "id";
                        cboTecnico.DataBind();

                        cn.Cerrar();
                    }
                    lblticket.Text = Session["idTicket"].ToString();
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }
        }
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }
                cn.Conectar();
                SqlCommand    q  = new SqlCommand("select username from usuario", cn.getConexion());
                SqlDataReader dr = q.ExecuteReader();
                dr.Read();
                usu = dr["username"].ToString();
                cn.Cerrar();

                SqlCommand cmd = new SqlCommand("insert into usuario (fecRegistro, username, clave, nombre, email, idPerfil) values (getDate(), @usu, @clave, @nom, @email, @perfil)", cn.getConexion());
                cmd.Parameters.AddWithValue("@usu", txtUsuario.Text);
                cmd.Parameters.AddWithValue("@clave", pwd2);
                cmd.Parameters.AddWithValue("@nom", txtNom.Text);
                cmd.Parameters.AddWithValue("@email", txtEmail.Text);
                cmd.Parameters.AddWithValue("@perfil", int.Parse(cboPerfil.SelectedValue.ToString()));

                if (!string.IsNullOrEmpty(txtUsuario.Text))
                {
                    cn.Conectar();

                    cmd.ExecuteNonQuery();
                    ConfigSMTP cs = new ConfigSMTP();
                    cs.enviar(txtEmail.Text, txtUsuario.Text, pwd1);
                    cn.Cerrar();
                    lblError.Visible    = false;
                    lblCorrecto.Text    = "Usuario registrado exitosamente.";
                    lblCorrecto.Visible = true;
                    txtEmail.Text       = "";
                    txtNom.Text         = "";
                    txtUsuario.Text     = "";
                }
                else
                {
                    lblCorrecto.Visible = false;
                    lblError.Text       = "El usuario es requerido.";
                    lblError.Visible    = true;
                }
            }catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNREGISTRAR");
                }
                return;
            }
        }
示例#6
0
        protected void btnCambiar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtClaveN.Text == txtClaveN2.Text)
                {
                    //String Login = Session["username"].ToString();
                    string id = Decryptdata(user);

                    String claveNueva = sha2(txtClaveN.Text);
                    string usuario    = "";
                    cn.Conectar();
                    SqlCommand q = new SqlCommand("select username, email, nombre from usuario where id=@log", cn.getConexion());
                    q.Parameters.AddWithValue("@log", id);
                    SqlDataReader dr = q.ExecuteReader();
                    dr.Read();

                    usuario = dr["username"].ToString();
                    correo  = dr["email"].ToString();
                    cn.Cerrar();
                    SqlCommand sc = new SqlCommand("update usuario set clave=@clave where username=@usu", cn.getConexion());
                    sc.Parameters.AddWithValue("@usu", usuario);

                    sc.Parameters.AddWithValue("@clave", claveNueva);


                    cn.Conectar();
                    sc.ExecuteNonQuery();
                    cn.Cerrar();

                    SqlCommand sc2 = new SqlCommand("update solicitudClave set estadoSolicitud=1 where idSolicitud=@id", cn.getConexion());
                    sc2.Parameters.AddWithValue("@id", idSolicitud.ToString());
                    cn.Conectar();
                    sc2.ExecuteNonQuery();
                    cn.Cerrar();
                    lblNota.Text    = "Usted a realizado su cambio de clave exitosamente.";
                    lblNota.Visible = true;
                }
                else
                {
                    lblError.Visible = true;
                    lblError.Text    = "Las contraseñas no coinciden.";
                }
            }catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNCAMBIAR");
                }
                return;
            }
        }
        protected void btnGrabar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }
                cn.Conectar();
                SqlCommand sc = new SqlCommand("update ticket set idTecnico= '" + cboTecnico.SelectedValue.ToString() + "', idEstado=2 where RIGHT('000000' + cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'", cn.getConexion());
                sc.ExecuteNonQuery();
                cn.Cerrar();
                cn.Conectar();
                SqlCommand q = new SqlCommand("select u.username, u2.email, t.requerimiento from ticket t inner join usuario u on t.id=u.id" +
                                              " inner join usuario u2 on t.idTecnico = u2.id where RIGHT('000000' + cast(t.idTicket AS varchar(6)), 6)=@tck", cn.getConexion());
                q.Parameters.AddWithValue("@tck", Session["idTicket"].ToString());
                SqlDataReader dr = q.ExecuteReader();
                dr.Read();
                email = dr["email"].ToString();
                usu   = dr["username"].ToString();
                req   = dr["requerimiento"].ToString();

                //ConfigSMTP smtp = new ConfigSMTP();
                //smtp.emailTec(usu, req, email);
                //cn.Cerrar();

                //if (!string.IsNullOrEmpty(Session["error"].ToString()))
                //{
                //    lblError.Text = Session["error"].ToString();
                //    lblError.Visible = true;
                //    return;
                //}
                Session["mensaje"] = "Se asignó correctamente el técnico.";
                string cerrar = "window.close();";
                Session.Remove("idTicket");

                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closewindows", cerrar, true);
            }catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNGRABAR");
                }
                return;
            }
        }
示例#8
0
        protected void btnCierre_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }
                DateTime fecha  = DateTime.Now;
                int      año    = fecha.Year;
                string   query1 = "EXEC sp_rename @objname = 'ticket', @newname = 'ticket" + año + "'";

                string query2 = "SELECT * Into ticket From ticket" + año + " where 0=1";

                string query3 = "insert into ListaTicket values (" + año + ", 'Ticket " + año + "', GETDATE()";

                cn.Conectar();
                SqlCommand q1 = new SqlCommand(query1, cn.getConexion());
                q1.ExecuteNonQuery();
                cn.Cerrar();

                cn.Conectar();
                SqlCommand q2 = new SqlCommand(query2, cn.getConexion());
                q2.ExecuteNonQuery();
                cn.Cerrar();

                cn.Conectar();
                SqlCommand q3 = new SqlCommand(query3, cn.getConexion());
                q3.ExecuteNonQuery();
                cn.Cerrar();

                Response.Redirect("ticket.aspx");

                lblCorrecto.Text    = "El cierre se realizó correctamente.";
                lblCorrecto.Visible = true;
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNCIERRE");
                }
                return;
            }
        }
示例#9
0
      protected void Page_Load(object sender, EventArgs e)
      {
          try
          {
              this.cn = new Conexion();

              if (string.IsNullOrEmpty(Session["username"].ToString()))
              {
                  Session["error"] = "Primero debe iniciar sesión";
                  Response.Redirect("login.aspx");
              }
              else
              {
                  lblUsuario.Text = "Bienvenido " + Session["username"].ToString();
              }

              try
              {
                  string     usuario = (string)(Session["username"]);
                  SqlCommand sc      = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
                  sc.Parameters.AddWithValue("@login", usuario);
                  cn.Conectar();
                  SqlDataReader dr = sc.ExecuteReader();

                  dr.Read();

                  idP = Convert.ToInt32(dr["idPerfil"].ToString());
                  cn.Cerrar();
              }
              catch (Exception x)
              {
                  ConfigSMTP smtp = new ConfigSMTP();
                  smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
              }

              if (idP != 1 && idP != 2)
              {
                  regUsuarios.Visible   = false;
                  ListaUsuarios.Visible = false;
              }
          }
          catch (Exception x)
          {
              lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
              lblError.Visible = true;
              ConfigSMTP smtp = new ConfigSMTP();
              smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
              return;
          }
      }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.cn = new Conexion();
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }
                if (Session["idTicket"] == null)
                {
                    ticket.Text = Session["idTicket"].ToString();
                    idTicket    = Session["idTicket"].ToString();
                }
                else
                {
                    Session["error"] = "El número de ticket no existe";
                    Response.Redirect("ticket.aspx");
                }

                string     login = (string)(Session["username"]);
                SqlCommand sc    = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
                sc.Parameters.AddWithValue("@login", login);
                cn.Conectar();
                SqlDataReader dr = sc.ExecuteReader();

                dr.Read();
                idP = Convert.ToInt32(dr["idPerfil"].ToString());
                cn.Cerrar();
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }
            //if (!IsPostBack)
            //{
            //    ListarTicketTec();
            //}
        }
示例#11
0
        protected void gvUsuario_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            //clave=autoClave(10);
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }

                string usu = gvUsuario.DataKeys[e.RowIndex].Values["id"].ToString();

                GridViewRow row1 = (GridViewRow)gvUsuario.Rows[e.RowIndex];


                TextBox user   = (TextBox)row1.Cells[0].Controls[0];
                TextBox nombre = (TextBox)row1.Cells[1].Controls[0];
                TextBox email  = (TextBox)row1.Cells[2].Controls[0];
                string  perfil = (gvUsuario.Rows[e.RowIndex].FindControl("cboPerfil") as DropDownList).SelectedItem.Value;
                gvUsuario.EditIndex = -1;

                cn.Conectar();
                SqlCommand cmd = new SqlCommand("update usuario set username = '******', nombre='" + nombre.Text + "', email='" + email.Text + "'" +
                                                ", idPerfil='" + perfil + "' where id = '" + usu + "'", cn.getConexion());

                cmd.ExecuteNonQuery();

                cn.Cerrar();

                ListarUsuario();
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "GVUSUARIO_ROWUPDATING");
                }
                return;
            }
        }
示例#12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            this.cn = new Conexion();
            try
            {
                if (!string.IsNullOrEmpty(Request.QueryString["id"].ToString()))
                {
                    user = Request.QueryString["id"].ToString();

                    cn.Conectar();
                    SqlCommand q = new SqlCommand("select top 1 fechaSolicitud, estadoSolicitud, idSolicitud from solicitudClave where fechaSolicitud >= @fecha and idUsuario = @id order by idSolicitud desc ", cn.getConexion());
                    q.Parameters.AddWithValue("@id", Decryptdata(user));
                    q.Parameters.AddWithValue("@fecha", DateTime.Today);
                    SqlDataReader dr = q.ExecuteReader();
                    dr.Read();

                    fechaSolicitud  = dr["fechaSolicitud"].ToString();
                    estadoSolicitud = dr["estadoSolicitud"].ToString();
                    idSolicitud     = dr["idSolicitud"].ToString();
                    cn.Cerrar();

                    if (DateTime.Parse(fechaSolicitud) != DateTime.Today)
                    {
                        Session["error"] = "La solicitud de cambio de clave a vencido. Vuevla a solicitar un cambio de clave";
                        Response.Redirect("login.aspx");
                    }
                    else if (estadoSolicitud.Equals(1))
                    {
                        Session["error"] = "Usted ya a realizado su cambio de clave. Vuevla a solicitar un cambio de clave";
                        Response.Redirect("login.aspx");
                    }
                }
                else
                {
                    Session["error"] = "Usted no a solicitado un cambio de clave.";
                    Response.Redirect("login.aspx");
                }

                //if (!string.IsNullOrEmpty(lblNota.Text))
                //{
                //    Thread.Sleep(5000);
                //    Response.Redirect("login.aspx");
                //}
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }

            //if (string.IsNullOrEmpty(HelpDesk.login.sesion))
            //{
            //    Response.Redirect("login.aspx");
            //}
            //else
            //{
            //    lblUsuario.Text = "Bienvenido " + Session["username"].ToString();
            //}

            //try
            //{
            //    string usuario = (string)(Session["username"]);
            //    SqlCommand sc = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
            //    sc.Parameters.AddWithValue("@login", usuario);
            //    cn.Conectar();
            //    SqlDataReader dr = sc.ExecuteReader();

            //    dr.Read();

            //    idP = Convert.ToInt32(dr["idPerfil"].ToString());
            //    cn.Cerrar();
            //}
            //catch (Exception x)
            //{
            //    x.Message.ToString();
            //}

            //if (idP != 1 && idP != 2)
            //{
            //    regUsuarios.Visible = false;
            //    ListaUsuarios.Visible = false;
            //}
            //if (idP == 2)
            //{
            //    regRequerimiento.Visible = false;
            //}
        }
示例#13
0
        protected void DropDownListTitulo_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (int.Parse(DropDownListTitulo.SelectedValue) == 0)
            {
                Titulo.Text = "Tickets Pendientes";
                Session.Remove("error");
                ListarTicket();
            }
            else
            {
                try
                {
                    Titulo.Text = "Mis Tickets";
                    string login = (string)(Session["username"]);
                    cn.Conectar();
                    string query = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, " +
                                   "u2.username as usertec, t.fecAtendido, t.tiempo, " +
                                   "t.observaciones, t.nombreImg, t.area" +
                                   " from ticket t inner join estado e on t.idEstado=e.idEstado" +
                                   " inner join usuario u on t.id=u.id left outer join usuario u2 on t.idTecnico=u2.id ";


                    query = query + "where t.idEstado IN (1, 2, 3, 4) and u.id = " + id + " order by t.fecRegistro desc";

                    SqlCommand     sc = new SqlCommand(query, cn.getConexion());
                    SqlDataAdapter sa = new SqlDataAdapter(sc);
                    DataTable      ds = new DataTable();

                    sa.Fill(ds);

                    gvTicket.DataSource = ds;

                    gvTicket.DataBind();
                    cn.Cerrar();
                    Session.Remove("error");
                    if (0 < gvTicket.Rows.Count)
                    {
                        if (idP == 4 || idP == 5)
                        {
                            gvTicket.Columns[6].Visible = false;
                            gvTicket.Columns[8].Visible = false;
                        }
                        gvTicket.Visible = true;
                    }
                    else
                    {
                        if (idP == 4 || idP == 5)
                        {
                            gvTicket.Columns[6].Visible = false;
                            gvTicket.Columns[8].Visible = false;
                        }
                        ds.Rows.Add(ds.NewRow());
                        gvTicket.DataSource = ds;
                        gvTicket.DataBind();

                        int totalColumns = gvTicket.Rows[0].Cells.Count;
                        gvTicket.Rows[0].Cells.Clear();
                        gvTicket.Rows[0].Cells.Add(new TableCell());
                        gvTicket.Rows[0].Cells[0].ColumnSpan      = totalColumns;
                        gvTicket.Rows[0].Cells[0].Text            = "No tiene tickets registrados";
                        gvTicket.Rows[0].Cells[0].Width           = 1150;
                        gvTicket.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                    }
                }
                catch (Exception x)
                {
                    lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                    lblError.Visible = true;
                    if (Session["username"] != null)
                    {
                        ConfigSMTP smtp = new ConfigSMTP();
                        smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "LISTATICKET");
                    }
                    return;
                }
            }
        }
        //BOTON REGISTRO REQUERIMIENTO
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            try
            {
                string area = "";
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }

                if (string.IsNullOrWhiteSpace(txtReq.Text))
                {
                    lblError.Text    = "El requerimiento debe contener alguna palabra.";
                    lblError.Visible = true;
                    return;
                }
                else
                {
                    if (fileImg.HasFile)
                    {
                        int    contador  = fileImg.FileName.Length;
                        int    extension = contador - 4;
                        string file      = fileImg.FileName.Substring(extension, 4);
                        if (file != ".jpg" && file != ".png")
                        {
                            lblError.Text    = "Solo permite imágenes (Formato .jpg .png)";
                            lblError.Visible = true;
                            return;
                        }
                    }
                    if (!chkAdm.Checked && !chkRRHH.Checked && !chkSoporte.Checked)
                    {
                        lblError.Text    = "Para registrar su ticket debe seleccionar el aréa";
                        lblError.Visible = true;
                        return;
                    }
                    if (chkSoporte.Checked)
                    {
                        area = "Soporte Tecnico";
                    }
                    else if (chkRRHH.Checked)
                    {
                        area = "Recursos Humanos";
                    }
                    else if (chkAdm.Checked)
                    {
                        area = "Administrativa";
                    }
                    int    estado = 1;
                    string login  = (string)(Session["username"]);

                    SqlCommand cmd = new SqlCommand("insert into ticket (fecRegistro, id, requerimiento, idEstado, imagen, nombreImg, area) values (@fec, @usu, @req, @estado, @img, @nomImg, @area)", cn.getConexion());
                    cmd.Parameters.AddWithValue("@fec", DateTime.Now);
                    cmd.Parameters.AddWithValue("@usu", id);
                    cmd.Parameters.AddWithValue("@req", txtReq.Text);
                    cmd.Parameters.AddWithValue("@estado", estado);
                    cmd.Parameters.AddWithValue("@img", fileImg.FileBytes);
                    cmd.Parameters.AddWithValue("@nomImg", fileImg.FileName);
                    cmd.Parameters.AddWithValue("@area", area);
                    cn.Cerrar();
                    cn.Conectar();
                    cmd.ExecuteNonQuery();

                    cn.Cerrar();

                    if (chkSoporte.Checked)
                    {
                        ConfigSMTP smtp = new ConfigSMTP();
                        smtp.emailADM(login, txtReq.Text);
                    }
                    else if (chkRRHH.Checked)
                    {
                        ConfigSMTP smtp = new ConfigSMTP();
                        smtp.emailAreaRRHH(login, txtReq.Text);
                    }
                    else if (chkAdm.Checked)
                    {
                        ConfigSMTP smtp = new ConfigSMTP();
                        smtp.emailAreaAdm(login, txtReq.Text);
                    }

                    if (Session["error"] != null)
                    {
                        lblError.Text    = mensaje;
                        lblError.Visible = true;
                        return;
                    }
                    cn.Cerrar();

                    txtReq.Text = "";
                    //ClientScript.RegisterStartupScript(GetType(), "sw", "alertaCustom", true);

                    lblCorrecto.Text    = "Ticket registrado exitosamente. <br/>En un momento Soporte Técnico atenderá su ticket.";
                    lblCorrecto.Visible = true;
                    //string popup = "alertaCustom()";
                    //ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", popup, true);
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNREGISTRAR");
                }
                return;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            txtReq.Focus();

            //OBTIENE EL USUARIO DE QUIEN ESTA EN LA SESION

            try
            {
                this.cn = new Conexion();
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }
                else
                {
                    if (!IsPostBack)
                    {
                        if (Session["username"] != null)
                        {
                            lblUsuario.Text     = "Bienvenido" + " " + Session["username"].ToString();
                            lblCorrecto.Visible = false;
                            lblError.Visible    = false;
                        }
                        else
                        {
                            mensaje = "Primero debe iniciar sesión";
                            Response.Redirect("login.aspx");
                        }
                    }
                }

                //OBTENER EL ID DEL USUARIO Y SU ID PERFIL PARA VALIDACION
                string     login = (string)(Session["username"]);
                SqlCommand sc    = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
                sc.Parameters.AddWithValue("@login", login);
                cn.Conectar();
                SqlDataReader dr = sc.ExecuteReader();

                dr.Read();
                id  = Convert.ToInt32(dr["id"].ToString());
                idP = Convert.ToInt32(dr["idPerfil"].ToString());
                cn.Cerrar();



                //MUESTRA CONTROLES POR TIPO DE USUARIO
                //PERFIL usuario
                if (idP == 3)
                {
                    if (!IsPostBack)
                    {
                        regUsuarios.Visible   = false;
                        ListaUsuarios.Visible = false;
                    }
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }
        }
示例#16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.cn = new Conexion();

                int    id = Convert.ToInt32(Request.QueryString["idTicket"]);
                byte[] img;
                string nombre = "";

                SqlCommand sc = new SqlCommand("select imagen, nombreImg from ticket where idTicket= " + id + "", cn.getConexion());

                cn.Conectar();
                SqlDataReader dr = sc.ExecuteReader();

                dr.Read();

                img = (Byte[])dr["imagen"];
                //img = Encoding.ASCII.GetBytes(dr["imagen"].);
                nombre = dr["nombreImg"].ToString();
                cn.Cerrar();
                string strBase64 = Convert.ToBase64String(img);

                Image1.ImageUrl = "data:Image/png;base64," + strBase64;



                //File.WriteAllBytes("D:\\Mirko\\" + nombre, img);
                //Response.Redirect("ticket.aspx");
                //FileStream file = new FileStream("D:\\Mirko\\" + nombre, FileMode.Create);
                //file.Write(img, 0, img.Length);
                //file.Close();

                //Response.Clear();
                //Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", nombre));
                //Response.Clear();
                //// Con esto le decimos al browser que la salida sera descargable
                //Response.ContentType = "application/octet-stream";
                //// esta linea es opcional, en donde podemos cambiar el nombre del fichero a descargar (para que sea diferente al original)
                //Response.AddHeader("Content-Disposition", "attachment; filename='"+nombre+"'");
                //// Escribimos el fichero a enviar
                //Response.WriteFile("img");
                //// volcamos el stream
                //Response.Flush();
                //// Enviamos todo el encabezado ahora
                //Response.End();
                //switch (Path.GetExtension(nombre).ToLower())
                //{
                //    case ".jpg":
                //        Response.ContentType = "image/jpg";
                //        break;
                //    case ".gif":
                //        Response.ContentType = "image/gif";
                //        break;
                //    case ".png":
                //        Response.ContentType = "image/png";
                //        break;
                //}

                //Response.BinaryWrite(img);
                //Response.End();
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                ConfigSMTP smtp = new ConfigSMTP();
                smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");

                return;
            }
        }
示例#17
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                TimeoutException to = new TimeoutException();

                this.cn = new Conexion();

                if (Session["username"] == null)
                {
                    Session["error"] = "Primero deberá iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }
                else if (Session["error"] != null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }
                else
                {
                    if (!IsPostBack)
                    {
                        if (Session["username"] != null)
                        {
                            lblUsuario.Text = "Bienvenido" + " " + Session["username"].ToString();
                        }
                        else
                        {
                            Response.Redirect("login.aspx");
                        }
                    }
                }

                //OBTENER EL ID DEL USUARIO Y SU ID PERFIL PARA VALIDACION
                string     login = (string)(Session["username"]);
                SqlCommand sc    = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
                sc.Parameters.AddWithValue("@login", login);
                cn.Conectar();
                SqlDataReader dr = sc.ExecuteReader();

                dr.Read();
                id  = Convert.ToInt32(dr["id"].ToString());
                idP = Convert.ToInt32(dr["idPerfil"].ToString());
                cn.Cerrar();

                btnEjecucion.Visible = false;
                btnRealizado.Visible = false;

                if (Session["mensaje"] != null)
                {
                    lblCorrecto.Text    = Session["mensaje"].ToString();
                    lblCorrecto.Visible = true;
                }

                //if (!IsPostBack)
                //{
                //    EditaRequerimiento.id_ticket = "";
                //    EditaRequerimiento.requerimiento = "";
                //    asignarTec.id_ticket2 = "";
                //    ticket.idCheck = "";
                //    ticketFin.id_ticket2 = "";
                //}

                //MUESTRA CONTROLES POR TIPO DE USUARIO
                //PERFIL ADMIN
                if (idP == 1)
                {
                    if (!IsPostBack)
                    {
                        Titulo.Visible = false;


                        cboHistorial_Data();
                        gvTicket.Visible = true;
                        ListarTicket();
                    }
                    btnAsignar.Visible   = true;
                    btnEjecucion.Visible = true;
                    btnRealizado.Visible = true;
                }

                //PERFIL TECNICO
                if (idP == 2)
                {
                    if (!IsPostBack)
                    {
                        ListarTicket();
                        Titulo.Visible = false;
                    }
                    btnEjecucion.Visible = true;
                    btnRealizado.Visible = true;
                    btnAsignar.Visible   = false;

                    regRequerimiento.Visible = true;

                    lblEstado.Visible = false;
                    txtFec.Visible    = false;
                    cboEstado.Visible = false;
                    btnFiltro.Visible = false;
                    lblFec.Visible    = false;
                    //hpregistroUsuarios.Visible = false;


                    TxtFec2.Visible = false;
                    lblfec2.Visible = false;

                    cboHistorial.Visible = false;
                    //btnHistorial.Visible = false;
                    btnCierre.Visible = false;

                    lblHistorial.Visible = false;
                }

                //PERFIL USUARIO
                if (idP == 3)
                {
                    if (!IsPostBack)
                    {
                        ListarTicket();
                        cboHistorial.SelectedIndex = 1;
                    }
                    regUsuarios.Visible        = false;
                    ListaUsuarios.Visible      = false;
                    Titulo.Text                = "Mis Requerimientos";
                    Titulo.Visible             = true;
                    DropDownListTitulo.Visible = false;
                    lblEstado.Visible          = false;
                    txtFec.Visible             = false;
                    cboEstado.Visible          = false;
                    btnFiltro.Visible          = false;
                    lblFec.Visible             = false;
                    //hpregistroUsuarios.Visible = false;
                    TxtFec2.Visible      = false;
                    lblfec2.Visible      = false;
                    btnAsignar.Visible   = false;
                    cboHistorial.Visible = false;
                    lblHistorial.Visible = false;
                    btnCierre.Visible    = false;
                }

                if (idP == 4)
                {
                    if (!IsPostBack)
                    {
                        ListarTicket();
                    }
                    regUsuarios.Visible   = false;
                    ListaUsuarios.Visible = false;
                    Titulo.Visible        = false;
                    btnRealizado.Visible  = true;
                    lblEstado.Visible     = true;
                    txtFec.Visible        = true;
                    cboEstado.Visible     = true;
                    btnFiltro.Visible     = true;
                    lblFec.Visible        = true;
                    //hpregistroUsuarios.Visible = false;
                    TxtFec2.Visible      = true;
                    lblfec2.Visible      = true;
                    btnAsignar.Visible   = false;
                    cboHistorial.Visible = false;
                    lblHistorial.Visible = false;
                    btnCierre.Visible    = false;
                }

                if (idP == 5)
                {
                    if (!IsPostBack)
                    {
                        ListarTicket();
                    }
                    regUsuarios.Visible   = false;
                    ListaUsuarios.Visible = false;
                    Titulo.Visible        = false;
                    btnRealizado.Visible  = true;
                    lblEstado.Visible     = true;
                    txtFec.Visible        = false;
                    cboEstado.Visible     = true;
                    btnFiltro.Visible     = false;
                    lblFec.Visible        = false;
                    //hpregistroUsuarios.Visible = false;
                    TxtFec2.Visible      = false;
                    lblfec2.Visible      = false;
                    btnAsignar.Visible   = false;
                    cboHistorial.Visible = false;
                    lblHistorial.Visible = false;
                    btnCierre.Visible    = false;
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;

                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }
        }
示例#18
0
        //BOTON REGISTRO REQUERIMIENTO


        private void filtrar_datos()
        {
            try
            {
                string query = "";

                string estado = "";

                if (cboEstado.SelectedValue.ToString().Equals("0"))
                {
                    estado = "null";
                }
                else
                {
                    estado = cboEstado.SelectedValue.ToString();
                }

                String f1 = "";
                String f2 = "";

                if (string.IsNullOrWhiteSpace(txtFec.Text))
                {
                    f1 = "null";
                }
                else
                {
                    f1 = "'" + txtFec.Text + " 00:00:00.000'";
                }

                if (string.IsNullOrWhiteSpace(TxtFec2.Text))
                {
                    f2 = "null";
                }
                else
                {
                    f2 = "'" + TxtFec2.Text + " 23:59:59.999'";
                }
                try
                {
                    if (int.Parse(cboHistorial.SelectedValue.ToString()) == 1)
                    {
                        query = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido, Convert(Time(0),t.tiempo,0) as tiempo, t.observaciones, t.area, t.nombreImg " +
                                "from ticket t inner join estado e on t.idEstado = e.idEstado" +
                                " inner join usuario u on t.id = u.id left outer join usuario u2 on t.idTecnico=u2.id WHERE t.fecRegistro BETWEEN COALESCE(convert(datetime, " + f1 + ", 121), t.fecRegistro) AND COALESCE(convert(datetime, " + f2 + ", 121), t.fecRegistro) AND t.idEstado = COALESCE(" + estado + ", t.idEstado) order by t.fecRegistro desc, t.idEstado desc";
                    }
                    else if (int.Parse(cboHistorial.SelectedValue.ToString()) < 2018)
                    {
                        query = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido, Convert(Time(0),t.tiempo,0) as tiempo, t.observaciones, t.nombreImg " +
                                "from ticket" + cboHistorial.SelectedValue + " t inner join estado e on t.idEstado = e.idEstado" +
                                " inner join usuario u on t.id = u.id left outer join usuario u2 on t.idTecnico=u2.id WHERE t.fecRegistro BETWEEN COALESCE(convert(datetime, " + f1 + ", 121), t.fecRegistro) AND COALESCE(convert(datetime, " + f2 + ", 121), t.fecRegistro) AND t.idEstado = COALESCE(" + estado + ", t.idEstado) order by t.fecRegistro desc, t.idEstado desc";
                    }
                    else if (int.Parse(cboHistorial.SelectedValue.ToString()) >= 2018)
                    {
                        query = "select t.idTicket, t.fecRegistro, t.area, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido, Convert(Time(0),t.tiempo,0) as tiempo, t.observaciones, t.nombreImg " +
                                "from ticket" + cboHistorial.SelectedValue + " t inner join estado e on t.idEstado = e.idEstado" +
                                " inner join usuario u on t.id = u.id left outer join usuario u2 on t.idTecnico=u2.id WHERE t.fecRegistro BETWEEN COALESCE(convert(datetime, " + f1 + ", 121), t.fecRegistro) AND COALESCE(convert(datetime, " + f2 + ", 121), t.fecRegistro) AND t.idEstado = COALESCE(" + estado + ", t.idEstado) order by t.fecRegistro desc, t.idEstado desc";
                    }
                    if (query != null)
                    {
                        cn.Conectar();

                        SqlCommand sc = new SqlCommand(query, cn.getConexion());

                        SqlDataAdapter sa = new SqlDataAdapter(sc);
                        DataTable      ds = new DataTable();

                        sa.Fill(ds);

                        gvTicket.DataSource = ds;

                        gvTicket.DataBind();
                        cn.Cerrar();

                        if (0 < gvTicket.Rows.Count)
                        {
                        }
                        else
                        {
                            ds.Rows.Add(ds.NewRow());
                            gvTicket.DataSource = ds;
                            gvTicket.DataBind();

                            int totalColumns = gvTicket.Rows[0].Cells.Count;
                            gvTicket.Rows[0].Cells.Clear();
                            gvTicket.Rows[0].Cells.Add(new TableCell());
                            gvTicket.Rows[0].Cells[0].ColumnSpan      = totalColumns;
                            gvTicket.Rows[0].Cells[0].Text            = "No tiene tickets registrados";
                            gvTicket.Rows[0].Cells[0].Width           = 1150;
                            gvTicket.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                        }
                    }
                }
                catch (Exception x)
                {
                    if (idP == 1)
                    {
                        query = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido, Convert(Time(0),t.tiempo,0) as tiempo, t.observaciones, t.area, t.nombreImg " +
                                "from ticket t inner join estado e on t.idEstado = e.idEstado" +
                                " inner join usuario u on t.id = u.id left outer join usuario u2 on t.idTecnico=u2.id WHERE t.fecRegistro BETWEEN COALESCE(convert(datetime, " + f1 + ", 121), t.fecRegistro) AND COALESCE(convert(datetime, " + f2 + ", 121), t.fecRegistro) AND t.idEstado = COALESCE(" + estado + ", t.idEstado) order by t.fecRegistro desc, t.idEstado desc";
                    }
                    else if (idP == 4 || idP == 5)
                    {
                        query = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido, Convert(Time(0),t.tiempo,0) as tiempo, t.observaciones, t.area, t.nombreImg " +
                                "from ticket t inner join estado e on t.idEstado = e.idEstado" +
                                " inner join usuario u on t.id = u.id left outer join usuario u2 on t.idTecnico=u2.id WHERE t.fecRegistro BETWEEN COALESCE(convert(datetime, " + f1 + ", 121), t.fecRegistro) AND COALESCE(convert(datetime, " + f2 + ", 121), t.fecRegistro) AND t.idEstado = COALESCE(" + estado + ", t.idEstado) and t.id = " + id + " order by t.fecRegistro desc, t.idEstado desc";
                    }

                    cn.Conectar();

                    SqlCommand sc = new SqlCommand(query, cn.getConexion());

                    SqlDataAdapter sa = new SqlDataAdapter(sc);
                    DataTable      ds = new DataTable();

                    sa.Fill(ds);

                    gvTicket.DataSource = ds;

                    gvTicket.DataBind();
                    cn.Cerrar();

                    if (0 < gvTicket.Rows.Count)
                    {
                    }
                    else
                    {
                        ds.Rows.Add(ds.NewRow());
                        gvTicket.DataSource = ds;
                        gvTicket.DataBind();

                        int totalColumns = gvTicket.Rows[0].Cells.Count;
                        gvTicket.Rows[0].Cells.Clear();
                        gvTicket.Rows[0].Cells.Add(new TableCell());
                        gvTicket.Rows[0].Cells[0].ColumnSpan      = totalColumns;
                        gvTicket.Rows[0].Cells[0].Text            = "No tiene tickets registrados";
                        gvTicket.Rows[0].Cells[0].Width           = 1150;
                        gvTicket.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                    }
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "FILTRARDATOS");
                }
                return;
            }
        }
示例#19
0
        protected void btnNuevaClave_Click(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(txtUsu.Text))
                {
                    SqlCommand sc1 = new SqlCommand("select username from usuario where username=@usu", cn.getConexion());
                    sc1.Parameters.AddWithValue("@usu", txtUsu.Text);
                    cn.Conectar();
                    SqlDataAdapter sa1 = new SqlDataAdapter(sc1);
                    DataTable      dt  = new DataTable();
                    sa1.Fill(dt);

                    cn.Cerrar();

                    if (dt.Rows.Count > 0)
                    {
                        SqlCommand sc = new SqlCommand("select email, username, id from usuario where username=@usu", cn.getConexion());
                        sc.Parameters.AddWithValue("@usu", txtUsu.Text);
                        cn.Conectar();
                        SqlDataReader sa = sc.ExecuteReader();
                        sa.Read();
                        email     = sa["email"].ToString();
                        usu       = sa["username"].ToString();
                        idUsuario = sa["id"].ToString();
                        cn.Cerrar();
                        ConfigSMTP smtp = new ConfigSMTP();
                        smtp.enviarClave(email, usu);
                        if (!string.IsNullOrEmpty(mensaje))
                        {
                            lblError.Text    = mensaje;
                            lblError.Visible = true;
                            return;
                        }

                        SqlCommand sc2 = new SqlCommand("insert into solicitudClave values (@usuario, @fecha, 0)", cn.getConexion());
                        sc2.Parameters.AddWithValue("@usuario", idUsuario.ToString());
                        sc2.Parameters.AddWithValue("@fecha", DateTime.Today);
                        cn.Conectar();

                        sc2.ExecuteNonQuery();
                        cn.Cerrar();

                        lblAviso.Text    = "Su solicitud fue registrada. Verifique su correo.";
                        lblAviso.Visible = true;
                    }
                    else
                    {
                        lblError.Text    = "El usuario es erróneo o no está registrado";
                        lblError.Visible = true;
                        return;
                    }
                }
                else
                {
                    lblError.Text    = "Debe ingresar un usuario.";
                    lblError.Visible = true;
                    return;
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado.";
                lblError.Visible = true;
                ConfigSMTP smtp = new ConfigSMTP();
                smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNNUEVACLAVE");

                return;
            }
        }
示例#20
0
        //LISTADO DE TICKET DEL USUARIO
        public void ListarTicket()
        {
            try
            {
                string login = (string)(Session["username"]);
                cn.Conectar();
                string query = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, " +
                               "u2.username as usertec, t.fecAtendido, t.tiempo, " +
                               "t.observaciones, t.nombreImg, t.area" +
                               " from ticket t inner join estado e on t.idEstado=e.idEstado" +
                               " inner join usuario u on t.id=u.id left outer join usuario u2 on t.idTecnico=u2.id ";

                if (idP == 3)
                {
                    query = query + "where t.idEstado IN (1, 2, 3, 4) and u.id = " + id + " order by t.fecRegistro desc";
                }
                else if (idP == 2)
                {
                    query = query + "where t.area = 'Soporte Tecnico' and t.idEstado in (2, 3) and u2.id = " + id + " order by t.fecRegistro desc, t.idEstado desc";
                }
                else if (idP == 1)
                {
                    query = query + "where t.area = 'Soporte Tecnico' order by t.fecRegistro desc, t.idEstado desc";
                }
                else if (idP == 4)
                {
                    query = query + "where t.area = 'Recursos Humanos' order by t.fecRegistro desc, t.idEstado desc";
                }
                else if (idP == 5)
                {
                    query = query + "where t.area = 'Administrativa' order by t.fecRegistro desc, t.idEstado desc";
                }
                SqlCommand     sc = new SqlCommand(query, cn.getConexion());
                SqlDataAdapter sa = new SqlDataAdapter(sc);
                DataTable      ds = new DataTable();

                sa.Fill(ds);

                gvTicket.DataSource = ds;

                gvTicket.DataBind();
                cn.Cerrar();
                if (0 < gvTicket.Rows.Count)
                {
                    if (idP == 3)
                    {
                        gvTicket.Columns[2].Visible = false;
                        gvTicket.Columns[6].Visible = false;
                        gvTicket.Columns[7].Visible = false;
                        gvTicket.Columns[8].Visible = false;
                    }
                    else if (idP == 1 || idP == 2)
                    {
                        gvTicket.Columns[10].Visible = false;
                    }
                    else if (idP == 4 || idP == 5)
                    {
                        gvTicket.Columns[6].Visible = false;
                        gvTicket.Columns[8].Visible = false;
                    }
                    gvTicket.Visible = true;
                }
                else
                {
                    if (idP == 3)
                    {
                        gvTicket.Columns[2].Visible = false;
                        gvTicket.Columns[6].Visible = false;
                        gvTicket.Columns[7].Visible = false;
                        gvTicket.Columns[8].Visible = false;
                    }
                    else if (idP == 1 || idP == 2)
                    {
                        gvTicket.Columns[10].Visible = false;
                    }
                    else if (idP == 4 || idP == 5)
                    {
                        gvTicket.Columns[6].Visible = false;
                        gvTicket.Columns[8].Visible = false;
                    }
                    ds.Rows.Add(ds.NewRow());
                    gvTicket.DataSource = ds;
                    gvTicket.DataBind();

                    int totalColumns = gvTicket.Rows[0].Cells.Count;
                    gvTicket.Rows[0].Cells.Clear();
                    gvTicket.Rows[0].Cells.Add(new TableCell());
                    gvTicket.Rows[0].Cells[0].ColumnSpan      = totalColumns;
                    gvTicket.Rows[0].Cells[0].Text            = "No tiene tickets registrados";
                    gvTicket.Rows[0].Cells[0].Width           = 1150;
                    gvTicket.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "LISTATICKET");
                }
                return;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }
                else
                {
                    lblUsuario.Text = "Bienvenido " + Session["username"].ToString();
                }

                this.cn = new Conexion();

                if (!this.IsPostBack)
                {
                    try {
                        string     usuario = (string)(Session["username"]);
                        SqlCommand sc      = new SqlCommand("select id, idPerfil from usuario where username=@login", cn.getConexion());
                        sc.Parameters.AddWithValue("@login", usuario);
                        cn.Conectar();
                        SqlDataReader dr = sc.ExecuteReader();

                        dr.Read();

                        idP = Convert.ToInt32(dr["idPerfil"].ToString());
                        cn.Cerrar();
                    }catch (Exception x)
                    {
                        lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                        lblError.Visible = true;
                        if (Session["username"] != null)
                        {
                            ConfigSMTP smtp = new ConfigSMTP();
                            smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                        }
                        return;
                    }

                    if (idP != 1 && idP != 2)
                    {
                        Response.Redirect("login.aspx");
                        regUsuarios.Visible   = false;
                        ListaUsuarios.Visible = false;
                    }

                    using (SqlCommand cmd = new SqlCommand("SELECT idPerfil, descPerfil FROM perfil"))
                    {
                        cn.Cerrar();
                        cn.Conectar();
                        cmd.CommandType = CommandType.Text;
                        cmd.Connection  = cn.getConexion();

                        cboPerfil.DataSource     = cmd.ExecuteReader();
                        cboPerfil.DataTextField  = "descPerfil";
                        cboPerfil.DataValueField = "idPerfil";
                        cboPerfil.DataBind();

                        cn.Cerrar();
                    }
                }
                pwd1 = autoClave(10);
                pwd2 = sha2(pwd1);
                string login = (string)(Session["username"]);
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }
        }
示例#22
0
      protected void btnCambiar_Click(object sender, EventArgs e)
      {
          try
          {
              if (string.IsNullOrEmpty(Session["username"].ToString()))
              {
                  Session["error"] = "Primero debe iniciar sesión";
                  Response.Redirect("login.aspx");
                  return;
              }
              if (txtClaveN.Text == txtClaveN2.Text)
              {
                  String Login = Session["username"].ToString();

                  string claveA     = sha2(txtClaveA.Text);
                  String claveNueva = sha2(txtClaveN.Text);

                  cn.Conectar();
                  SqlCommand q = new SqlCommand("select email, nombre, clave from usuario where id=@log", cn.getConexion());
                  q.Parameters.AddWithValue("@log", Login);
                  SqlDataReader dr = q.ExecuteReader();
                  dr.Read();
                  claveANT = dr["clave"].ToString();

                  correo = dr["email"].ToString();
                  cn.Cerrar();
                  SqlCommand sc = new SqlCommand("update usuario set clave=@clave where username=@usu and clave=@claveA", cn.getConexion());
                  sc.Parameters.AddWithValue("@usu", Login);
                  sc.Parameters.AddWithValue("@claveA", claveA);
                  sc.Parameters.AddWithValue("@clave", claveNueva);
                  if (claveA == claveANT)
                  {
                      cn.Conectar();
                      sc.ExecuteNonQuery();
                      //ConfigSMTP smtp = new ConfigSMTP();
                      //smtp.enviarClaveNueva(correo, txtClaveN2.Text);
                      cn.Cerrar();
                      lblCorrecto.Text    = "Se ha modificado correctamente";
                      lblCorrecto.Visible = true;
                  }
                  else
                  {
                      lblError.Visible = true;
                      lblError.Text    = "La Clave anterior no es correcta";
                      return;
                  }
              }
              else
              {
                  lblError.Visible = true;
                  lblError.Text    = "Las contraseñas no coinciden.";
                  return;
              }
          }catch (Exception x)
          {
              lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
              lblError.Visible = true;
              if (Session["username"] != null)
              {
                  ConfigSMTP smtp = new ConfigSMTP();
                  smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNCAMBIAR");
              }

              return;
          }
      }
        protected void btngrabar_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }
                if (idP == 1 || idP == 2)
                {
                    DateTime hoy = DateTime.Now;
                    DateTime inicio;

                    cn.Conectar();
                    SqlCommand q2 = new SqlCommand("select t.fecAtendido from ticket t inner join usuario u on t.id=u.id" +
                                                   " inner join usuario u2 on t.idTecnico = u2.id where RIGHT('000000' + cast(t.idTicket AS varchar(6)), 6)=@tck", cn.getConexion());
                    q2.Parameters.AddWithValue("@tck", idTicket);
                    SqlDataReader dr2 = q2.ExecuteReader();
                    dr2.Read();
                    inicio = DateTime.Parse(dr2["fecAtendido"].ToString());

                    cn.Cerrar();

                    double minutos  = (hoy - inicio).TotalMinutes;
                    String minutosF = "";
                    if (minutos > 59)
                    {
                        if (minutos < 120)
                        {
                            double horas   = (hoy - inicio).TotalHours;
                            int    residuo = Convert.ToInt32(minutos % 60);
                            if (residuo == 1)
                            {
                                minutosF = horas.ToString("##") + " hora " + residuo + " minuto";
                            }
                            else if (residuo < 1)
                            {
                                minutosF = horas.ToString("##") + " hora";
                            }
                            else
                            {
                                minutosF = horas.ToString("##") + " hora " + residuo + " minutos";
                            }
                        }
                        else
                        {
                            double horas   = (hoy - inicio).TotalHours;
                            int    residuo = Convert.ToInt32(minutos % 60);
                            if (residuo == 1)
                            {
                                minutosF = horas.ToString("##") + " horas " + residuo + " minuto";
                            }
                            else if (residuo < 1)
                            {
                                minutosF = horas.ToString("##") + " horas";
                            }
                            else
                            {
                                minutosF = horas.ToString("##") + " horas " + residuo + " minutos";
                            }
                        }
                    }
                    else
                    {
                        minutosF = minutos.ToString("##") + " minutos";
                    }



                    cn.Conectar();
                    SqlCommand sc = new SqlCommand("update ticket set observaciones ='" + txtobs.Text + "', idEstado=4, tiempo = '" + minutosF +
                                                   "' where RIGHT('000000' + cast(idTicket AS varchar(6)), 6) = '" + idTicket + "'", cn.getConexion());
                    sc.ExecuteNonQuery();
                    cn.Cerrar();
                    cn.Conectar();
                    SqlCommand q = new SqlCommand("select u.username, u.email, u2.username as tecnico, t.requerimiento from ticket t inner join usuario u on t.id=u.id" +
                                                  " inner join usuario u2 on t.idTecnico = u2.id where RIGHT('000000' + cast(t.idTicket AS varchar(6)), 6)=@tck", cn.getConexion());
                    q.Parameters.AddWithValue("@tck", idTicket);
                    SqlDataReader dr = q.ExecuteReader();
                    dr.Read();
                    rqc     = dr["requerimiento"].ToString();
                    email   = dr["email"].ToString();
                    tecnico = dr["tecnico"].ToString();

                    //ConfigSMTP smtp = new ConfigSMTP();
                    //smtp.emailTecADM(tecnico, rqc);
                    //smtp.enviarTecUsu(email, rqc);
                    //cn.Cerrar();

                    Session["mensaje"] = "Se finalizó el ticket exitosamente.";
                    string cerrar = "window.close();";
                    Session.Remove("idTicket");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closewindows", cerrar, true);
                }
                else if (idP == 4 || idP == 5)
                {
                    cn.Conectar();

                    SqlCommand sc = new SqlCommand("update ticket set fecAtencion = GETDATE(), observaciones ='" + txtobs.Text + "', idEstado=4, tiempo = case " +
                                                   "when convert(varchar(8), fecAtendido, 108) <= getdate() " +
                                                   "then getdate() - convert(varchar(8), fecAtendido, 108)" +
                                                   " else convert(varchar(8), fecAtendido, 108) - getdate() end " +
                                                   "where RIGHT('000000' + cast(idTicket AS varchar(6)), 6) = '" + idTicket + "'", cn.getConexion());
                    sc.ExecuteNonQuery();
                    cn.Cerrar();
                    cn.Conectar();
                    SqlCommand q = new SqlCommand("select u.username, u.email, u2.username as tecnico, t.requerimiento from ticket t inner join usuario u on t.id=u.id" +
                                                  " inner join usuario u2 on t.idTecnico = u2.id where RIGHT('000000' + cast(t.idTicket AS varchar(6)), 6)=@tck", cn.getConexion());
                    q.Parameters.AddWithValue("@tck", idTicket);
                    SqlDataReader dr = q.ExecuteReader();
                    dr.Read();
                    rqc     = dr["requerimiento"].ToString();
                    email   = dr["email"].ToString();
                    tecnico = dr["tecnico"].ToString();

                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.emailTecADM(tecnico, rqc);
                    smtp.enviarTecUsu(email, rqc);
                    cn.Cerrar();

                    Session["mensaje"] = "Se finalizó el ticket exitosamente.";
                    string cerrar = "window.close();";
                    Session.Remove("idTicket");
                    ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closewindows", cerrar, true);
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.UserHostAddress.ToString(), Session["username"].ToString(), "BTNGRABAR");
                }
                return;
            }
        }
示例#24
0
        /*Boton guarda la edicion del ticket*/
        protected void btnEditarTicket_Click(object sender, EventArgs e)
        {
            string query = "";

            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }
                if (Session["idTicket"] != null)
                {
                    if (idP == 1)
                    {
                        if (fileImg.HasFile)
                        {
                            query = "update ticket set requerimiento = '" + txtreq.Text + "', observaciones = '" + txtObs.Text + "', imagen = @img, nombreImg = @nomImg where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                            cn.Conectar();
                            SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                            cmd.Parameters.AddWithValue("@img", fileImg.FileBytes);
                            cmd.Parameters.AddWithValue("@nomImg", fileImg.FileName);

                            cmd.ExecuteNonQuery();
                            cn.Cerrar();

                            lblCorrectoEditar.Text    = "Se ha modificado correctamente.";
                            lblCorrectoEditar.Visible = true;
                        }
                        else
                        {
                            query = "update ticket set requerimiento = '" + txtreq.Text + "', observaciones = '" + txtObs.Text + "'  where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                            cn.Conectar();
                            SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                            cmd.ExecuteNonQuery();
                            cn.Cerrar();

                            lblCorrectoEditar.Text    = "Se ha modificado correctamente.";
                            lblCorrectoEditar.Visible = true;
                        }
                        ListarTicket();
                    }
                    else if (idP == 2)
                    {
                        query = "update ticket set observaciones = '" + txtObs.Text + "' where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                        cn.Conectar();
                        SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                        cmd.ExecuteNonQuery();
                        cn.Cerrar();

                        lblCorrectoEditar.Text    = "Se ha modificado correctamente.";
                        lblCorrectoEditar.Visible = true;
                    }
                    else if (idP == 3)
                    {
                        query = "update ticket set requerimiento = '" + txtreq.Text + "' where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                        cn.Conectar();
                        SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                        cmd.ExecuteNonQuery();
                        cn.Cerrar();

                        lblCorrectoEditar.Text    = "Se ha modificado correctamente.";
                        lblCorrectoEditar.Visible = true;
                    }
                    else if (idP == 4 || idP == 5)
                    {
                        query = "update ticket set observaciones = '" + txtObs.Text + "' where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                        cn.Conectar();
                        SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                        cmd.ExecuteNonQuery();
                        cn.Cerrar();
                        lblCorrectoEditar.Text    = "Se ha modificado correctamente.";
                        lblCorrectoEditar.Visible = true;
                    }
                }
            }
            catch (Exception x)
            {
                lblErrorEditar.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblErrorEditar.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNGRABAR");
                }
                return;
            }
        }
        protected void btnGrabar_Click(object sender, EventArgs e)
        {
            string query = "";

            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }
                if (Session["idTicket"] != null)
                {
                    if (txtreq.Visible.Equals(true))
                    {
                        if (fileImg.HasFile)
                        {
                            query = "update ticket set requerimiento = '" + txtreq.Text + "', imagen = @img, nombreImg = @nomImg where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                            cn.Conectar();
                            SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                            cmd.Parameters.AddWithValue("@img", fileImg.FileBytes);
                            cmd.Parameters.AddWithValue("@nomImg", fileImg.FileName);

                            cmd.ExecuteNonQuery();
                            cn.Cerrar();
                            if (idP.Equals(3))
                            {
                                string cerrar = "window.close();";
                                Session.Remove("idTicket");
                                Session.Remove("requerimiento");
                                Session.Remove("observaciones");
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closewindows", cerrar, true);
                                Session["mensaje"] = "Se ha modificado correctamente.";
                                return;
                            }

                            lblCorrecto.Text    = "Se ha modificado correctamente.";
                            lblCorrecto.Visible = true;
                        }
                        else
                        {
                            query = "update ticket set requerimiento = '" + txtreq.Text + "' where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                            cn.Conectar();
                            SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                            cmd.ExecuteNonQuery();
                            cn.Cerrar();
                            if (idP.Equals(3))
                            {
                                string cerrar = "window.close();";
                                Session.Remove("idTicket");
                                Session.Remove("requerimiento");
                                Session.Remove("observaciones");
                                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "closewindows", cerrar, true);
                                Session["mensaje"] = "Se ha modificado correctamente.";
                                return;
                            }
                            lblCorrecto.Text    = "Se ha modificado correctamente.";
                            lblCorrecto.Visible = true;
                        }
                    }
                    else
                    {
                        query = "update ticket set observaciones = '" + txtObs.Text + "' where RIGHT('000000'+ cast(idTicket AS varchar(6)), 6) = '" + Session["idTicket"].ToString() + "'";
                        cn.Conectar();
                        SqlCommand cmd = new SqlCommand(query, cn.getConexion());

                        cmd.ExecuteNonQuery();
                        cn.Cerrar();
                        lblCorrecto.Text    = "Se ha modificado correctamente.";
                        lblCorrecto.Visible = true;
                    }
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNGRABAR");
                }
                return;
            }
        }
示例#26
0
        //LISTAR TICKET POR AÑOS PASADOS
        public void ListarTicketCbo()
        {
            try {
                cn.Conectar();
                string query1 = "";
                if (int.Parse(cboHistorial.SelectedValue.ToString()) == 1)
                {
                    query1 = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido, t.tiempo, t.observaciones, t.nombreImg" +
                             " from ticket t inner join estado e on t.idEstado=e.idEstado" +
                             " inner join usuario u on t.id=u.id left outer join usuario u2 on t.idTecnico=u2.id order by t.fecRegistro desc";
                }
                else
                {
                    query1 = "select t.idTicket, t.fecRegistro, u.username, t.requerimiento, e.desEstado, u2.username as usertec, t.fecAtendido,t.tiempo, t.observaciones, t.nombreImg" +
                             " from ticket" + cboHistorial.SelectedValue.ToString() + " t inner join estado e on t.idEstado=e.idEstado" +
                             " inner join usuario u on t.id=u.id left outer join usuario u2 on t.idTecnico=u2.id order by t.fecRegistro desc";
                }
                SqlCommand sc = new SqlCommand(query1, cn.getConexion());

                SqlDataAdapter sa = new SqlDataAdapter(sc);
                DataTable      ds = new DataTable();

                sa.Fill(ds);

                gvTicket.DataSource = ds;

                gvTicket.DataBind();
                cn.Cerrar();
                if (0 < gvTicket.Rows.Count)
                {
                    if (idP == 3)
                    {
                        gvTicket.Rows[0].Cells[5].Visible = false;
                        gvTicket.Rows[0].Cells[6].Visible = false;
                        gvTicket.Rows[0].Cells[7].Visible = false;
                        gvTicket.Rows[0].Cells[8].Visible = false;
                    }
                    gvTicket.Visible = true;
                }
                else
                {
                    ds.Rows.Add(ds.NewRow());
                    gvTicket.DataSource = ds;
                    gvTicket.DataBind();

                    int totalColumns = gvTicket.Rows[0].Cells.Count;
                    gvTicket.Rows[0].Cells.Clear();
                    gvTicket.Rows[0].Cells.Add(new TableCell());
                    gvTicket.Rows[0].Cells[0].ColumnSpan      = totalColumns;
                    gvTicket.Rows[0].Cells[0].Text            = "No tiene tickets registrados";
                    gvTicket.Rows[0].Cells[0].Width           = 1150;
                    gvTicket.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "LISTARTICKETCBO");
                }
                return;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                this.cn = new Conexion();
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                }
                else
                {
                    string     login = Session["username"].ToString();
                    SqlCommand sc    = new SqlCommand("select idPerfil from usuario where username=@login", cn.getConexion());
                    sc.Parameters.AddWithValue("@login", login);
                    cn.Conectar();
                    SqlDataReader dr = sc.ExecuteReader();

                    dr.Read();

                    idP = Convert.ToInt32(dr["idPerfil"].ToString());
                    cn.Cerrar();
                }


                if (!IsPostBack)
                {
                    if (Session["requerimiento"] != null)
                    {
                        txtreq.Text = Session["requerimiento"].ToString();
                    }
                    if (Session["observaciones"] != null)
                    {
                        txtObs.Text = Session["observaciones"].ToString();
                    }
                    if (Session["idTicket"] != null)
                    {
                        lblticket.Text = Session["idTicket"].ToString();
                    }
                    req.Visible          = false;
                    txtreq.Visible       = false;
                    lblImg.Visible       = false;
                    fileImg.Visible      = false;
                    txtObs.Visible       = false;
                    lblContador2.Visible = false;
                    txtContador2.Visible = false;
                    Obs.Visible          = false;
                    btnGrabar.Visible    = false;
                    lblCorrecto.Visible  = false;
                    lblContador.Visible  = false;
                    txtContador.Visible  = false;
                }


                if (idP.Equals(3))
                {
                    req.Visible          = true;
                    txtContador.Visible  = true;
                    lblContador.Visible  = true;
                    txtreq.Visible       = true;
                    lblImg.Visible       = true;
                    fileImg.Visible      = true;
                    btnGrabar.Visible    = true;
                    btnEditObs.Visible   = false;
                    btnEditRq.Visible    = false;
                    btnFinalizar.Visible = false;
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "PAGELOAD");
                }
                return;
            }
        }
示例#28
0
        //BOTON DE EN EJECUCION DEL TECNICO
        protected void btnEjecucion_Click(object sender, EventArgs e)
        {
            try
            {
                if (Session["username"] == null)
                {
                    Session["error"] = "Primero debe iniciar sesión";
                    Response.Redirect("login.aspx");
                    return;
                }

                if (Session["idTicket"] == null)
                {
                    lblError.Text    = "Debe seleccionar un requerimiento de la tabla";
                    lblError.Visible = true;
                    return;
                }
                else
                {
                    SqlCommand sc = new SqlCommand("select idEstado from ticket where RIGHT('000000' + cast(idTicket AS varchar(6)), 6) = @tck", cn.getConexion());
                    sc.Parameters.AddWithValue("@tck", Session["idTicket"].ToString());
                    cn.Conectar();
                    SqlDataReader dr = sc.ExecuteReader();

                    dr.Read();
                    int estado;
                    estado = Convert.ToInt32(dr["idEstado"].ToString());
                    cn.Cerrar();

                    if (estado.Equals(1))
                    {
                        lblError.Text    = "El ticket seleccionado de ser asignado a un técnico";
                        lblError.Visible = true;
                        return;
                    }

                    else if (estado.Equals(3))
                    {
                        lblError.Text    = "El ticket seleccionado ya se encuentra en Ejecución.";
                        lblError.Visible = true;
                        return;
                    }
                    else
                    {
                        cn.Conectar();
                        SqlCommand cmd = new SqlCommand("update ticket set idEstado=3, fecAtendido=getdate() where RIGHT('000000' + cast(idTicket AS varchar(6)), 6) = @tck", cn.getConexion());
                        cmd.Parameters.AddWithValue("@tck", Session["idTicket"].ToString());
                        cmd.ExecuteNonQuery();
                        cn.Cerrar();
                        Session.Remove("idTicket");
                        ListarTicket();
                    }
                }
            }
            catch (Exception x)
            {
                lblError.Text    = "Ha ocurrido un error inesperado. Comuniquese con Soporte Técnico.";
                lblError.Visible = true;
                if (Session["username"] != null)
                {
                    ConfigSMTP smtp = new ConfigSMTP();
                    smtp.enviarError(x.Message.ToString(), Request.Url.ToString(), Session["username"].ToString(), "BTNEJECUCION");
                }
                return;
            }
        }