middelpat
middelpat

Reputation: 2585

asp.net c# code not working properly on firefox, works fine on other browsers

I have written an application which is used to scan orders and change their statusses depending on their statusflow which is defined in the database for each product.

When I scan a chunk (part of an orderline) for example a cover of a book (chunk 1) and the content of a book (chunk 2). they are both in the same orderline, the orderline again is part of the order which can contain more orderlines.

an order can only be set to "shipped" when all the other orderlines have the status "shipping", an chunk can only be set to the next status when all the other chunks in the orderline have at least the same status, or higher.

example:

status flow = new, production, shipping, shipped

chunk1 status = new chunk 2 status = new

chunk1 scanned

chunk1 status = production chunk 2 status = new

chunk 1 scanned

"cannot be done, chunk2 has to have status production first"

chunk 2 scanned

chunk1 status = production chunk2 status = production

this all works fine in both IE and google chrome.

but when i execute this code in firefox it doesn't work the way i want it to. i don't get any exceptions or errors.

then it works like example:

status flow = new, production, shipping, shipped

chunk1 status = new chunk 2 status = new

chunk 1 scannend

chunk 1 status = production chunk 2 status = new

chunk 2 scanned

chunk 1 status = production chunk 2 status = shipping

now in firefox when a chunk is being scanned, it skips one step. it is like my code doesn't look for chunk 2 for the current chunk status when it is being scanned but for chunk1's status.

code:

protected void BarCodeTextBox_TextChanged(object sender, EventArgs e)
    {
        InfoPanel.Hide();

        if (BarCodeTextBox.Text.Length > 4 && validBarcodeInput)
        {
            if (BarCodeTextBox.Text == currBarcodeLabel.Text || BarCodeTextBox.Text == string.Format("B{0}", currBarcodeLabel.Text))
            {
                secondscanstring = "true";
                secondScan = true;
            }
            else
            {
                secondscanstring = "false";
                secondScan = false;
            }

            if (Chunk.OrderLine.Order.OrderId == int.Parse(currOrderIdLabel.Text))
            {
                secondscanstring = "true";
                secondScan = true;
            }

            BindData();                               

            UpdateStatus();                
        }
        else
        {
            BarCodeTextBox.Text = "";
            InfoPanel.ErrorMessage = "ongeldige barcode!";
            InfoPanel.ShowErrorMessage();
            return;
        }
    }


private void UpdateStatus()
    {            
        if (!StatusMessageChecked.Checked && StatusMessageChecked.Visible)
        {
            AgreeConfirmation.Visible = true;
            return;
        }

        IProductRepository prodRep = RepositoryFactory.CreateProductRepository();
        IOrderRepository orderRep = RepositoryFactory.CreateOrderRepository();

        OrderLineChunk chunk = orderRep.GetOrderLineChunkById(Barcode);

        if (chunk == null)
        {
            InfoPanel.ErrorMessage = "ongeldige barcode!";
            InfoPanel.ShowErrorMessage();
            return;
        }

        List<Status> statusFlowList = new List<Status>();

        string statusFlowString = prodRep.GetStatusFlowForProduct(chunk.OrderLine.Product.ProductId);

        string[] statusIdS = statusFlowString.Split(',');

        foreach (string statusId in statusIdS)
        {
            int id = int.Parse(statusId);

            Status status = orderRep.GetStatusById(id);

            statusFlowList.Add(status);
        }

        int currStatusId = chunk.Status.StatusId;

        int count = 0;
        int newIndex = 0;

        foreach (Status s in statusFlowList)
        { 
            if(s.StatusId == currStatusId)
            {
                if (count == statusFlowList.Count - 1)
                {
                    newIndex = count;
                }
                else
                {
                    newIndex = count + 1;
                }
                break;
            }
            count++;
        }

        if (newIndex > 0 && newIndex <= statusFlowList.Count - 1)
        {
            if (chunk.Status.Name == Status.InProduction.Name && chunk.OrderLine.Status.Name != Status.InProduction.Name)
            {
                InfoPanel.ErrorMessage = string.Format("kan de status niet veranderen omdat nog niet alle chunks in deze order de status '<b>{0}</b>' hebben", Status.InProduction.Description.ToLower());
                InfoPanel.ShowErrorMessage();
                return;
            }
            else if (chunk.Status.Name == Status.Binding.Name && chunk.OrderLine.Status.Name != Status.Binding.Name)
            {
                InfoPanel.ErrorMessage = string.Format("kan de status niet veranderen omdat nog niet alle chunks in deze order de status '<b>{0}</b>' hebben", Status.Binding.Description.ToLower());
                InfoPanel.ShowErrorMessage();
                return;
            }
            else if (chunk.Status.Name == Status.Shipping.Name && chunk.OrderLine.Status.Name != Status.Shipping.Name)
            {
                InfoPanel.ErrorMessage = string.Format("kan de status niet veranderen omdat nog niet alle chunks in deze order de status '<b>{0}</b>' hebben", Status.Shipping.Description.ToLower());
                InfoPanel.ShowErrorMessage();
                return;
            }
            else if (chunk.Status.Name == Status.Glue.Name && chunk.OrderLine.Status.Name != Status.Glue.Name)
            {
                InfoPanel.ErrorMessage = string.Format("kan de status niet veranderen omdat nog niet alle chunks in deze order de status '<b>{0}</b>' hebben", Status.Glue.Description.ToLower());
                InfoPanel.ShowErrorMessage();
                return;
            }
            else
            {
                if (secondScan || chunk.OrderLine.Order.Status.Name == Status.Shipping.Name)
                {
                    Status newStatus = statusFlowList[newIndex];

                    if (chunk.OrderLine.Order.Status == Status.Shipping)
                    {
                        chunk.OrderLine.Order.ChangeStatusTo(Status.Shipped);

                        sendShippedMail();
                    }
                    else
                    {
                        chunk.ChangeStatusTo(newStatus, Status.Action.UpdateParent);
                    }
                }
            }                
        }
        else
        {
            InfoPanel.ErrorMessage = string.Format("Er is een fout opgetreden!");
            InfoPanel.ShowErrorMessage();
        }

        BindData();

        currBarcodeLabel.Text = Barcode.ToString();
        currOrderIdLabel.Text = Order.OrderId.ToString();
        secondScanLabel.Text = secondscanstring;
        BarCodeTextBox.Text = String.Format("B{0}", Barcode);
    }

    protected void CancelButton_Click(object sender, ImageClickEventArgs e)
    {
        IOrderRepository repository = RepositoryFactory.CreateOrderRepository();

        if (Order != null)
        {
            OrderLineChunk chunk = repository.GetOrderLineChunkById(Barcode);

            chunk.Status = Status.Canceled;
            repository.UpdateOrderLineChunk(chunk);

            BindData();
        }
    }


private void BindData()
    {
        PrintPakbonLink.Visible = false;           

        if (Order != null)
        {
            if (StatusMessageChecked.Checked)
            {
                AgreeConfirmation.Visible = false;
            }
            OrderInfoPanel.Visible = true;
            OrderIdLink.Text = string.Format("<b>{0}</b>", Order.OrderId);
            OrderIdLink.NavigateUrl = string.Format("OrderDetails.aspx?OrderId={0}", Order.OrderId);

            OrderDateLabel.Text = Order.Date.ToString();

            SubShopLabel.Text = string.Format("Subshop: <span class='orange'>{0}", Order.Customer.SubShop.Name);
            CustomerLabel.Text = string.Format("Klant: <span class='orange'>{0} ({1})</span>", Order.Customer.FullName, Order.Customer.UserId);

            if (Order.ShippingAddress != null)
            {
                BindShippingAddress(Order.ShippingAddress);
            }

            if (Order.BillingAddress != null)
            {
                BindBillingAddress(Order.BillingAddress);
            }
            else
            {
                BindBillingAddress(Order.ShippingAddress);
            }

            if (Order.Status.StepPosition >= Status.Shipping.StepPosition)
            {
                PrintPakbonLink.NavigateUrl = string.Format("Reports.aspx?ReportType={0}&OrderId={1}", (int)Reports.ReportType.Pakbon, Order.OrderId);
                PrintPakbonLink.Visible = true;
            }

            if (Order.StatusHistory.Where(s => !string.IsNullOrEmpty(s.Message)).Any())
            {
                StringBuilder message = new StringBuilder();

                var messages = from s in Order.StatusHistory
                               where !string.IsNullOrEmpty(s.Message)
                               orderby s.Date descending
                               select s;

                foreach (var m in messages)
                {
                    if (message.Length == 0)
                    {
                        message.AppendLine("Status meldingen voor deze order<br/><br/>");
                        StatusMessageChecked.Visible = true;
                    }

                    message.AppendLine(string.Format("<FONT COLOR=\"#FF0000\">(<small><b>{0}</b></small>) {1}</FONT><br/>", m.Date, m.Message));
                }

                StatusMessageHistoryLabel.Text = message.ToString();
            }
            else
            {
                StatusMessageHistoryLabel.Text = string.Empty;
            }
        }
        else
        {
            OrderInfoPanel.Visible = false;
            SubShopLabel.Text = "";
            CustomerLabel.Text = "";

            BindShippingAddress(new Address());
            BindBillingAddress(new Address());
        }

        ChunkGrid.DataBind();
        ChunkGrid.HighlightRow(Barcode);
    }

my aspx code

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div style="clear: both;">
        <aq:InfoPanel runat="server" ID="InfoPanel" />
    </div>
    <div id="barCodeScannerContentBig">
        <div id="orderDetails">
            <div id="orderDetailsBlock">
                <span class="barCodeHeader">Toegekende barcode</span><br />
                <br />
                <asp:TextBox ID="BarCodeTextBox" runat="server" OnTextChanged="BarCodeTextBox_TextChanged"
                    TabIndex="0" AutoPostBack="true" />
                <br />
                <asp:RequiredFieldValidator ID="requiredfieldvalidator2" runat="server" SkinID="FieldValidator"
                    ControlToValidate="BarCodeTextBox" ErrorMessage="Barcode is verplicht" />
                <br />
                <br />                
                <asp:Label ID="secondScanLabel" runat="server" Text="Huidige barcode: " />
                <asp:Label ID="currBarcodeLabel" runat="server" /><br />
                order: <asp:Label ID="currOrderIdLabel" runat="server" />
                <br />
                <br />

            </div>
            <div id="orderDetailsBlockBordBarCodeTextBoxerLeft">
                <span class="barCodeHeader">Gescande artikel</span><br />
                <br />
                Informatie over het gescande artikel.
                <br />
                <br />
                <asp:Panel runat="server" ID="OrderInfoPanel" Visible="false">
                    Order
                    <asp:HyperLink runat="server" ID="OrderIdLink" CssClass="orange" Text="" NavigateUrl="~/OrderDetails.aspx?OrderId=" />
                    van
                    <asp:Label runat="server" ID="OrderDateLabel" />
                </asp:Panel>
                <br />
                <asp:Label runat="server" ID="SubShopLabel" Text="" />
                <br />
                <asp:Label runat="server" ID="CustomerLabel" Text="" />
                <br />
            </div>
        </div>
    </div>
    <br />
    <div style="clear: both; width: 668px">
        <div style="width: 150px; float: left">
            <asp:ImageButton runat="server" ID="GoToDashBoardImageButton" ImageUrl="~/App_Themes/Default/button_naar_dashboard.PNG"
                PostBackUrl="~/Default.aspx" Style="margin: 10px 0px 0px 0px;" CssClass="btnLeft"
                CausesValidation="false" />
        </div>
        <div style="width: 318px; float: left; padding:10px 10px 0px 10px; text-align: center;">
        <asp:Panel ID="AgreeConfirmation" runat="server" Visible="false" CssClass="errorInfoPanel">
                    Niet akkoord gegaan met de foutmelding!</asp:Panel>
            <asp:Panel runat="server" ID="StatusMessagePanel">
                <asp:Label runat="server" ID="StatusMessageHistoryLabel"></asp:Label>
            </asp:Panel>
        <asp:CheckBox ID="StatusMessageChecked" runat="server" Text=" Akkoord" Visible="false" />
        </div>
        <div style="width: 100px; float: left">
            <asp:HyperLink runat="server" ID="PrintPakbonLink" Target="_blank" CssClass="btnRight"
                Style="margin: 10px 5px 20px 0px;">
        <asp:Image runat="server" ImageUrl="~/App_Themes/Default/button_print_pakbon.PNG" AlternateText="Pakbon afdrukken" />

            </asp:HyperLink>
        </div>
        <div style="width: 80px; float: right">
            <asp:ImageButton runat="server" ID="AgreeButton" ImageUrl="~/App_Themes/Default/button_akkoord.png"
                CssClass="btnRight" Style="margin: 10px 0px 0px 0px;" OnClick="AgreeButton_Click"/>                     
        </div>
    </div>
    <%--<asp:ImageButton runat="server" ID="PrintEtiketImageButton" ImageUrl="#" AlternateText="Print etiket"
        CssClass="btnRight" Style="padding: 5px 0px 0px 0px;" OnClick="PrintEtiketImageButton_Click" />--%>
    <div id="detailedOrderInformation">
        <br />
        <br />
        <br />
        <span class="barCodeHeader">Gedetailleerde order informatie</span>
        <br />
        <br />
        <asp:UpdatePanel runat="server" ID="OrdersUpdatePanel">
            <ContentTemplate>
                <aq:ChunkGrid runat="server" ID="ChunkGrid" ObjectDataSourceId="OrderLineChunksDataSource" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <div class="adressHeader">
    </div>
    <div class="orderBlockLeft">
        <table class="OrderDetailTable">
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Naam
                </td>
                <td>
                    <asp:Label runat="server" ID="ShippingAddressNameLine1Label" />
                </td>
            </tr>
            <tr>
                <td colspan="2" class="buffer">
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Adres
                </td>
                <td>
                    <asp:Label runat="server" ID="ShippingAddressAddressLine1Label" />
                </td>
            </tr>
            <tr>
                <td colspan="2" class="buffer">
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Plaats
                </td>
                <td>
                    <asp:Label runat="server" ID="ShippingAddressCityLabel" />
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Postcode
                </td>
                <td>
                    <asp:Label runat="server" ID="ShippingAddressPostalCodeLabel" />
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Land
                </td>
                <td>
                    <asp:Label runat="server" ID="ShippingAddressCountryLabel" Width="146" />
                </td>
            </tr>
        </table>
    </div>
    <div class="orderBlockRight" style="width: 320px">
        <table class="OrderDetailTable">
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Naam
                </td>
                <td>
                    <asp:Label runat="server" ID="BillingAddressNameLine1Label" />
                </td>
            </tr>
            <tr>
                <td colspan="2" class="buffer">
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Adres
                </td>
                <td>
                    <asp:Label runat="server" ID="BillingAddressAddressLine1Label" />
                </td>
            </tr>
            <tr>
                <td colspan="2" class="buffer">
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Plaats
                </td>
                <td>
                    <asp:Label runat="server" ID="BillingAddressCityLabel" />
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Postcode
                </td>
                <td>
                    <asp:Label runat="server" ID="BillingAddressPostalCodeLabel" />
                </td>
            </tr>
            <tr>
                <td class="tableLabel" valign="top" width="120">
                    Land
                </td>
                <td>
                    <asp:Label runat="server" ID="BillingAddressCountryLabel" Width="146" />
                </td>
            </tr>
        </table>
        <br />
        <br />
        <%-- <asp:ImageButton runat="server" ID="profileCustomer" ImageUrl="~/App_Themes/Default/button_profile.PNG"
                    CssClass="btnRight" />--%>
    </div>
    <div style="clear: both">
        &nbsp;<br />
    </div>
    <asp:ObjectDataSource ID="OrderLineChunksDataSource" runat="server" TypeName="ChrisRussell.Data.Repository.Interfaces.IOrderRepository"
        DataObjectTypeName="ChrisRussell.Data.Order" SelectMethod="GetAllOrderLineChunksForOrder"
        OnObjectCreating="OrderLineDataSource_ObjectCreating" OnObjectDisposing="DataSource_ObjectDisposing"
        OnSelecting="OrderLineChunksDataSource_Selecting"></asp:ObjectDataSource>
    <div style="clear: both">
        &nbsp;<br />
        <br />
    </div>
</asp:Content>

|||||||||||||||||||||||||||||||||ANSWERED|||||||||||||||||||||||||||||||||||||

I fixed my own problem Hogan gave me a huge push in te good direction. My fault had to be in aspx code as he said. so i explored every bit of my C# calculation. in an aspx textfield i showed the old orderid which i used in my calculation later.

now I store that value also in a string so it is browser independent.

Upvotes: 2

Views: 2319

Answers (1)

Hogan
Hogan

Reputation: 70513

It all seems very complex, but you say the problem changes by browser so the issue must be with the HTML. I only see one HTML problem in the code you posted so try fixing that:

Change

"Subshop: <span class='orange'>{0}"

To

"Subshop: <span class='orange'>{0}</span>"

If that does not fix the problem then you will have to show us the apsx page because you must have a typo somewhere in you HTML to cause different browsers to act differently.

(NB - I know it could be the request or the response, but that would be rare since there are many ways the apsx file could cause this problem.)

Upvotes: 3

Related Questions