asp.net c#代码在firefox上运行不正常,在其他浏览器上运行正常

时间:2011-08-30 09:55:20

标签: c# asp.net firefox google-chrome

我编写了一个应用程序,用于扫描订单并根据每个产品在数据库中定义的状态流来更改状态。

当我扫描一个块(一个订单行的一部分)时,例如一本书的封面(块1)和一本书的内容(块2)。它们都在同一个订单行中,订单行也是订单的一部分,可以包含更多的订单。

当所有其他订单行的状态为“送货”时,订单只能设置为“已发货”,当订单行中的所有其他块至少具有相同的状态时,只能将块设置为下一个状态,或更高。

示例:

状态流程=新的,生产,运输,发货

chunk1 status = new chunk 2 status = new

chunk1扫描

chunk1 status = production chunk 2 status = new

块1已扫描

“无法完成,chunk2必须先拥有状态生成”

块2扫描

chunk1 status = production chunk2 status = production

这一切都适用于IE和谷歌浏览器。

但是当我在firefox中执行此代码时,它不能按照我想要的方式工作。我没有任何例外或错误。

然后就像例子一样:

状态流程=新的,生产,运输,发货

chunk1 status = new chunk 2 status = new

chunk 1 scannend

块1状态=生产 chunk 2 status = new

块2扫描

块1状态=生产 块2状态=运输

现在在firefox中扫描一个块时,它会跳过一步。就像我的代码在扫描当前的块状态时不会查找块2,而是查找chunk1的状态。

代码:

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);
    }

我的aspx代码

<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 ||||||||||||| ||||||||||||||||||||||||

我解决了自己的问题霍根给了我一个很好的方向。他说,我的错必须是aspx代码。所以我探索了C#计算的每一点。在一个aspx文本字段中,我展示了我之后在计算中使用的旧orderid。

现在我将该值也存储在字符串中,因此它与浏览器无关。

1 个答案:

答案 0 :(得分:3)

这一切看起来都非常复杂,但是你说问题会因浏览器而改变,所以问题必须与HTML有关。我只在您发布的代码中看到一个HTML问题,因此请尝试修复:

更改

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

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

如果这不能解决问题,那么您必须向我们展示apsx页面,因为您必须在HTML中的某个地方输入拼写错误,以使不同的浏览器采取不同的行动。

(注意 - 我知道它可能是请求或响应,但这很少见,因为apsx文件有很多方法可能导致此问题。)