Exemplo n.º 1
0
    protected void SNVIEW_SelectedIndexChanged(object sender, EventArgs e)
    {
        XmlCreator xmlCreator = null;//实例化xmlcreator
        bool useOuter = true;
        string version = "";
        string Pallet_Id = SNVIEW.SelectedRow.Cells[1].Text.ToString().Trim();
        string Serial_Num = SNVIEW.SelectedRow.Cells[2].Text.ToString().Trim();
            //String value = DOCVIEW.Columns[1];
            //string doc = DOCVIEW.Rows[1];
            //Response.Write("<script type='text/javascript'>alert('"+ DOCVIEW.Rows[1] +"');</script>");
        DataConnLib con1 = new DataConnLib(ConfigurationManager.AppSettings["Database"]);
        try
        {
            string query = "select top 1 (VERSION) from [PAK.PAKRT_Log] nolock order by CREATE_DATE desc";
            con1.SqlQueComm(query, "VERSION");
            version = con1.Ds.Tables[0].Rows[0][0].ToString().Trim(); 
        }
        catch (System.Exception err) 
        {
            System.Windows.Forms.MessageBox.Show(err.Message.ToString());
        }
        DataConnLib con = new DataConnLib(ConfigurationManager.AppSettings["Database"]);
        try 
        {
            string query = "select distinct b.DOC_CAT,b.DOC_SET_NUMBER, b.XSL_TEMPLATE_NAME, a.PO_NUM, b.SCHEMA_FILE_NAME,a.CARTON_QTY from [PAK_PAKComn] a,[PAK.PAKRT] b where a.DOC_SET_NUMBER = b.DOC_SET_NUMBER   collate Chinese_Taiwan_Stroke_90_BIN  and a.InternalID = '" + BOX_DN.Text.ToString().Trim() + "'";//collate Chinese_Taiwan_Stroke_90_BIN 
            con.SqlQueComm(query,"DOCTable");
            if (con.Ds.Tables.Count > 0) 
            {   
                if (con.Ds.Tables[0].Rows.Count > 0)
                {
                    string dateyear = System.DateTime.Now.Year.ToString();
                    string datemonth = System.DateTime.Now.Month.ToString().Trim();
                    if (datemonth.Length == 1)
                    {
                        datemonth = "0" + datemonth;
                    }
                    string dateday = System.DateTime.Now.Day.ToString().Trim();
                    if (dateday.Length == 1)
                    {
                        dateday = "0" + dateday;
                    }
                    if (RadioButton_Step1.Checked)
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_PRE_MTP_TEST_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear + version;
                    }
                    else if (RadioButton_Step2.Checked)
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_MTP_TEST_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear + version;
                    }
                    else
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_PROD_CHECK_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear +version;
                    }
                    #region step1&step2
                    if (RadioButton_Step1.Checked || RadioButton_Step2.Checked)
                    {
                       // for (int i = 0; i <= con.Ds.Tables[0].Rows.Count; i++)
                        for (int i = 0; i < con.Ds.Tables[0].Rows.Count; i++)
                        {
                            bool isBsam = false;
                            if (con.Ds.Tables[0].Rows[i][4].ToString().ToUpper().IndexOf("BSAM") > 0)
                                isBsam = true;
                            if (int.Parse(con.Ds.Tables[0].Rows[i][5].ToString()) > 1)                         
                            {
                                if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Tablet_MRP")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxShipmentMRPXMLCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num + "/" + "M" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Tablet_Wholesale")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label" && isBsam)
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                            }
                            else 
                            {
                                if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Single Pack")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                #region mark
                                /*
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Tablet_MRP")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxShipmentMRPXMLCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num + "/" + "M" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Tablet_Wholesale")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                 **/
                                #endregion
                            }
                                if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pallet Ship Label- Pack ID Single")
                                {
                                    useOuter = true;
                                    //////if (Pallet_Id.Substring(0,2).ToString() == "NA" || Pallet_Id.Substring(0,2).ToString() == "BA")
                                    //////{
                                    //////    continue;
                                    //////}
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    if (filename_XML.IndexOf("TypeA") != -1)
                                    {
                                        xmlCreator = new PalletAShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        if (isBsam)
                                            xmlCreator = new PalletBShipmentBsamXmlCreator();
                                        else
                                            xmlCreator = new PalletBShipmentXmlCreator();
                                    }
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Pallet_Id);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);

                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Transportation")
                                {
                                    useOuter = false;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    #region Modify by 20130312
                                    //xmlCreator = new PackListShipmentXmlCreator();
                                    if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                    {
                                        useOuter = true;
                                        //xmlCreator = new MasterWaybillShipmentXmlCreator();
                                        xmlCreator = new MasterWaybillShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator();
                                    }
                                    #endregion
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Transportation");
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);

                                    ///*
                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                    //*/ 
                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Shipment")
                                {
                                    useOuter = false;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;


                                    if (isBsam)
                                    {
                                        xmlCreator = new HouseWaybillsXmlCreator();
                                        xmlCreator.LoadData(BOX_DN.Text.Trim());
                                        xmlCreator.WriteXml(docName_XML, true);
                                    }
                                    else if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC")) //add for QVC 201305
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator_QVC();
                                        //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                        xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment", docName_XML);

                                    }
                                    else
                                    {
                                        if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                        {
                                            useOuter = true;
                                            //xmlCreator = new MasterWaybillShipmentXmlCreator();
                                            xmlCreator = new MasterWaybillShipmentXmlCreator();
                                        }
                                        else
                                        {
                                            xmlCreator = new PackListShipmentXmlCreator();
                                        }
                                        xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                        //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                        xmlCreator.WriteXml(docName_XML, useOuter);
                                    }
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);
                                    ///*
                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                    //*/
                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Addition")
                                {
                                    useOuter = false;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new PackListShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);

                                    ///*
                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                    //*/
                                }
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Waybill- Addition")
                                {
                                    useOuter = true;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    //xmlCreator = new WayBillShipmentXmlCreator();
                                    xmlCreator = new WayBillShipmentXmlCreator();

                                    xmlCreator.LoadData(BOX_DN.Text.Trim());
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);
                                    ///*
                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                    //*/ 
                                }
                                
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "POS")
                                {
                                    useOuter = false;
                                    string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    //xmlCreator = new WayBillShipmentXmlCreator();
                                    string query_step3 = "select a.TruckID,[Date]   from HPIMES.dbo.Forwarder a,HPIMES.dbo.MAWB b where a.MAWB=b.MAWB or a.MAWB=b.HAWB and b.Delivery= '" + BOX_DN.Text.ToString().Trim() + "'";//collate Chinese_Taiwan_Stroke_90_BIN 
                                    con.SqlQueComm(query_step3, "Truck");
                                    if (con.Ds.Tables["Truck"].Rows.Count < 1)
                                    {
                                        Exception ex = new Exception("NO MAWB Or Forwarder Data!");
                                        throw ex;

                                    }

                                    xmlCreator = new POSXmlCreator();
                                    string TruckInfo = "";
                                    TruckInfo = con.Ds.Tables["Truck"].Rows[0][0] + @"@" + con.Ds.Tables["Truck"].Rows[0][1];
                                    xmlCreator.LoadData(TruckInfo);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);
                                    ///*
                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                    //*/ 
                                }
                        
                        }
                    }
                    #endregion
                    #region step3
                    else if (RadioButton_Step3.Checked)
                    {
                        //for (int i = 0; i <= con.Ds.Tables[0].Rows.Count; i++)
                        for (int i = 0; i < con.Ds.Tables[0].Rows.Count; i++)
                        {
                            bool isBsam = false;
                            if (con.Ds.Tables[0].Rows[i][4].ToString().ToUpper().IndexOf("BSAM") > 0)
                                isBsam = true;
                            if (int.Parse(con.Ds.Tables[0].Rows[i][5].ToString()) > 1)
                            {
                                //if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Over Pack_Gift Box")
                                if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Tablet_MRP")
                                {
                                    useOuter = true;
                                    string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxShipmentMRPXMLCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num + "/" + "M" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                               // else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Over Pack_Wholesale")
                                else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Tablet_Wholesale")
                                {
                                    useOuter = true;
                                    string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);


                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);

                                }
                                if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label"&&isBsam)
                                {
                                    useOuter = true;
                                    string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                    string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                    string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                    xmlCreator = new BoxLabelShipmentXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                    string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    //FOPWrap.FOP.GeneratePDF(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_PDF);
                                    //FOPWrap.FOP.GenerateFo(
                                    //    fopPath,
                                    //    docName_XML,
                                    //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    //    docName_FO);
                                    DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                    DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                }
                            }
                           else
                            {
                                if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label" || con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label_Single Pack")
                             {
                                useOuter = true;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new BoxLabelShipmentXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                             }
                            }
                             if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pallet Ship Label- Pack ID Single")
                            {
                                useOuter = true;
                                //if (Pallet_Id.Substring(0, 2).ToString() == "NA" || Pallet_Id.Substring(0, 2).ToString() == "BA")
                                //{
                                //    continue;
                                //}
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                if (filename_XML.IndexOf("TypeA") != -1)
                                {
                                    xmlCreator = new PalletAShipmentXmlCreator();
                                }
                                else
                                {
                                    if (isBsam)
                                        xmlCreator = new PalletBShipmentBsamXmlCreator();
                                    else
                                        xmlCreator = new PalletBShipmentXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Pallet_Id);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Transportation")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new PackListShipmentXmlCreator();
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                {
                                    useOuter = true;
                                    xmlCreator = new MasterWaybillShipmentXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PackListShipmentXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Transportation");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Shipment")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;

                                if (isBsam)
                                {
                                    xmlCreator = new HouseWaybillsXmlCreator();
                                    xmlCreator.LoadData(BOX_DN.Text.Trim());
                                    xmlCreator.WriteXml(docName_XML, true);
                                }
                                else if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC")) //add for QVC 201305
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment", docName_XML);

                                }
                                else
                                {
                                    if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                    {
                                        useOuter = true;
                                        xmlCreator = new MasterWaybillShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator();
                                    }
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                }
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                                #region mark
                                /*
                                //xmlCreator = new PackListShipmentXmlCreator();
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                {
                                    useOuter = true;
                                    xmlCreator = new MasterWaybillShipmentXmlCreator();
                                }
                                else if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC"))
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                }
                                else
                                {
                                    xmlCreator = new PackListShipmentXmlCreator();
                                }
                              //  xmlCreator.LoadData(BOX_DN.Text.Trim());
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);*/
                                #endregion
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Addition")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new PackListShipmentXmlCreator();
                                //xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Waybill- Addition")
                            {
                                useOuter = true;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillShipmentXmlCreator();
                                xmlCreator = new WayBillShipmentXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() );
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                             #region POS
                             
                             else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "POS")
                           {
                               useOuter = false;
                               string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                               string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                               string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                               //xmlCreator = new WayBillShipmentXmlCreator();
                               string query_step3 = "select a.TruckID,[Date]   from HPIMES.dbo.Forwarder a,HPIMES.dbo.MAWB b where a.MAWB=b.MAWB or a.MAWB=b.HAWB and b.Delivery= '" + BOX_DN.Text.ToString().Trim() + "'";//collate Chinese_Taiwan_Stroke_90_BIN 
                               con.SqlQueComm(query_step3, "Truck");
                               if (con.Ds.Tables["Truck"].Rows.Count < 1)
                               {
                                   Exception ex = new Exception("NO MAWB Or Forwarder Data!");
                                   throw ex;
                                  
                               }

                               xmlCreator = new POSXmlCreator();
                               string TruckInfo = "";
                               TruckInfo = con.Ds.Tables["Truck"].Rows[0][0] + @"@" + con.Ds.Tables["Truck"].Rows[0][1];
                               xmlCreator.LoadData(TruckInfo);
                               string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                               xmlCreator.WriteXml(docName_XML, useOuter);
                               string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                               string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                               string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                               //FOPWrap.FOP.GeneratePDF(
                               //    fopPath,
                               //    docName_XML,
                               //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                               //    docName_PDF);
                               //FOPWrap.FOP.GenerateFo(
                               //    fopPath,
                               //    docName_XML,
                               //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                               //    docName_FO);
                               DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                               DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                           }
                          
                             #endregion
                        }
                    }
                    #endregion
                    //Response.Write("<script type='text/javascript'>alert('" + con.Ds.Tables[0].Rows[0][0] + "');</script>");
                }
            }
        }
        catch (System.Exception err)
        {
           // MessageBox.Show(err.Message.ToString());
            logger.Error(err.Message + Environment.NewLine + err.ToString() + Environment.NewLine + err.InnerException);
            Response.Write(err);
        }

    }
Exemplo n.º 2
0
    public string PackingShipment_QVCLabel(string FilePH, string Dn)
    {
        PackListShipmentXmlCreator_QVC xmlCreator = null;
        xmlCreator = new PackListShipmentXmlCreator_QVC();
        string res = null;
        try
        {
            xmlCreator.LoadData(Dn.ToString().Trim() + @"/" + "", FilePH);
            //xmlCreator.WriteXml(FilePH, true);
            res = Dn;
        }
        catch (Exception err)
        {
            res = err.Message.ToString();
        }
        return res;

    }
Exemplo n.º 3
0
    public string PackingShipment_QVCLabel(string FilePH, string Dn)
    {
        logger.Info("PackingShipment_QVCLabel begin; FilePH=" + FilePH + " , Dn=" + Dn);
		PackListShipmentXmlCreator_QVC xmlCreator = null;
        xmlCreator = new PackListShipmentXmlCreator_QVC();
        string res = null;
        try
        {
            xmlCreator.LoadData(Dn.ToString().Trim() + @"/" + "", FilePH);
            //xmlCreator.WriteXml(FilePH, true);
            res = Dn;
        }
        catch (Exception err)
        {
            res = err.Message.ToString();
        }
		finally
        {
            logger.Info("PackingShipment_QVCLabel end");
        }
        return res;

    }
Exemplo n.º 4
0
    protected void SNVIEW_SelectedIndexChanged(object sender, EventArgs e)
    {
        XmlCreator xmlCreator = null;
        bool useOuter = true;
        string version = "";
        string Pallet_Id = SNVIEW.SelectedRow.Cells[1].Text.ToString().Trim(); //取選擇的gridview的值
        string Serial_Num = SNVIEW.SelectedRow.Cells[2].Text.ToString().Trim();
        //String value = DOCVIEW.Columns[1];
        //string doc = DOCVIEW.Rows[1];
        //Response.Write("<script type='text/javascript'>alert('"+ DOCVIEW.Rows[1] +"');</script>");
        DataConnLib con1 = new DataConnLib(ConfigurationManager.AppSettings["Database"]);//
        try
        {
            string query = "select top 1 (VERSION) from [PAK.PAKRT_Log] nolock order by CREATE_DATE desc";
            con1.SqlQueComm(query,"VERSION");
            version = con1.Ds.Tables[0].Rows[0][0].ToString().Trim(); 
        }
        catch (System.Exception err) 
        {
        
        }
        DataConnLib con = new DataConnLib(ConfigurationManager.AppSettings["Database"]);
        try 
        {
            string query = "select distinct b.DOC_CAT,b.DOC_SET_NUMBER, b.XSL_TEMPLATE_NAME, a.PO_NUM from [PAK.PAKComn] a,[PAK.PAKRT] b where a.DOC_SET_NUMBER = b.DOC_SET_NUMBER  collate Chinese_Taiwan_Stroke_90_BIN and a.InternalID = '" + BOX_DN.Text.ToString().Trim() + "'";
            con.SqlQueComm(query,"DOCTable");
            if (con.Ds.Tables.Count > 0) 
            {
                if (con.Ds.Tables[0].Rows.Count > 0)
                {
                    string dateyear = System.DateTime.Now.Year.ToString();//取當前時間的年份
                    string datemonth = System.DateTime.Now.Month.ToString().Trim();
                    if (datemonth.Length == 1)//月份是10月前的在月份前加上0
                    {
                        datemonth = "0" + datemonth;
                    }
                    string dateday = System.DateTime.Now.Day.ToString().Trim();
                    if (dateday.Length == 1)
                    {
                        dateday = "0" + dateday;
                    }
                    if (RadioButton_Step1.Checked)
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_PRE_MTP_TEST_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear + version;
                    }
                    else if (RadioButton_Step2.Checked)
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_MTP_TEST_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear + version;
                    }
                    else
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_PROD_CHECK_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear +version;
                    }
                    #region 當選擇step1和step2時
                    if (RadioButton_Step1.Checked || RadioButton_Step2.Checked)//當step1和step2被選擇的時候
                    {
                        for (int i = 0; i < con.Ds.Tables[0].Rows.Count; i++)
                        {
                            if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label")
                            {
                                useOuter = true;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new BoxLabelXmlCreator();//實例化一個xmlcreator
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);//傳入dn和SN
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;// ConfigurationManager.AppSettings["FilePath"]取config設置的文件存放路徑再加上文件名稱;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pallet Ship Label- Pack ID Single")
                            {
                                useOuter = true;
                                //if (Pallet_Id.Substring(0,2).ToString() == "NA" || Pallet_Id.Substring(0,2).ToString() == "BA")
                                //{
                                //    continue;
                                //}
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                if (filename_XML.IndexOf("TypeA") != -1)
                                {
                                    xmlCreator = new PalletAXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PalletBXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Pallet_Id); //PalletBXmlCreator();傳入數據為DN和pallet_id
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Transportation")
                            {
                                useOuter = false;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                #region Modify by 20130312
                                // xmlCreator = new PackListXmlCreator();
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                {
                                    useOuter = true;
                                    xmlCreator = new MasterWaybillShipmentXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PackListShipmentXmlCreator();
                                }
                                #endregion
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Transportation");//PackListXmlCreator()傳入參數是DN及要生成XML類型
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Shipment")
                            {
                                useOuter = false;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                #region Modify by 20130312
                                // xmlCreator = new PackListXmlCreator();
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC")) //add for QVC 201305
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment", docName_XML);

                                }
                                else
                                {
                                    if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                    {
                                        useOuter = true;
                                        xmlCreator = new MasterWaybillShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator();
                                    }
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                }
                                #endregion

                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Addition")
                            {
                                useOuter = false;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new PackListXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Waybill- Addition")
                            {
                                useOuter = true;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillXmlCreator();
                                xmlCreator = new WayBill_AdditionXMLCreat_new();
                                xmlCreator.LoadData(BOX_DN.Text.Trim());
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "POS")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillShipmentXmlCreator();
                                string query_step3 = "select a.TruckID,[Date]   from HPIMES.dbo.Forwarder a,HPIMES.dbo.MAWB b where a.MAWB=b.MAWB or a.MAWB=b.HAWB and b.Delivery= '" + BOX_DN.Text.ToString().Trim() + "'";//collate Chinese_Taiwan_Stroke_90_BIN 
                                con.SqlQueComm(query_step3, "Truck");
                                if (con.Ds.Tables["Truck"].Rows.Count < 1)
                                {
                                    Exception ex = new Exception("NO MAWB Or Forwarder Data!");
                                    throw ex;

                                }

                                xmlCreator = new POSXmlCreator();
                                string TruckInfo = "";
                                TruckInfo = con.Ds.Tables["Truck"].Rows[0][0] + @"@" + con.Ds.Tables["Truck"].Rows[0][1];
                                xmlCreator.LoadData(TruckInfo);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                        }
                    }
                    #endregion
                    #region 當選擇step3時 命名規則和step1和step2有區別將DN更換為PC
                    else if (RadioButton_Step3.Checked)
                    {
                        for (int i = 0; i < con.Ds.Tables[0].Rows.Count; i++)
                        {
                            if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label")
                            {
                                useOuter = true;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new BoxLabelXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pallet Ship Label- Pack ID Single")
                            {
                                useOuter = true;
                                //if (Pallet_Id.Substring(0, 2).ToString() == "NA" || Pallet_Id.Substring(0, 2).ToString() == "BA")
                                //{
                                //    continue;
                                //}
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                if (filename_XML.IndexOf("TypeA") != -1)
                                {
                                    xmlCreator = new PalletAXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PalletBXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Pallet_Id);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Transportation")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new PackListXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Transportation");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Shipment")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC")) //add for QVC 201305
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment", docName_XML);

                                }
                                else
                                {
                                     if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                    {
                                        useOuter = true;
                                        xmlCreator = new MasterWaybillShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator();
                                    }
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
 
                                }
                                //xmlCreator = new PackListXmlCreator();
                                //xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                //xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Addition")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new PackListXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Waybill- Additon")
                            {
                                useOuter = true;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillXmlCreator();
                                xmlCreator = new WayBill_AdditionXMLCreat_new();
                                xmlCreator.LoadData(BOX_DN.Text.Trim());
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "POS")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillShipmentXmlCreator();
                                string query_step3 = "select a.TruckID,[Date]   from HPIMES.dbo.Forwarder a,HPIMES.dbo.MAWB b where a.MAWB=b.MAWB or a.MAWB=b.HAWB and b.Delivery= '" + BOX_DN.Text.ToString().Trim() + "'";//collate Chinese_Taiwan_Stroke_90_BIN 
                                con.SqlQueComm(query_step3, "Truck");
                                if (con.Ds.Tables["Truck"].Rows.Count < 1)
                                {
                                    Exception ex = new Exception("NO MAWB Or Forwarder Data!");
                                    throw ex;

                                }

                                xmlCreator = new POSXmlCreator();
                                string TruckInfo = "";
                                TruckInfo = con.Ds.Tables["Truck"].Rows[0][0] + @"@" + con.Ds.Tables["Truck"].Rows[0][1];
                                xmlCreator.LoadData(TruckInfo);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                //FOPWrap.FOP.GeneratePDF(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_PDF);
                                //FOPWrap.FOP.GenerateFo(
                                //    fopPath,
                                //    docName_XML,
                                //    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                //    docName_FO);
                                DoGenFile(PDF, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_PDF);
                                DoGenFile(FO, Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()), docName_XML, docName_FO);
                            }
                        }
                    }
                        //Response.Write("<script type='text/javascript'>alert('" + con.Ds.Tables[0].Rows[0][0] + "');</script>");
                }
            }
        }
                    #endregion
        catch (System.Exception err)
        {
           // MessageBox.Show(err.Message.ToString());
            logger.Error(err.Message + Environment.NewLine + err.ToString() + Environment.NewLine + err.InnerException);
            Response.Write(err);
        }

    }
Exemplo n.º 5
0
    protected void SNVIEW_SelectedIndexChanged(object sender, EventArgs e)
    {
        XmlCreator xmlCreator = null;//实例化xmlcreator
        bool useOuter = true;
        string version = "";
        string Pallet_Id = SNVIEW.SelectedRow.Cells[1].Text.ToString().Trim();
        string Serial_Num = SNVIEW.SelectedRow.Cells[2].Text.ToString().Trim();
            //String value = DOCVIEW.Columns[1];
            //string doc = DOCVIEW.Rows[1];
            //Response.Write("<script type='text/javascript'>alert('"+ DOCVIEW.Rows[1] +"');</script>");
        DataConnLib con1 = new DataConnLib(ConfigurationManager.AppSettings["Database"]);
        try
        {
            string query = "select top 1 (VERSION) from [PAK.PAKRT_Log] nolock order by CREATE_DATE desc";
            con1.SqlQueComm(query,"VERSION");
            version = con1.Ds.Tables[0].Rows[0][0].ToString().Trim(); 
        }
        catch (System.Exception err) 
        {
            System.Windows.Forms.MessageBox.Show(err.Message.ToString());
        }
        DataConnLib con = new DataConnLib(ConfigurationManager.AppSettings["Database"]);
        try 
        {
            string query = "select distinct b.DOC_CAT,b.DOC_SET_NUMBER, b.XSL_TEMPLATE_NAME, a.PO_NUM from [PAK_PAKComn] a,[PAK.PAKRT] b where a.DOC_SET_NUMBER = b.DOC_SET_NUMBER  collate Chinese_Taiwan_Stroke_90_BIN  and a.InternalID = '" + BOX_DN.Text.ToString().Trim() + "'";//collate Chinese_Taiwan_Stroke_90_BIN 
            con.SqlQueComm(query,"DOCTable");
            if (con.Ds.Tables.Count > 0) 
            {   
                if (con.Ds.Tables[0].Rows.Count > 0)
                {
                    string dateyear = System.DateTime.Now.Year.ToString();
                    string datemonth = System.DateTime.Now.Month.ToString().Trim();
                    if (datemonth.Length == 1)
                    {
                        datemonth = "0" + datemonth;
                    }
                    string dateday = System.DateTime.Now.Day.ToString().Trim();
                    if (dateday.Length == 1)
                    {
                        dateday = "0" + dateday;
                    }
                    if (RadioButton_Step1.Checked)
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_PRE_MTP_TEST_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear + version;
                    }
                    else if (RadioButton_Step2.Checked)
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_MTP_TEST_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear + version;
                    }
                    else
                    {
                        Label_Messege.Text = "ZipFileName: Inventec_PROD_CHECK_DATE_" + dateyear + datemonth + dateday + "_EDITS_REVISION_" + dateyear +version;
                    }
                    if (RadioButton_Step1.Checked || RadioButton_Step2.Checked)
                    {
                       // for (int i = 0; i <= con.Ds.Tables[0].Rows.Count; i++)
                        for (int i = 0; i < con.Ds.Tables[0].Rows.Count; i++)
                        {
                            if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label")
                            {
                                useOuter = true;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new BoxLabelShipmentXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pallet Ship Label- Pack ID Single")
                            {
                                useOuter = true;
                                //////if (Pallet_Id.Substring(0,2).ToString() == "NA" || Pallet_Id.Substring(0,2).ToString() == "BA")
                                //////{
                                //////    continue;
                                //////}
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                if (filename_XML.IndexOf("TypeA") != -1)
                                {
                                    xmlCreator = new PalletAShipmentXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PalletBShipmentXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Pallet_Id);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Transportation")
                            {
                                useOuter = false;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                #region Modify by 20130312
                                //xmlCreator = new PackListShipmentXmlCreator();
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                {
                                    useOuter = true;
                                    xmlCreator = new MasterWaybillShipmentXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PackListShipmentXmlCreator();
                                }
                                #endregion
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Transportation");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Shipment")
                            {
                               
                                useOuter = false;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC")) //add for QVC 201305
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment", docName_XML);
                                   
                                }
                                else
                                {
                                    if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                    {
                                        useOuter = true;
                                        xmlCreator = new MasterWaybillShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator();
                                    }
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                }
                                    string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                    string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                    string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                    FOPWrap.FOP.GeneratePDF(
                                        fopPath,
                                        docName_XML,
                                        Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                        docName_PDF);
                                    FOPWrap.FOP.GenerateFo(
                                        fopPath,
                                        docName_XML,
                                        Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                        docName_FO);
                                
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Addition")
                            {

                                useOuter = false;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new PackListShipmentXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else  if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Waybill- Addition")
                            {

                                useOuter = true;
                                string filename_XML = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = DropDownList_ID.Text + "_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillShipmentXmlCreator();
                                xmlCreator = new WayBillShipmentXmlCreator();

                                xmlCreator.LoadData(BOX_DN.Text.Trim());
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                        }
                    }
                    #region step3
                    else if (RadioButton_Step3.Checked)
                    {
                        //for (int i = 0; i <= con.Ds.Tables[0].Rows.Count; i++)
                        for (int i = 0; i < con.Ds.Tables[0].Rows.Count; i++)
                        {
                           if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Box Ship Label")
                            {
                                useOuter = true;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new BoxLabelShipmentXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Serial_Num);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pallet Ship Label- Pack ID Single")
                            {
                                useOuter = true;
                                //if (Pallet_Id.Substring(0, 2).ToString() == "NA" || Pallet_Id.Substring(0, 2).ToString() == "BA")
                                //{
                                //    continue;
                                //}
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                if (filename_XML.IndexOf("TypeA") != -1)
                                {
                                    xmlCreator = new PalletAShipmentXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PalletBShipmentXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/" + Pallet_Id);
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Transportation")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new PackListShipmentXmlCreator();
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                {
                                    useOuter = true;
                                    xmlCreator = new MasterWaybillShipmentXmlCreator();
                                }
                                else
                                {
                                    xmlCreator = new PackListShipmentXmlCreator();
                                }
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Transportation");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Shipment")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC")) //add for QVC 201305
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment", docName_XML);

                                }
                                else
                                {
                                    if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                    {
                                        useOuter = true;
                                        xmlCreator = new MasterWaybillShipmentXmlCreator();
                                    }
                                    else
                                    {
                                        xmlCreator = new PackListShipmentXmlCreator();
                                    }
                                    xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                    //string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                    xmlCreator.WriteXml(docName_XML, useOuter);
                                }
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                                /*
                                //xmlCreator = new PackListShipmentXmlCreator();
                                if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("Rail"))
                                {
                                    useOuter = true;
                                    xmlCreator = new MasterWaybillShipmentXmlCreator();
                                }
                                else if (con.Ds.Tables[0].Rows[i][2].ToString().Contains("QVC"))
                                {
                                    xmlCreator = new PackListShipmentXmlCreator_QVC();
                                }
                                else
                                {
                                    xmlCreator = new PackListShipmentXmlCreator();
                                }
                              //  xmlCreator.LoadData(BOX_DN.Text.Trim());
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Shipment");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);*/
                            }

                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Pack List- Addition")
                            {
                                useOuter = false;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                xmlCreator = new PackListShipmentXmlCreator();
                                //xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                xmlCreator.LoadData(BOX_DN.Text.Trim() + "/Pack List- Addition");
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                            else if (con.Ds.Tables[0].Rows[i][0].ToString().Trim() == "Waybill- Addition")
                            {
                                useOuter = true;
                                string filename_XML = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".xml");
                                string filename_PDF = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".pdf");
                                string filename_FO = "PC_" + con.Ds.Tables[0].Rows[i][1].ToString() + "_" + con.Ds.Tables[0].Rows[i][3].ToString() + "_" + con.Ds.Tables[0].Rows[i][2].ToString().Replace(".xslt", ".fo");
                                //xmlCreator = new WayBillShipmentXmlCreator();
                                xmlCreator = new WayBillShipmentXmlCreator();
                                xmlCreator.LoadData(BOX_DN.Text.Trim() );
                                string docName_XML = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_XML;
                                xmlCreator.WriteXml(docName_XML, useOuter);
                                string docName_PDF = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_PDF;
                                string docName_FO = ConfigurationManager.AppSettings["FilePath"] + @"\" + filename_FO;
                                string fopPath = ConfigurationManager.AppSettings["FOPPath"];
                                FOPWrap.FOP.GeneratePDF(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_PDF);
                                FOPWrap.FOP.GenerateFo(
                                    fopPath,
                                    docName_XML,
                                    Server.MapPath(@"~\XSL\" + con.Ds.Tables[0].Rows[i][2].ToString().Trim()),
                                    docName_FO);
                            }
                        }
                    }
                    #endregion
                    //Response.Write("<script type='text/javascript'>alert('" + con.Ds.Tables[0].Rows[0][0] + "');</script>");
                }
            }
        }
        catch (System.Exception err)
        {
           // MessageBox.Show(err.Message.ToString());
            Response.Write(err);
        }

    }