protected void gvDO_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        try
        {
            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");
                Label lblTransactionID = (Label)selectedRow.FindControl("lblTransactionID");
                Label lblDONumber      = (Label)selectedRow.FindControl("lblDONumber");
                GenericCollection <ShowShipmentBE> listOfBE = (GenericCollection <ShowShipmentBE>)Session[vSSList];
                ShowShipmentBE Headerobj = new ShowShipmentBE();

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

                TransactionBC objBC = new TransactionBC();
                GenericCollection <ShowShipmentBE> ArchiveObjects = new GenericCollection <ShowShipmentBE>();
                ArchiveObjects              = objBC.GetShowShipment945Details("Files", lblTransactionID.Text, lblDONumber.Text, "", "", "", "", "", "", null, null);
                Headerobj.AckAperakStatus   = ArchiveObjects[0].AckAperakStatus;
                Headerobj.AckArchiveFile    = ArchiveObjects[0].AckArchiveFile;
                Headerobj.DesAdvArchiveFile = ArchiveObjects[0].DesAdvArchiveFile;
                Headerobj.EDIXMLArchiveFile = ArchiveObjects[0].EDIXMLArchiveFile;
                Session["ArchiveFiles"]     = Headerobj;
                Page.ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowNewPage();", true);
            }
            if (e.CommandName == "ViewError")
            {
                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 lblTransactioID = (Label)selectedRow.FindControl("lblTransactionID");
                Label lblDONumber     = (Label)selectedRow.FindControl("lblDONumber");

                PurchaseOrderBC objBC        = new PurchaseOrderBC();
                string          Error        = objBC.LoadPOErrorMessage(lblTransactioID.Text, lb.ID == "imgStatus" ? "Extranet" : "Corpnet");
                string          PoNumber     = " Transaction ID : " + lblTransactioID.Text + " \\n Delivery Order : " + lblDONumber.Text + " \\n Error Details : \\n ";
                string          errormessage = "Error Number : " + Error.Split(',')[0] + " \\n Error Description : \\n " + Error.Split(',')[1];
                //Label LabelTxnType = (Label)selectedRow.FindControl("LabelTxnType");
                string Eror = "My Error";
                //ClientScript.RegisterStartupScript(this.GetType(), "CallMyFunction", "ShowMessage();", true);
                ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Registering", "$(document).ready(function(){ ShowMessage('" + lblTransactioID.Text + "','" + lblDONumber.Text + "','" + Error.Split(',')[0] + "','" + Error.Split(',')[1] + "'); });", true);
            }
        }
        catch (Exception ex)
        {
        }
    }
    private void BindShowShipment()
    {
        TransactionBC   objBC    = new TransactionBC();
        PurchaseOrderBC objPucBC = new PurchaseOrderBC();

        try
        {
            DateTime?DateFrom = txtDateFrom.Text == "" ? Convert.ToDateTime("1/1/1990") : Convert.ToDateTime(txtDateFrom.Text);
            DateTime?DateTo   = txtDateTo.Text == "" ? Convert.ToDateTime("12/31/2050") : Convert.ToDateTime(txtDateTo.Text);

            TimeSpan?duration = null;

            // Assign values to a and b...

            if (DateFrom.HasValue && DateTo.HasValue)
            {
                duration = DateTo.Value - DateFrom.Value;
            }

            double days = duration.GetValueOrDefault().TotalDays;

            if (days > 2 && txtDO.Text.Trim() == "")
            {
                lblSearchError.Text    = "Please select 2 Days difference between dates due to high volume of data or Provide DO Number to Search";
                lblSearchError.Visible = true;
                return;
            }

            GenericCollection <ShowShipmentBE> listOfBE = objBC.GetShowShipment945Details("Get", TxtIDOC.Text.Trim(), txtDO.Text.Trim(), txtLoadID.Text.Trim(), drdStatus.SelectedValue, drdTxnType.SelectedValue, drdServiceComponentPartnerSearch.SelectedValue, txtPlant.Text.Trim(), txtOrderType.Text.Trim(), DateFrom, DateTo);

            foreach (ShowShipmentBE objExt1 in listOfBE)
            {
                if (objExt1.StageName == "SentPositive997ToPartner")
                {
                    objExt1.Ack997Status = "pos997";
                }
                if (objExt1.StageName == "SentNegative997ToPartner")
                {
                    objExt1.Ack997Status = "neg997";
                }
                if (objExt1.StageName == "SentPositiveEDI824ToPartner")
                {
                    objExt1.Ack824Status = "pos824";
                }
                if (objExt1.StageName == "SentNegativeEDI824ToPartner")
                {
                    objExt1.Ack824Status = "Neg824";
                }
                if (objExt1.StageName == "SendPositiveEDI824for945ToBatchPrimaryTransport")
                {
                    objExt1.Ack824Status = "Pos824Batch";
                }
                if (objExt1.StageName == "SendNegativeEDI824for945ToBatchPrimaryTransport")
                {
                    objExt1.Ack824Status = "Neg824Batch";
                }
                if (objExt1.StageName == "SendNegativeEDI824for945ToBatchSecondaryTransport")
                {
                    objExt1.Ack824Status = "Neg824Batch";
                }
                if (objExt1.StageName == "SendPositiveEDI824for945ToBatchSecondaryTransport")
                {
                    objExt1.Ack824Status = "Pos824Batch";
                }
                if (objExt1.StageName == "AperakAckSentToPartner")
                {
                    objExt1.AckAperakStatus = "posAperak";
                }
                if (objExt1.StageName == "AperakNAckSentToPartner")
                {
                    objExt1.AckAperakStatus = "negAperak";
                }
                if (objExt1.MDNStatus == "RcvdPositiveMDNFromPartner")
                {
                    objExt1.MDNStatus = "PosMDN";
                }
                if (objExt1.MDNStatus == "Error_RcvdNegativeMDNFromPartnerEx")
                {
                    objExt1.MDNStatus = "NegMDN";
                }
                if (objExt1.MDNStatus == "Error_MDNNotReceivedFromPartner")
                {
                    objExt1.MDNStatus = "NoMDN";
                }
            }

            foreach (ShowShipmentBE obj in listOfBE)
            {
                string PartnerName = objPucBC.GetPartnerName(obj.Plant);
                obj.CM = PartnerName == "" ? obj.CM : PartnerName;
            }

            Session[vSSList] = listOfBE;



            if (ViewState[grdPageSize] != null)
            {
                gvDO.PageSize = Convert.ToInt32(ViewState[grdPageSize].ToString());
            }
            else
            {
                gvDO.PageSize = 10;
            }


            lblRec.Text  = Utils.GridRecDispMsg(gvDO.PageIndex, gvDO.PageSize, listOfBE.Count);
            gvDO.Visible = true;
            if (listOfBE != null && listOfBE.Count > 0)
            {
                rowPage.Visible = true;
                rowGrid.Visible = true;

                gvDO.DataSource = listOfBE;
                gvDO.DataBind();
                lblRec.Text    = Utils.GridRecDispMsg(gvDO.PageIndex, gvDO.PageSize, listOfBE.Count);
                gvDO.Visible   = true;
                lblRec.Visible = true;
            }
            else
            {
                lblRec.Visible  = false;
                rowGrid.Visible = false;
                rowPage.Visible = false;


                gvDO.Visible    = false;
                gvDO.DataSource = null;
                gvDO.DataBind();
                lblSearchError.Text    = "No records found.";
                lblSearchError.Visible = true;
            }
        }
        catch (Exception ex)
        {
            lblSearchError.Text    = ex.Message;
            lblSearchError.Visible = true;
            logFile.ErrorLogging(ex);
        }
    }