protected void ddlAssunto_Change(Object sender, EventArgs e)
    {
        String value = this.ddlAssunto.SelectedValue;

        if (value.Equals(String.Empty))
        {
            alert("Houve um erro ao carregar!");
        }
        else
        {

            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE LOAD_LIST_PERFIL_BY_TIPO_RECADO " + value , "CHR_DESC_PERFIL");

            String html = "<ul>";

            for (int i = 0; i < query.Count(); i++)
            {
                html += "<li>" + query.Field(i, 0) + "</li>";
            }

            html += "</ul>";

            this.tdQuem.InnerHtml = html;

        }
    }
Ejemplo n.º 2
0
        // carrega a página
        public Boolean loadPage(HtmlTable table, Boolean showEdit, Boolean showFirst, Boolean zebra, String editText, String editFunc)
        {
            // classe mãe
            if (!base.loadPage()){
                return false;
            }
            else
            {
                CDataBase db = new CDataBase();
                HtmlTableRow row;
                HtmlTableCell cell;

                CQuery query = db.select(this._isqlload, this._fields);

                if (query == null)
                    return false;

                int initRow = table.Rows.Count;

                for (int i = 0; i < query.Count(); i++)
                {

                    row = new HtmlTableRow();

                    for (int j = (showFirst ? 0 : 1); j < query.Row(i).Count(); j++)
                    {

                        cell = new HtmlTableCell();
                        cell.InnerHtml = query.Field(i, j);

                        row.Cells.Add(cell);
                    }

                    if (showEdit)
                    {
                        cell = new HtmlTableCell();
                        cell.InnerHtml = "<a href=\"#\" onclick=\"" + mountFunction(editFunc, query.Row(i)) + "\"" +
                            " onmouseenter=\"javascript:document.getElementById('" + table.ID + "').rows[" + (int)(i + initRow) + "].style.color = 'EB151C';\"" +
                            " onmouseleave=\"javascript:document.getElementById('" + table.ID + "').rows[" + (int)(i + initRow) + "].style.color = '';\"" +
                            ">" + editText + "</a>";
                        row.Cells.Add(cell);
                    }

                    if (i % 2 == 1 && zebra)
                        row.Style.Add("background-color", "Gainsboro");

                    table.Rows.Add(row);

                }

                return true;
            }
        }
    public override Boolean loadPage()
    {
        String id = getUrlParameter(this.Request.RawUrl, "morador");

        String script = "<script type=\"text/javascript\" language=\"javascript\">" +
            "alert('Erro ao carregar a página!');self.close();</script>";

        if (id.Equals(String.Empty))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "erro", script, false);
        }
        else
        {

            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE LOAD_REG_MORADOR " + id,
                "CHR_NOME;CHR_NUMERO_LAVANDERIA;CHR_DESC_PERFIL;CHR_DESC_STATUS_MORADOR;CHR_DESC_IES;" +
                "CHR_DESC_CURSO;CHR_DESC_QUARTO;CHR_CIDADE_ORIGEM;CHR_TELEFONE_CELULAR;CHR_EMAIL;CHR_ANIVERSARIO;" +
                "CHR_APELIDO;CHR_INGRESSO");

            if (query.Count() == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "erro", script, false);
            }
            else
            {

                this.tdNome.InnerText = query.Field(0, 0);
                this.tdNumLavanderia.InnerText = query.Field(0, 1);
                this.tdPerfil.InnerText = query.Field(0, 2);
                this.tdStatus.InnerText = query.Field(0, 3);
                this.tdIes.InnerText = query.Field(0, 4);
                this.tdCurso.InnerText = query.Field(0, 5);
                this.tdQuarto.InnerText = query.Field(0, 6);
                this.tdCidadeOrigem.InnerText = query.Field(0, 7);
                this.tdTelefone.InnerText = query.Field(0, 8);
                this.tdEmail.InnerText = query.Field(0, 9);
                this.tdAniversario.InnerText = query.Field(0, 10);
                this.tdApelido.InnerText = query.Field(0, 11);
                this.tdIngresso.InnerText = query.Field(0, 12);

                this.frmFoto.Attributes["src"] =
                    "frmFoto.aspx?morador=" + id + ";";

            }

        }

        return true;
    }
    public override Boolean loadPage()
    {
        String id = getUrlParameter(Request.RawUrl, "obra");

        String scripterro = "<script type=\"text/javascript\" language=\"javascript\">" +
                "alert('Houve um erro ao carregar a obra!');self.close();</script>";

        if (id.Equals(String.Empty))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "erro", scripterro, false);
        }
        else
        {
            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE LOAD_REG_OBRA " + id,
                "COD_OBRA;CHR_DESC_TIPO_OBRA;CHR_CHAMADA;CHR_TITULO;CHR_NOME_AUTOR_OBRA;CHR_EDICAO;CHR_PUBLICACAO;" +
                "CHR_NORMALIZACAO;CHR_DESC_ASSUNTO_OBRA;CHR_DESC_STATUS_OBRA;BLN_PERMITE_RESERVA");

            if (query.Count() == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "erro", scripterro, false);
            }
            else
            {
                this.tdCodigo.InnerText = query.Field(0, 0);
                this.hdCodObra.Value = query.Field(0, 0);
                this.tdTipoObra.InnerText = query.Field(0, 1);
                this.tdNumChamada.InnerText = query.Field(0, 2);
                this.tdTitulo.InnerHtml = "<h6>" + query.Field(0, 3) + "</h6>";
                this.tdAutorObra.InnerText = query.Field(0, 4);
                this.tdEdicao.InnerText = query.Field(0, 5);
                this.tdPublicacao.InnerText = query.Field(0, 6);
                this.tdNormalizacao.InnerText = query.Field(0, 7);
                this.tdAssuntoObra.InnerText = query.Field(0, 8);
                this.tdStatusObra.InnerText = query.Field(0, 9);

                this.btnReserva.Enabled = Convert.ToBoolean(query.Field(0, 10)) ? true : false;
            }

        }
        return true;
    }
    public override Boolean loadPage()
    {
        String id = getUrlParameter(this.Request.RawUrl, "aviso");

        String script = "<script type=\"text/javascript\" language=\"javascript\">" +
            "alert('Erro ao carregar a página!');self.close();</script>";

        if (id.Equals(String.Empty))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "erro", script, false);
        }
        else
        {

            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE LOAD_REG_AVISO " + id, "CHR_NOME;DT_DATAHORA;CHR_ASSUNTO;CHR_AVISO");

            if (query.Count() == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "erro", script, false);
            }
            else
            {

                this.tdMorador.InnerText = query.Field(0, 0);
                this.tdData.InnerText = query.Field(0, 1);
                this.tdAssunto.InnerHtml = "<h3>" + query.Field(0, 2) + "</h3>";
                this.tdMensagem.InnerHtml = query.Field(0, 3).Replace("[b]", "<b>")
                    .Replace("[/b]", "</b>")
                    .Replace("[i]", "<i>")
                    .Replace("[/i]", "</i>")
                    .Replace("[u]", "<u>")
                    .Replace("[/u]", "</u>")
                    .Replace("[br]", "<br />");
            }

        }

        return true;
    }
    protected void btnReserva_Click(object sender, EventArgs e)
    {
        String codObra = this.hdCodObra.Value;
        String codMorador = ((CLogin)Session["login"]).getCod();
        String scripterro = "<script type=\"text/javascript\" language=\"javascript\">" +
            "alert('Houve um erro ao reservar a obra!\\n#ERRO');self.close();</script>";

        if (codObra.Equals(String.Empty) || codMorador.Equals(String.Empty))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "erro", scripterro, false);
        }
        else
        {
            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE VERIFY_INSERT_RESERVA_OBRA " + codMorador + "," + codObra, "P_CHR_MSG_ERRO");

            if (query.Count() == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "erro",
                    scripterro.Replace("#ERRO", "VERIFY_INSERT_RESERVA_OBRA"), false);
            }
            else
            {

                if (!query.Field(0, 0).Equals(String.Empty))
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "erro",
                        "<script type=\"text/javascript\" language=\"javascript\">" +
                        "alert('Não é possível fazer a reserva!\\n" + query.Field(0, 0) + "')</script>", false);
                }
                else
                {
                    try
                    {
                        db.execute("EXECUTE INSERT_RESERVA_OBRA " + codMorador + "," + codObra);
                        this.ClientScript.RegisterStartupScript(this.GetType(), "sucesso",
                            "<script type=\"text/javascript\" language=\"javascript\">" +
                            "alert('Obra reservada com sucesso!');self.close();</script>", false);
                    }
                    catch (Exception ex)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "erro",
                            scripterro.Replace("#ERRO", ex.Message), false);
                    }
                }
            }
        }
    }
Ejemplo n.º 7
0
        private void setIdentity(CDataBase cdb)
        {
            if (this._identity != -1)
            {
                if (((TextBox)this._fields[_identity].pageelement()).Text.Equals(String.Empty))
                {

                    CQuery query = cdb.select("SELECT IDENT_CURRENT('" + this._table + "') AS IDENT_CURRENT", "IDENT_CURRENT");

                    if(query.Count() > 0)
                    {
                        ((TextBox)this._fields[_identity].pageelement()).Text = query.Field(0, 0);
                        this._fields[_identity].pageelement().Attributes.Add("Value", query.Field(0, 0));
                    }
                }

            }
        }
Ejemplo n.º 8
0
        public Boolean saveClick()
        {
            if (this._isqlsave.Equals(String.Empty) || this._isqlverifysave.Equals(String.Empty))
            {
                return false;
            }
            else
            {
                String fields = " ";

                for (int i = 0; i < this._fields.Count; i++)
                {

                    // se é campo editável
                    if (this._fields[i].editable())
                    {

                        // verifica se é nulo
                        if (this._fields[i].notnull())
                        {
                            if (this._fields[i].fieldtype() == FieldType.TextBox)
                            {
                                if (((TextBox)this._fields[i].pageelement()).Text.Equals(String.Empty))
                                {
                                    alert("Preencha o campo " + this._fields[i].desc() + "!");
                                    return false;
                                }
                            }
                            else if (this._fields[i].fieldtype() == FieldType.SelectBox)
                            {
                                if (((DropDownList)_fields[i].pageelement()).SelectedValue.Equals(String.Empty))
                                {
                                    alert("Preencha o campo " + this._fields[i].desc() + "!");
                                    return false;
                                }
                            }
                        }

                        // verifica data
                        if (this._fields[i].sqltype() == SQLType.Date && this._fields[i].fieldtype() == FieldType.TextBox)
                        {
                            try
                            {
                                String value = ((TextBox)this._fields[i].pageelement()).Text;
                                DateTime dt = new DateTime(Convert.ToInt32(value.Substring(6, 4)),
                                    Convert.ToInt32(value.Substring(3, 2)), Convert.ToInt32(value.Substring(0, 2)));
                            }
                            catch (Exception ex)
                            {
                                alert("Digite uma data válida (DD/MM/AAAA) para o campo " + this._fields[i].desc() + "!");
                                return false;
                            }
                        }

                        // verifica campo numérico
                        if (this._fields[i].sqltype() == SQLType.Numeric && this._fields[i].fieldtype() == FieldType.TextBox && (i != _identity))
                        {

                            try
                            {
                                String value = ((TextBox)this._fields[i].pageelement()).Text;
                                if (!value.Equals(String.Empty) && this._fields[i].notnull())
                                {
                                    value = value.Replace(",", ".");

                                    Double db = Convert.ToDouble(value);
                                }
                            }
                            catch
                            {
                                alert("Digite um valor numérico válido para o campo " + this._fields[i].desc() + "!");
                                return false;
                            }
                        }

                        String aux;

                        if (this._fields[i].fieldtype() == FieldType.TextBox)
                        {
                            aux = ((TextBox)this._fields[i].pageelement()).Text;
                        }
                        else if (this._fields[i].fieldtype() == FieldType.SelectBox)
                        {
                            aux = ((DropDownList)_fields[i].pageelement()).SelectedValue;
                        }
                        else if (this._fields[i].fieldtype() == FieldType.CheckBox)
                        {
                            aux = ((CheckBox)_fields[i].pageelement()).Checked ? "1" : "0";
                        }
                        else if (this._fields[i].fieldtype() == FieldType.Calendar)
                        {
                            aux = ((Calendar)_fields[i].pageelement()).SelectedDate.Year.ToString() + "-" +
                                ((Calendar)_fields[i].pageelement()).SelectedDate.Month.ToString() + "-" +
                                ((Calendar)_fields[i].pageelement()).SelectedDate.Day.ToString();
                        }
                        else
                        {
                            aux = String.Empty;
                        }

                        fields += ((aux.Equals(String.Empty)&& i != _identity) ? ("NULL,") : ("'" + aux.Replace("'", "''") + "',"));
                    }

                }

                fields = fields.Substring(0, fields.Length - 1);

                CDataBase cdb = new CDataBase();
                CQuery query;

                if (!this._isqlverifysave.Equals("-1"))
                {
                    query = cdb.select(this._isqlverifysave + fields, "P_CHR_MSG_ERRO");
                }
                else
                {
                    query = new CQuery();
                    CRow row = new CRow();
                    row.addField("", "");
                    query.addRow(row);

                }

                if (query.Count() == 0)
                {
                    alert("Houve um erro ao salvar o registro!");
                    this.setPageStatus(StatusPage.OpenUnload);
                    return false;
                }
                else
                {
                    if (!query.Field(0, 0).Equals(String.Empty))
                    {
                        alert("Não foi possível salvar o registro!\\n" + query.Field(0, 0));
                        clearFields();
                        this.setPageStatus(StatusPage.OpenUnload);
                        return false;
                    }
                    else
                    {
                        try
                        {
                            cdb.execute(this._isqlsave + fields);
                            this.setIdentity(cdb);
                            this.setPageStatus(StatusPage.AfterSaveClick);
                        }
                        catch (Exception ex)
                        {
                            alert("Erro ao salvar o registro!\\n" + ex.Message);
                            this.setPageStatus(StatusPage.OpenUnload);
                        }
                    }
                }

                return true;
            }
        }
Ejemplo n.º 9
0
        public override Boolean loadPage(String id)
        {
            // verifica permissão
            if (!base.loadPage())
            {
                return false;
            }

            try
            {

                CDataBase db = new CDataBase();

                if (id.Equals(String.Empty))
                {
                    id = getUrlParameter(Request.RawUrl, this._idurl);
                }

                if (id.Equals("-1"))
                {
                    this.setPageStatus(StatusPage.OpenUnload);
                    return false;
                }
                else
                {

                    CQuery query = db.select(this._isqlload + " " + id, this.mountFieldName());

                    if (query.Count() == 0)
                    {
                        this.setPageStatus(StatusPage.OpenUnload);
                    }
                    else
                    {

                        for (int i = 0; i < this._fields.Count; i++)
                        {
                            if (_fields[i].fieldtype() == FieldType.TextBox)
                            {
                                ((TextBox)this._fields[i].pageelement()).Text = query.Field(0, i);
                            }
                            else if (_fields[i].fieldtype() == FieldType.SelectBox)
                            {
                                ((DropDownList)_fields[i].pageelement()).SelectedValue = query.Field(0,i);
                            }
                            else if (_fields[i].fieldtype() == FieldType.CheckBox)
                            {
                                try
                                {
                                    ((CheckBox)_fields[i].pageelement()).Checked = Convert.ToBoolean(query.Field(0, i));
                                }
                                catch (Exception ex1)
                                {
                                    // empty
                                }
                            }
                            else if (_fields[i].fieldtype() == FieldType.Calendar)
                            {
                                try
                                {
                                    ((Calendar)_fields[i].pageelement()).SelectedDate = Convert.ToDateTime(query.Field(0, i));
                                }
                                catch (Exception ex2)
                                {
                                    // empty
                                }
                            }
                        }

                        this.setPageStatus(StatusPage.OpenLoad);

                    }
                }

            }
            catch (Exception ex)
            {
                return false;
            }

            return true;
        }
Ejemplo n.º 10
0
        public Boolean delClick()
        {
            if (this._isqldel.Equals(String.Empty))
            {
                return false;
            }
            else
            {
                CDataBase cdb = new CDataBase();

                String id = ((TextBox)this._fields[_identity].pageelement()).Text;

                if (id.Equals(String.Empty))
                {
                    id = this._fields[_identity].pageelement().Attributes["Value"].ToString();
                }

                CQuery query = cdb.select(this._isqldel + " " + id, "P_CHR_MSG_ERRO");

                if (query.Count() == 0)
                {
                    return false;
                }
                else
                {
                    if (query.Field(0, 0).Equals(String.Empty))
                    {
                        this.setPageStatus(StatusPage.AfterDelClick);

                        // limpa os campos
                        clearFields();

                        return true;
                    }
                    else
                    {
                        alert("Impossível excluir o registro!\\n" + query.Field(0, 0));
                        return false;
                    }
                }
            }
        }
Ejemplo n.º 11
0
        public Boolean doLogin(String user, String pass)
        {
            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE DO_LOGIN '" + user + "','" + pass + "'",
                "DO_LOGIN");

            try
            {
                if (query.Field(0, 0) == "1")
                {
                    this._user = user;
                    return true;
                }
                else
                    return false;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Ejemplo n.º 12
0
        public Boolean verificaPermissao(String item)
        {
            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE VERIFICA_PERMISSAO " + item + ",'" + this._user + "'", "PERMISSAO");

            try
            {
                if (query.Field(0, 0) == "0")
                    return false;
                else
                    return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
Ejemplo n.º 13
0
        public String getCod()
        {
            if (this._cod.Equals("-1"))
            {
                CDataBase db = new CDataBase();

                CQuery query = db.select("EXECUTE LOAD_MORADOR_COD_BY_LOGIN '" + this._user + "'", "COD_MORADOR");

                if (query.Count() > 0)
                    this._cod = query.Field(0, 0);
            }

            return this._cod;
        }
    private void registraEmprestimo(String idReserva)
    {
        String scripterro = "<script type=\"text/javascript\" language=\"javascript\">" +
            "alert('Houve um erro ao reservar a obra!\\n#ERRO');self.close();</script>";

        if (idReserva.Equals(String.Empty) || idReserva.Equals(String.Empty))
        {
            this.ClientScript.RegisterStartupScript(this.GetType(), "erro", scripterro, false);
        }
        else
        {
            CDataBase db = new CDataBase();

            CQuery query = db.select("EXECUTE VERIFY_INSERT_EMPRESTIMO_RESERVA_OBRA " + idReserva, "P_CHR_MSG_ERRO");

            if (query.Count() == 0)
            {
                this.ClientScript.RegisterStartupScript(this.GetType(), "erro",
                    scripterro.Replace("#ERRO", "VERIFY_INSERT_EMPRESTIMO_RESERVA_OBRA"), false);
            }
            else
            {

                if (!query.Field(0, 0).Equals(String.Empty))
                {
                    this.ClientScript.RegisterStartupScript(this.GetType(), "erro",
                        "<script type=\"text/javascript\" language=\"javascript\">" +
                        "alert('Não é possível fazer a o empréstimo!\\n" + query.Field(0, 0) + "')</script>", false);
                }
                else
                {
                    try
                    {
                        db.execute("EXECUTE INSERT_EMPRESTIMO_RESERVA_OBRA " + idReserva);
                        this.ClientScript.RegisterStartupScript(this.GetType(), "sucesso",
                            "<script type=\"text/javascript\" language=\"javascript\">" +
                            "alert('Empréstimo realizado com sucesso!')</script>", false);
                    }
                    catch (Exception ex)
                    {
                        this.ClientScript.RegisterStartupScript(this.GetType(), "erro",
                            scripterro.Replace("#ERRO", ex.Message), false);
                    }
                }
            }
        }

        this.loadPage();
    }
Ejemplo n.º 15
0
    private void renovaEmprestimo(String id)
    {
        String erro = "Houve um erro ao renovar o empréstimo!#ERRO";

        if (id.Equals(String.Empty))
        {
            alert(erro.Replace("#ERRO", "\\nID not found"));
        }
        else
        {
            try
            {
                CDataBase db = new CDataBase();

                CQuery query = db.select("EXECUTE RENOVA_EMPRESTIMO_OBRA " + id, "P_CHR_MSG_ERRO");

                if (query.Count() == 0)
                {
                    alert(erro.Replace("#ERRO", "\\nQUERY not found"));
                }
                else
                {
                    if (query.Field(0, 0).Equals(String.Empty))
                    {
                        alert("Empréstimo renovado com sucesso!");
                    }
                    else
                    {
                        alert("A obra não pode ser renovada!\\n" + query.Field(0, 0));
                    }
                }
            }
            catch (Exception ex)
            {
                alert(erro.Replace("#ERRO", "\\n" + ex.Message));
            }
        }

        this.loadPage();
    }
Ejemplo n.º 16
0
        public void loadSelect()
        {
            CDataBase db = new CDataBase();

            CQuery query = db.select(this._isql, this._fields);

            String temp = "";

            for (int i = 0; i < query.Count(); i++)
            {
                temp = "";

                for (int j = 0; j < query.Row(i).Count(); j++)
                {
                    if (j != this._ivalue || this._svalue)
                    {
                        temp += query.Field(i, j) + " - ";
                    }
                }

                this._values.Add(query.Field(i, this._ivalue));

                this._obj.Items.Add(new ListItem(temp.Substring(0, temp.Length - 3), query.Field(i, this._ivalue)));
            }

            if (this._insNull)
            {
                this._obj.Items.Insert(0, new ListItem("", ""));
            }
        }