コード例 #1
0
    protected void gvASN_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            if (e.CommandName == "ViewDetails")
            {
                ImageButton lb          = (ImageButton)e.CommandSource;
                GridViewRow gvr         = (GridViewRow)lb.NamingContainer;
                GridView    gridview    = gvr.NamingContainer as GridView;
                int         index       = Convert.ToInt32(e.CommandArgument);
                GridViewRow selectedRow = gridview.Rows[index - (gridview.PageIndex * gridview.PageSize)];
                Label       lblSNo      = (Label)selectedRow.FindControl("lblSNo");
                GenericCollection <ASNHeaderBE> listOfBE = (GenericCollection <ASNHeaderBE>)Session[vASNList];
                GenericCollection <ASNLinesBE>  lines    = new GenericCollection <ASNLinesBE>();
                ASNHeaderBE Headerobj = new ASNHeaderBE();

                foreach (ASNHeaderBE obj in listOfBE)
                {
                    if (obj.SNo.ToString() == lblSNo.Text)
                    {
                        Headerobj = obj;
                        break;
                    }
                }

                lines = Headerobj.ASNLines;
                trPODetails.Visible          = false;
                Session["ASNLineCollection"] = lines;
                databind();
            }
            if (e.CommandName == "ViewFiles")
            {
                ImageButton lb          = (ImageButton)e.CommandSource;
                GridViewRow gvr         = (GridViewRow)lb.NamingContainer;
                GridView    gridview    = gvr.NamingContainer as GridView;
                int         index       = Convert.ToInt32(e.CommandArgument);
                GridViewRow selectedRow = gridview.Rows[index - (gridview.PageIndex * gridview.PageSize)];

                Label lblSNo = (Label)selectedRow.FindControl("lblSNo");
                GenericCollection <ASNHeaderBE> listOfBE = (GenericCollection <ASNHeaderBE>)Session[vASNList];
                ASNHeaderBE Headerobj = new ASNHeaderBE();

                foreach (ASNHeaderBE obj in listOfBE)
                {
                    if (obj.SNo.ToString() == lblSNo.Text)
                    {
                        Headerobj = obj;
                        break;
                    }
                }

                Session["ArchiveFiles"] = Headerobj;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowNewPage();", true);
            }
        }
        catch (Exception ex)
        {
        }
    }
コード例 #2
0
    private GenericCollection <ASNHeaderBE> PrepareASNList(GenericCollection <ASNHeaderBE> listOfBE)
    {
        TransactionBC   objTranBC = new TransactionBC();
        PurchaseOrderBC objBC     = new PurchaseOrderBC();
        GenericCollection <ASNHeaderBE> ASNList = new GenericCollection <ASNHeaderBE>();

        for (int i = 0; i < listOfBE.Count; i++)
        {
            ASNHeaderBE objBE = new ASNHeaderBE();
            objBE.SNo     = i;
            objBE.TxnType = "3B2";
            objBE.TxnDate = listOfBE[i].TxnDate;
            //string File = listOfBE[0].ArchiveFile;
            XmlDocument ASNFile = new XmlDocument();
            //ASNFile.Load(@"D:\BPM\SampleFiles\ASNEGLFiles.xml");
            ASNFile.Load(listOfBE[i].ArchiveFile);
            objBE.ArchiveFile = listOfBE[i].ArchiveFile;
            XmlNamespaceManager namespaceManager = new XmlNamespaceManager(ASNFile.NameTable);
            namespaceManager.AddNamespace("ns0", "http://MS.IT.Ops.HED.ShowShipment_V02_00_00");

            XmlNode xPartnerNode = ASNFile.SelectSingleNode("ns0:ShowShipment_V02_00_00/ApplicationArea/Sender/ns0:LogicalId", namespaceManager);
            objBE.CM = xPartnerNode == null ? "" : objBC.GetPartnerName(xPartnerNode.InnerText);
            objBE.CM = objBE.CM == "" ? xPartnerNode.InnerText : objBE.CM;

            XmlNode xASTransactionID = ASNFile.SelectSingleNode("ns0:ShowShipment_V02_00_00/ApplicationArea/ns0:ReferenceId", namespaceManager);
            objBE.ASFeedTxnID = xASTransactionID == null ? "" : xASTransactionID.InnerText;

            XmlNode xReceiverKey = ASNFile.SelectSingleNode("ns0:ShowShipment_V02_00_00/routing/ReceiverKey", namespaceManager);
            objBE.ReceiverKey = xReceiverKey == null ? "" : xReceiverKey.InnerText;

            XmlNode xShipDate = ASNFile.SelectSingleNode("ns0:ShowShipment_V02_00_00/DataArea/Shipment/Header/TransportationEvent/ns0:DateTime", namespaceManager);
            if (xShipDate != null)
            {
                try
                {
                    objBE.ShipDate = Convert.ToDateTime(xShipDate.InnerText.Substring(0, 4) + "-" + xShipDate.InnerText.Substring(4, 2) + "-" + xShipDate.InnerText.Substring(6, 2));
                }
                catch (Exception ex)
                {
                }
            }

            XmlNodeList PartiesNodeList        = ASNFile.SelectNodes("ns0:ShowShipment_V02_00_00/DataArea/Shipment/Header/Parties", namespaceManager);
            XmlNodeList TrackingReferenceNodes = ASNFile.SelectNodes("ns0:ShowShipment_V02_00_00/DataArea/Shipment/Header/TrackingReference", namespaceManager);
            XmlNodeList LineItemNodes          = ASNFile.SelectNodes("ns0:ShowShipment_V02_00_00/DataArea/Shipment/LineItem", namespaceManager);

            if (LineItemNodes != null)
            {
                objBE.LineCount = LineItemNodes.Count;
            }


            foreach (XmlNode xnd in PartiesNodeList)
            {
                if (xnd.SelectSingleNode("ns0:PartyTypeCode", namespaceManager).InnerText == "Originating Party")
                {
                    XmlNode xCMNode = xnd.SelectSingleNode("ns0:PartyIdentifier", namespaceManager);
                    objBE.OriginationParty = xCMNode == null ? "" : objBC.GetPartnerName(xCMNode.InnerText);
                    objBE.OriginationParty = objBE.OriginationParty == "" ? xCMNode.InnerText : objBE.OriginationParty;
                }
                if (xnd.SelectSingleNode("ns0:PartyTypeCode", namespaceManager).InnerText == "Selling Partner")
                {
                    XmlNode xCMNode = xnd.SelectSingleNode("ns0:PartyIdentifier", namespaceManager);
                    objBE.SellingPartner = xCMNode == null ? "" : objBC.GetPartnerName(xCMNode.InnerText);
                    objBE.SellingPartner = objBE.SellingPartner == "" ? xCMNode.InnerText : objBE.SellingPartner;
                }
                if (xnd.SelectSingleNode("ns0:PartyTypeCode", namespaceManager).InnerText == "Ship To")
                {
                    XmlNode xCMNode = xnd.SelectSingleNode("ns0:PartyIdentifier", namespaceManager);
                    objBE.SAPShipTo = xCMNode == null ? "" : objBC.GetPartnerName(xCMNode.InnerText);
                    objBE.SAPShipTo = objBE.SAPShipTo == "" ? xCMNode.InnerText : objBE.SAPShipTo;
                }

                if (xnd.SelectSingleNode("ns0:PartyTypeCode", namespaceManager).InnerText == "Freight Forwarder")
                {
                    XmlNode xCMNode = xnd.SelectSingleNode("ns0:PartyIdentifier", namespaceManager);
                    objBE.FMV = xCMNode == null ? "" : objBC.GetPartnerName(xCMNode.InnerText);
                    objBE.FMV = objBE.FMV == "" ? xCMNode.InnerText : objBE.FMV;
                }
            }
            foreach (XmlNode xnd in TrackingReferenceNodes)
            {
                if (xnd.SelectSingleNode("ns0:TrackingCode", namespaceManager).InnerText == "Load Identifier")
                {
                    XmlNode xCMNode = xnd.SelectSingleNode("ns0:TrackingId", namespaceManager);
                    objBE.LoadID = xCMNode == null ? "" : xCMNode.InnerText.Substring(0, xCMNode.InnerText.Length - 2);
                }
            }
            GenericCollection <ASNLinesBE> objLinesList = new GenericCollection <ASNLinesBE>();
            int j = 0;
            foreach (XmlNode xnd in LineItemNodes)
            {
                ASNLinesBE  objLineBE       = new ASNLinesBE();
                XmlNodeList LineDocRefNodes = ASNFile.SelectNodes("/ns0:ShowShipment_V02_00_00/DataArea/Shipment/LineItem/DocumentReference", namespaceManager);
                foreach (XmlNode xndDoc in LineDocRefNodes)
                {
                    if (xndDoc.SelectSingleNode("ns0:DocumentTypeCode", namespaceManager).InnerText == "Packing Slip Number")
                    {
                        XmlNode xCMNode = xndDoc.SelectSingleNode("ns0:Id", namespaceManager);
                        objLineBE.PackSlipNumber = xPartnerNode == null ? "" : xCMNode.InnerText;
                    }
                    if (xndDoc.SelectSingleNode("ns0:DocumentTypeCode", namespaceManager).InnerText == "Purchase Order")
                    {
                        XmlNode xCMNode = xndDoc.SelectSingleNode("ns0:Id", namespaceManager);
                        objLineBE.PONumber = xPartnerNode == null ? "" : xCMNode.InnerText;
                        XmlNode xLineNumber = xndDoc.SelectSingleNode("ns0:LineNumber", namespaceManager);
                        objLineBE.LineNumber = xLineNumber == null ? "" : xLineNumber.InnerText;
                    }
                }
                XmlNode xSKUNode = xnd.SelectSingleNode("OrderItem/ns0:ProductIdentifier", namespaceManager);
                objLineBE.SKU = xSKUNode == null ? "" : xSKUNode.InnerText;
                XmlNode xUnitsShippedNode = xnd.SelectSingleNode("ns0:UnitsShipped", namespaceManager);
                objLineBE.ItemQuantity = xUnitsShippedNode == null ? "" : xUnitsShippedNode.InnerText;
                objLinesList.Add(j, objLineBE);
                j++;
            }
            objBE.ASNLines = objLinesList;
            if (objBE.LineCount == 1 && objLinesList != null)
            {
                objBE.PONumber = objLinesList[0].PONumber;
            }
            else
            {
                objBE.PONumber = "See Details";
            }
            ASNList.Add(i, objBE);
        }
        return(ASNList);
    }