Increasing the size of a string

Asked

Viewed 301 times

1

It is possible to increase the size of a string in the code?

string sIdentComanda = "";
        if (objComandaParametro.ComandaParametros[0].IsControlaNrComanda)
        {
            sIdentComanda += " Comanda: " + nrComanda;
        }
        if (objComandaParametro.ComandaParametros[0].IsUtilizaNrMesa)
        { 
            sIdentComanda += " Mesa: " + nrMesa ;
        }

I need to increase the nrMesa to highlight the page. It is possible.

This is the datalist which is completed to be displayed on the screen.

<asp:UpdatePanel ID="upListaVendas" runat="server" class="row">
        <ContentTemplate>
            <asp:DataList ID="DataList1" runat="server" DataKeyField="IdItem" DataSourceID="sdsItensPendentes"
                OnSelectedIndexChanged="DataList1_SelectedIndexChanged" OnItemDataBound="DataList1_ItemDataBound"
                CellPadding="0" RepeatLayout="Flow" RepeatDirection="Horizontal" 
                GridLines="None">
                <ItemTemplate>
                    <div class="col-lg-3 col-sm-6 col-nested">
                        <asp:LinkButton ID="btnFinalizaPreparo" runat="server" CommandName="select" CssClass="text-uppercase rounded-box">
                            <span class="clearfix">
                                <span class="pull-left text-success"><strong>Qtde.:</strong> {0}</span>
                                <span class="pull-right">{1}</span>
                                <span class="pull-right">{2}</span></br></br>
                            </span>
                            <hr />
                            <span class="clearfix text-justify">
                                <strong>Item:</strong>
                                {3} - {4} 
                            </span>
                            <hr />
                            <span class="clearfix text-justify">
                                {5}
                            </span>
                        </asp:LinkButton>
                    </div>  
                </ItemTemplate>   
            </asp:DataList>

And this is the way that the datalist is loaded.

protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{

    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.SelectedItem)
    {
        LinkButton btnFinalizaPreparo = (LinkButton)e.Item.FindControl("btnFinalizaPreparo");
        DataRowView drv = (DataRowView)e.Item.DataItem;
        string qtde = Convert.ToString(drv.Row["Qtde"]);
        string nrMesa = String.IsNullOrEmpty(Convert.ToString(drv.Row["NrMesa"])) ? "--" : Convert.ToString(drv.Row["NrMesa"]);
        string nrComanda = String.IsNullOrEmpty(Convert.ToString(drv.Row["NrComanda"])) ? "--" : Convert.ToString(drv.Row["NrComanda"]);
        string Apelido = String.IsNullOrEmpty(Convert.ToString(drv.Row["Apelido"])) ? "--" : Convert.ToString(drv.Row["Apelido"]);
        string dtSolicitacao =  String.IsNullOrEmpty(Convert.ToString(drv.Row["dtSolicitacao"])) ? "--" : Convert.ToString(drv.Row["dtSolicitacao"]);
        string idProduto = Convert.ToString(drv.Row["IdProduto"]);
        string nomeProduto = Convert.ToString(drv.Row["NomeProduto"]);
        string complemento = Convert.ToString(drv.Row["Complemento"]);

        string sIdentComanda = "";
        if (objComandaParametro.ComandaParametros[0].IsControlaNrComanda)
        {
            sIdentComanda += " Comanda: " + nrComanda;
        }
        if (objComandaParametro.ComandaParametros[0].IsUtilizaNrMesa)
        { 
            sIdentComanda += " Mesa: " + nrMesa ;
        }
        string IdentNomeHorario = "";
        IdentNomeHorario += "Nome: " + Apelido;
        if (dtSolicitacao != "--")
            IdentNomeHorario += " " + String.Format("{0:HH:MM:ss}", DateTime.Parse(dtSolicitacao));

        btnFinalizaPreparo.Text = String.Format(btnFinalizaPreparo.Text, qtde, sIdentComanda , IdentNomeHorario, idProduto, nomeProduto, complemento);
    }

}
  • 4

    you want to increase the font size? or you want to concatenate a string with another?

  • Increase and then concatenate.

  • This is in the controller or in the view? And as it increases for you is the font size, your answer is ambiguous.

  • In the aspx.Cs file

  • The question is unclear and ambiguous, not to mention the mistakes of Portuguese.

1 answer

4


As shown in the original answer, mounting and displaying data are separate things, you can’t mix. Then you need to change your page to treat the parts separately and can not concatenate what is different.

Change this section to something like this:

<span class="pull-left text-success"><strong>Qtde.:</strong> {0}</span>
<span class="pull-right">{1}</span></br></br>
<span class="pull-right"><strong>Mesa:</strong></span><span class="pull-higlight">{2}</span>
<span class="pull-right">{3}</span></br></br>

The pull-higlight It was just an example, I don’t know how you want to highlight this and if you have this class in your CSS. I don’t know if this is exactly it because I don’t know all your need and your code, but that’s about it.

I would also change this passage:

var sIdentMesa = "";
if (objComandaParametro.ComandaParametros[0].IsUtilizaNrMesa) { 
    sIdentMesa = nrMesa;
}

And yet:

btnFinalizaPreparo.Text = String.Format(btnFinalizaPreparo.Text, qtde, sIdentComanda, sIdentMesa, IdentNomeHorario, idProduto, nomeProduto, complemento);

I put in the Github for future reference.

Actually this is so bad that I would rewrite completely from scratch and do it in an organized way. Just because it works doesn’t mean it’s right.


The question has completely changed, nor is it from the technology initially presented, Here is the original.

You are mixing concepts. In your code you are manipulating data. In general this should be done at controller, how it looks like you’re doing.

If you need to have data displayed in a specific way on the page, this should be done on view. It is done with an HTML and probably CSS.

To facilitate work the ideal is that the data that needs to be displayed in different ways be separated. If they are not, the code will have to separate them before using. Which is work and risks, and is not the right thing to do. Processing in the view.

There’s even a way to put the display on controller, but the gambiarra is so big, it’s so wrong to do it that I won’t even teach. Will cause more damage than help.

So the solution is not to concatenate what you want. You have to have the text " Table: " and the table number separate.

But to tell the truth, something tells me that this text " Mesa: "and other texts, like " Comanda: ", for example, should not even be in controller, This seems to be part of view.

If you have other relevant parts of the codes, either model, as controller and view, I try to give a more complete example how it would look.

  • +1 for the lesson and willingness to help the person not only with the problem he knows he has, but with those he doesn’t even realize he has

  • Bigown, thank you for helping, I will change the way this programmed and put the code snippets in their place.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.