Increase the size of a string

2

Is it 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 nrMesa to highlight the page. It is possible.

This is the datalist that is populated 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 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);
    }

}
    
asked by anonymous 27.08.2015 / 15:54

1 answer

4

As shown in the original response, assembling and displaying data are distinct things, you can not mix. So you need to change your page to treat the parts separately and you can not concatenate what is different.

Change this snippet 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 was just an example, I do not know how you want to highlight this and if you have this class in your CSS. I do not know if it's going to be exactly this because I do not know all your need and code, but it's more or less that.

I would also change this section:

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

And yet:

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

In fact this is so bad that I would completely rewrite it from scratch and do it in an organized way. Just because it works does not mean it's right.

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

You are mixing concepts. In your code you are manipulating data. In general this should be done in controller , as it seems you are doing.

If you need to have determined data displayed in a specific way on the page, this must be done in view . It's done with HTML and probably CSS.

To facilitate the work, the ideal is that the data that needs to be displayed in different ways is separate. If they are not, the code will have to separate them before using. What gives work and takes risks, besides being not the right thing to do. You should avoid processing the view .

Even though you have to put the display form in the controller , but the game is so big, it is so wrong to do this that I will not even teach. It will do more damage than help.

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

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

If you have other relevant code snippets, both in model , and controller and view , I try to give a more complete example of how it would look .

    
27.08.2015 / 16:09