Пример #1
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("MMTH_{0}_FORVAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);
        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_MMTH_Order_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                while ((line = sr.ReadLine()) != null)
                {
                    string[] arr = line.Split('|');
                    if (!arr[4].Contains("9999999999999999"))
                    {
                        string plantCode = arr[2];
                        string yyyy      = arr[3].Substring(0, 4);
                        string MM        = arr[3].Substring(4, 2);
                        string partNo    = arr[4];
                        string dayOld    = arr[11];
                        for (int d = 12; d <= arr.Length - 1; d += 2)
                        {
                            if (arr[d - 1] == "00")
                            {
                                break;
                            }
                            if (Convert.ToInt32(dayOld) > Convert.ToInt32(arr[d - 1]))
                            {
                                DateTime dtTemp = Convert.ToDateTime(yyyy + "-" + MM + "-01");
                                dtTemp = dtTemp.AddMonths(1);
                                MM     = dtTemp.Month.ToString();
                                yyyy   = dtTemp.Year.ToString();
                            }
                            MyCompany.Models.MMTHForcastImport forcast = new MyCompany.Models.MMTHForcastImport();
                            forcast.OrderBy             = "40113011";
                            forcast.DeliveryDestination = plantCode;
                            forcast.CustomerMatCode     = partNo.Trim();
                            string[] materialTemp = SharedBusinessRules.getMaterial(forcast.CustomerMatCode, "40113011", plantCode, "MMTh").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                forcast.SAPCode                 = materialTemp[0];
                                forcast.PartsDevision           = materialTemp[1];
                                forcast.DeliveryDestinationCode = materialTemp[2];
                            }
                            forcast.CustomerPO          = "";
                            forcast.ReliabilityDevision = "F";
                            forcast.Unit         = "ST";
                            forcast.PlngPeriod   = "D";
                            forcast.DeliveryDate = Convert.ToDateTime(yyyy + "-" + MM + "-" + arr[d - 1]);
                            forcast.Quantity     = Convert.ToInt32(arr[d]);
                            forcast.Insert();
                            dayOld = arr[d - 1];
                        }
                    }
                }
            }
        }
    }
Пример #2
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("THM_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = string.Empty; // "40108011";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                int totalLine = 0, totalOrder = 1;

                using (SqlProcedure sp = new SqlProcedure("sp_THM_Order_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }

                while ((line = sr.ReadLine()) != null)
                {
                    totalLine++;
                    if (line.Length > 0)
                    {
                        #region Format
                        // "000000000000" is Supply Part
                        string shipto = line.Substring(145, 5) + "-" + line.Substring(22, 6);
                        if ((line.Substring(140, 5) == "45320" || line.Substring(140, 5) == "05386") && line.Substring(10, 12) != "000000000000")
                        {
                            MyCompany.Models.THMOrderImport Order = new MyCompany.Models.THMOrderImport();
                            Order.DeliveryDestination = line.Substring(145, 5) + "-" + line.Substring(22, 6);
                            Order.OrderBy             = "40101011";
                            Order.CustomerMatCode     = line.Substring(28, 18).Trim().Replace(" ", "");
                            string[] materialTemp = SharedBusinessRules.getMaterial(line.Substring(28, 18).Trim().Replace(" ", ""), Order.OrderBy, line.Substring(22, 6), line.Substring(145, 5)).Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Order.SAPCode                 = materialTemp[0];
                                Order.PartsDevision           = materialTemp[1];
                                Order.DeliveryDestinationCode = materialTemp[2];
                                Order.Key1 = materialTemp[3];
                                Order.Key2 = materialTemp[4];
                                Order.Key3 = materialTemp[5];
                            }
                            Order.CustomerPO          = line.Substring(10, 12).Trim();
                            Order.ReliabilityDevision = "P"; //Realiability = [Forcast=F,Order=P]
                            Order.DeliveryDate        = Convert.ToDateTime(line.Substring(118, 4).Trim() + "-" + line.Substring(122, 2).Trim() + "-" + line.Substring(124, 2).Trim());
                            Order.Quantity            = line.Substring(126, 7).Trim();
                            Order.Unit = "ST";       // SD Fixd Data Unit = ST
                            //SD Fixd Data Unit = ST, Periad = D, Realiability = [Forcast=F,Order=P]
                            Order.PlngPeriod  = "D"; // Periad = D
                            Order.PlantCode   = line.Substring(22, 6) + " Add. " + line.Substring(94, 4).Trim();
                            Order.AddCode     = totalOrder.ToString();
                            Order.Arrivaltime = line.Substring(116, 2) + ":00:00";
                            Order.FromTo      = line.Substring(88, 5).Trim() + ":" + line.Substring(145, 5);
                            Order.Filename    = fn;
                            Order.Insert();
                            totalOrder++;
                        }
                        #endregion
                    }
                }

                sr.Close();
            }
        }
        //// Save file
        //string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        //filename = String.Format("THM_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        //AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);


        //string CustCode = "40101010";
        //filename = Server.MapPath("~/Files/") + filename;
        //if (File.Exists(filename))
        //{
        //    string line = string.Empty;
        //    using (StreamReader sr = new StreamReader(filename))
        //    {
        //        using (SqlProcedure sp = new SqlProcedure("sp_THM_Order_ClearData"))
        //        {
        //            sp.ExecuteNonQuery();
        //        }
        //        while ((line = sr.ReadLine()) != null)
        //        {
        //            if (line.Length > 0)
        //            {
        //                //string shipto = line.Substring(145, 5) + "-" + line.Substring(22, 6);
        //                if ((line.Substring(140, 5) == "45320" || line.Substring(140, 5) == "05386") && line.Substring(10, 12) != "000000000000")
        //                //if ((line.Substring(140, 5).Trim() == "CRS1" || line.Substring(140, 5) == "45320") && line.Substring(10, 12) != "000000000000")
        //                {
        //                    //string[] item = line.Split(Convert.ToChar("|"));
        //                    MyCompany.Models.THMOrderImport Order = new MyCompany.Models.THMOrderImport();
        //                    Order.OrderBy = CustCode;
        //                    Order.DeliveryDestination = ""; //Not sure
        //                    Order.CustomerMatCode = line.Substring(28, 18).Replace(" ","");
        //                    Order.PartsDevision = "1";
        //                    Order.CustomerPO = line.Substring(10, 12);
        //                    Order.ReliabilityDevision = "P";
        //                    Order.DeliveryDate =Convert.ToDateTime( line.Substring(118, 4) + "-" + line.Substring(122, 2) + "-" + line.Substring(124, 2));
        //                    Order.Quantity = float.Parse(line.Substring(126, 7)).ToString().Trim();
        //                    Order.Unit = "ST";
        //                    Order.PlngPeriod = "D";
        //                    string[] materialTemp = SharedBusinessRules.getMaterial(Order.CustomerMatCode, Order.OrderBy, PlantCode, LocationCode).Split(':');
        //                    if (materialTemp.Length > 1)
        //                    {
        //                        Order.SAPCode = materialTemp[0];
        //                        Order.PartsDevision = materialTemp[1];
        //                        Order.DeliveryDestinationCode = materialTemp[2];
        //                    }
        //                    Order.Insert();

        //                }

        //            }
        //        }
        //        sr.Close();
        //    }

        //}
    }
Пример #3
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);

        filename = String.Format("AAT_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // AAT
        string CustCode = "40116011";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            DataTable dt         = new DataTable();
            var       connString = string.Format(@"Provider=Microsoft.Jet.OleDb.4.0; Data Source={0};Extended Properties=""Text;HDR=YES;FMT=Delimited""", Path.GetDirectoryName(filename));
            using (OleDbConnection con = new OleDbConnection(connString))
            {
                try
                {
                    using (SqlProcedure sp = new SqlProcedure("sp_AAT_Order_ClearData"))
                    {
                        sp.ExecuteNonQuery();
                    }
                    if (con.State != ConnectionState.Open)
                    {
                        con.Open();
                    }
                    var query = "SELECT * FROM [" + Path.GetFileName(filename) + "]";
                    using (var adapter = new OleDbDataAdapter(query, con))
                    {
                        adapter.Fill(dt);
                        if (dt.Columns.Count == 39)
                        {
                            bool boolStatusInsert = false;
                            foreach (DataRow _item in dt.Rows)
                            {
                                if (boolStatusInsert)
                                {
                                    if (_item[38].ToString() == "W")
                                    {
                                        MyCompany.Data.Objects.AATOrderImport Order = new MyCompany.Data.Objects.AATOrderImport();
                                        Order.OrderBy             = CustCode;
                                        Order.DeliveryDestination = _item[8].ToString();
                                        Order.CustomerMatCode     = _item[11].ToString();
                                        string[] scpdTemp = SharedBusinessRules.getMaterial(_item[11].ToString(), CustCode, _item[8].ToString(), "AAT").Split(':');
                                        Order.PartsDevision       = scpdTemp[1];
                                        Order.CustomerPO          = _item[12].ToString();
                                        Order.ReliabilityDevision = "F";
                                        Order.DeliveryDate        = Convert.ToDateTime(_item[35].ToString().Substring(0, 4).Trim() + "-" + _item[35].ToString().Substring(4, 2).Trim() + "-" + _item[35].ToString().Substring(6, 2).Trim());
                                        Order.Quantity            = _item[32].ToString();
                                        Order.Unit       = _item[33].ToString();
                                        Order.PlngPeriod = "D";
                                        Order.SAPCode    = scpdTemp[0];
                                        Order.Insert();
                                    }
                                }
                                else
                                {
                                    boolStatusInsert = true;
                                }
                            }
                        }
                        else if (dt.Columns.Count == 30)
                        {
                            bool boolStatusInsert = false;
                            foreach (DataRow _item in dt.Rows)
                            {
                                if (boolStatusInsert)
                                {
                                    MyCompany.Data.Objects.AATOrderImport Order = new MyCompany.Data.Objects.AATOrderImport();
                                    Order.OrderBy             = CustCode;
                                    Order.DeliveryDestination = _item[8].ToString();
                                    Order.CustomerMatCode     = _item[11].ToString();
                                    string[] scpdTemp = SharedBusinessRules.getMaterial(_item[11].ToString(), CustCode, _item[8].ToString(), "AAT").Split(':');
                                    Order.PartsDevision       = scpdTemp[1];
                                    Order.CustomerPO          = _item[12].ToString();
                                    Order.ReliabilityDevision = "F";
                                    Order.DeliveryDate        = Convert.ToDateTime(_item[28].ToString().Substring(0, 4).Trim() + "-" + _item[28].ToString().Substring(4, 2).Trim() + "-" + _item[28].ToString().Substring(6, 2).Trim());
                                    Order.Quantity            = _item[25].ToString();
                                    Order.Unit       = _item[26].ToString();
                                    Order.PlngPeriod = "D";
                                    Order.SAPCode    = scpdTemp[0];
                                    Order.Insert();
                                }
                                else
                                {
                                    boolStatusInsert = true;
                                }
                            }
                        }
                    }
                    con.Close();
                }
                catch (Exception ex)
                {
                }
            }
        }
    }
Пример #4
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("HATC_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);
        string LocationCode = string.Empty;
        // HATC Order
        string CustCode = string.Empty;

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                //List<MyCompany.Models.HATCForcastImport> HATCList = new List<MyCompany.Models.HATCForcastImport>();
                string CustMatNo = string.Empty, year = string.Empty, PlantCode = string.Empty;
                Dictionary <int, string> dueDate  = new Dictionary <int, string>();
                Dictionary <int, double> orderQty = new Dictionary <int, double>();
                int lineIndex = -1;
                using (SqlProcedure sp = new SqlProcedure("sp_HATC_Forcast_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                string ReliabilityDevision = string.Empty;
                while ((line = sr.ReadLine()) != null)
                {
                    if (lineIndex >= 0)
                    {
                        lineIndex++;
                    }

                    switch (lineIndex)
                    {
                    case 3:
                        year = line.Substring(40, 4);
                        string[] ln = line.Split(' ');
                        LocationCode = ln[3];
                        break;

                    case 5:
                        try
                        {
                            dueDate.Clear();
                            orderQty.Clear();
                            // get Part and Delivery Date
                            CustMatNo = line.Substring(0, line.IndexOf("DATE")).Trim();
                            string[] data     = line.Substring(line.IndexOf("DATE") + 4, (line.IndexOf("TOTAL") - line.IndexOf("DATE") - 4)).Trim().Split(' ');
                            int      colIndex = 0;
                            for (int i = 0; i < data.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(data[i].Trim()))
                                {
                                    string[] _dueDate = data[i].Split('/');
                                    if (_dueDate.Length > 0)
                                    {
                                        dueDate.Add(colIndex, String.Format("{0}-{1}-{2}", year, _dueDate[1], _dueDate[0]));
                                        colIndex++;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        break;

                    case 6: try
                        {
                            line = line.Substring(line.IndexOf("QTY.") + 4, line.Length - line.IndexOf("QTY.") - 10);
                            int colIndex = 0;
                            while (line.Length >= 7)
                            {
                                string qty = line.Substring(0, 7).Trim();
                                qty = String.IsNullOrEmpty(qty) ? "0" : qty;
                                orderQty.Add(colIndex, Convert.ToDouble(qty));
                                line = line.Substring(7, line.Length - 7);
                                colIndex++;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        break;

                    case 11:
                        PlantCode = line.Substring(16, 17).Trim();

                        for (int i = 0; i < dueDate.Count; i++)
                        {
                            //[XXXX]03 => 40138011 => HATC-P
                            //[XXXX]xx => 40108011 => HATC

                            MyCompany.Models.HATCForcastImport forcast = new MyCompany.Models.HATCForcastImport();
                            forcast.OrderBy             = PlantCode.EndsWith("03") ? "40138011" : "40108011";
                            forcast.DeliveryDestination = PlantCode + "-" + LocationCode;
                            forcast.CustomerMatCode     = CustMatNo;
                            string[] materialTemp = SharedBusinessRules.getMaterial(forcast.CustomerMatCode, PlantCode.EndsWith("03") ? "40138011" : "40108011", PlantCode, LocationCode).Split(':');
                            if (materialTemp.Length > 1)
                            {
                                forcast.SAPCode = materialTemp[0];
                                if (materialTemp[1] == "1A")
                                {
                                    forcast.PartsDevision = "1";
                                }
                                else if (materialTemp[1] == "1B")
                                {
                                    forcast.PartsDevision = "2";
                                }
                                else
                                {
                                    forcast.PartsDevision = materialTemp[1];
                                }

                                forcast.DeliveryDestinationCode = materialTemp[2];
                                forcast.Key1 = materialTemp[3];
                                forcast.Key2 = materialTemp[4];
                                forcast.Key3 = materialTemp[5];
                            }
                            forcast.CustomerPO          = "";
                            forcast.ReliabilityDevision = ReliabilityDevision;
                            forcast.Unit         = "ST";
                            forcast.PlngPeriod   = "D";
                            forcast.DeliveryDate = Convert.ToDateTime(dueDate[i]);
                            forcast.Quantity     = Convert.ToInt32(orderQty[i].ToString());
                            forcast.FileName     = fn;
                            forcast.Insert();
                        }
                        break;

                    default:
                        break;
                    }

                    if (line.Trim().StartsWith("PART ORDER SCHEDULE (MAIL)") || line.Trim().StartsWith("PURCHASE SHEET (MAIL)"))
                    {
                        if (line.Trim().StartsWith("PART ORDER SCHEDULE (MAIL)"))
                        {
                            ReliabilityDevision = "F";
                        }
                        else if (line.Trim().StartsWith("PURCHASE SHEET (MAIL)"))
                        {
                            ReliabilityDevision = "P";
                        }
                        lineIndex = 0;
                    }
                }

                sr.Close();
            }
        }
    }
Пример #5
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {

        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn = filename;
        filename = String.Format("IMCT_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40111011";
        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                //using (SqlProcedure sp = new SqlProcedure("sp_IMCT_Order_ClearData"))
                //{
                //    sp.ExecuteNonQuery();
                //}
                int i = 1;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        if (!line.Contains("ISUZU"))
                        {
                            MyCompany.Models.IMCTOrderImport Order = new MyCompany.Models.IMCTOrderImport();
                            Order.OrderBy = CustCode;
                            Order.DeliveryDestination = line.Substring(120, 5).Trim();
                            Order.CustomerMatCode = line.Substring(35, 10).Trim();
                            Order.CustomerPO = line.Substring(2, 10).Trim();
                            Order.ReliabilityDevision = "P";
                            Order.DeliveryDate = Convert.ToDateTime(line.Substring(50, 4).Trim() + "-" + line.Substring(54, 2).Trim() + "-" + line.Substring(56, 2).Trim());
                            Order.Quantity = float.Parse(line.Substring(58, 6)).ToString().Trim();
                            Order.Unit = "ST";
                            Order.PlngPeriod = "D";
                            string[] materialTemp = SharedBusinessRules.getMaterial(line.Substring(35, 10).Trim().Replace(" ", ""), CustCode, line.Substring(120, 5).Trim(), "IMCT").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Order.SAPCode = materialTemp[0];
                                Order.PartsDevision = materialTemp[1];
                                Order.DeliveryDestinationCode = materialTemp[2];
                                Order.Key1 = materialTemp[3];
                                Order.Key2 = materialTemp[4];
                                Order.Key3 = materialTemp[5];
                            }
                            Order.AddCode = i.ToString();
                            Order.PlantCode = "";
                            Order.Arrivaltime = line.Substring(159, 2).Trim() + ":" + line.Substring(161, 2).Trim();
                            Order.FromTo = "RTP:" + line.Substring(120, 5).Trim();
                            Order.Filename = fn;
                            Order.Insert();
                            i++;
                        }
                    }
                }
                
                sr.Close();
            }

        }
    }
Пример #6
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("HATC_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_IMCT_Forcast_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                sr.ReadLine();
                while ((line = sr.ReadLine()) != null)
                {
                    string   DeliveryDestination = line.Substring(33, 6).Trim();
                    string   OrderBy             = "40111011";
                    string   CusMatCode          = line.Substring(41, 10);
                    string   locCode             = line.Substring(39, 2).Trim();
                    string[] materialTemp        = SharedBusinessRules.getMaterial(CusMatCode, OrderBy, DeliveryDestination, "IMCT").Split(':');

                    int startPointDate = 92;
                    int startPointQty  = 148;
                    for (int w = 1; w <= 6; w++)
                    {
                        DateTime dateOld      = Convert.ToDateTime(line.Substring(startPointDate, 4).ToString() + "-" + line.Substring(startPointDate + 4, 2).ToString() + "-" + line.Substring(startPointDate + 6, 2).ToString());
                        int      subPointDate = 8;
                        int      subPointQty  = 0;
                        for (int d = 1; d <= 6; d++)
                        {
                            DateTime dateDrliveryDate;
                            if (line.Substring(startPointDate + subPointDate, 4).ToString().Trim() != string.Empty)
                            {
                                dateDrliveryDate = Convert.ToDateTime(line.Substring(startPointDate + subPointDate, 4).ToString() + "-" + line.Substring(startPointDate + subPointDate + 4, 2).ToString() + "-" + line.Substring(startPointDate + subPointDate + 6, 2).ToString());
                            }
                            else
                            {
                                dateDrliveryDate = dateOld.AddDays(d - 1);
                            }
                            int numQty = Convert.ToInt32(line.Substring(startPointQty + subPointQty, 6).ToString());
                            MyCompany.Models.IMCTForcastImport forcast = new MyCompany.Models.IMCTForcastImport();
                            forcast.OrderBy             = OrderBy;
                            forcast.DeliveryDestination = DeliveryDestination + "-" + locCode;
                            forcast.CustomerMatCode     = CusMatCode;
                            if (materialTemp.Length > 1)
                            {
                                forcast.SAPCode                 = materialTemp[0];
                                forcast.PartsDevision           = materialTemp[1];
                                forcast.DeliveryDestinationCode = materialTemp[2];
                                forcast.Key1 = materialTemp[3];
                                forcast.Key2 = materialTemp[4];
                                forcast.Key3 = materialTemp[5];
                            }
                            forcast.CustomerPO          = "";
                            forcast.ReliabilityDevision = "F";
                            forcast.Unit         = "ST";
                            forcast.PlngPeriod   = "D";
                            forcast.DeliveryDate = dateDrliveryDate;
                            forcast.Quantity     = numQty;
                            forcast.FileName     = fn;
                            forcast.Insert();
                            subPointDate += 8;
                            subPointQty  += 6;
                        }
                        startPointDate += 100;
                        startPointQty  += 100;
                    }
                }
            }
        }
    }
Пример #7
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("THM_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);
        string LocationCode = string.Empty;
        // HATC Order
        string CustCode = string.Empty;

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                //List<MyCompany.Models.HATCForcastImport> HATCList = new List<MyCompany.Models.HATCForcastImport>();
                string CustMatNo = string.Empty, year = string.Empty, PlantCode = string.Empty;
                Dictionary <int, string> dueDate  = new Dictionary <int, string>();
                Dictionary <int, double> orderQty = new Dictionary <int, double>();
                int lineIndex = -1;
                using (SqlProcedure sp = new SqlProcedure("sp_THM_Forcast_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                string ReliabilityDevision = string.Empty;
                while ((line = sr.ReadLine()) != null)
                {
                    if (lineIndex >= 0)
                    {
                        lineIndex++;
                    }

                    switch (lineIndex)
                    {
                    case 3:
                        year = line.Substring(40, 4);
                        string[] ln = line.Split(' ');
                        LocationCode = ln[3];
                        break;

                    case 5:
                        try
                        {
                            dueDate.Clear();
                            orderQty.Clear();
                            // get Part and Delivery Date
                            CustMatNo = line.Substring(0, line.IndexOf("DATE")).Trim();
                            string[] data     = line.Substring(line.IndexOf("DATE") + 4, (line.IndexOf("TOTAL") - line.IndexOf("DATE") - 4)).Trim().Split(' ');
                            int      colIndex = 0;
                            for (int i = 0; i < data.Length; i++)
                            {
                                if (!string.IsNullOrEmpty(data[i].Trim()))
                                {
                                    string[] _dueDate = data[i].Split('/');
                                    if (_dueDate.Length > 0)
                                    {
                                        dueDate.Add(colIndex, String.Format("{0}-{1}-{2}", year, _dueDate[1], _dueDate[0]));
                                        colIndex++;
                                    }
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        break;

                    case 6: try
                        {
                            line = line.Substring(line.IndexOf("QTY.") + 4, line.Length - line.IndexOf("QTY.") - 10);
                            int colIndex = 0;
                            while (line.Length >= 7)
                            {
                                string qty = line.Substring(0, 7).Trim();
                                qty = String.IsNullOrEmpty(qty) ? "0" : qty;
                                orderQty.Add(colIndex, Convert.ToDouble(qty));
                                line = line.Substring(7, line.Length - 7);
                                colIndex++;
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                        break;

                    case 11:
                        PlantCode = line.Substring(16, 17).Trim();

                        for (int i = 0; i < dueDate.Count; i++)
                        {
                            //[XXXX]03 => 40138011 => HATC-P
                            //[XXXX]xx => 40108011 => HATC

                            MyCompany.Models.THMForcastImport forcast = new MyCompany.Models.THMForcastImport();
                            forcast.OrderBy             = "40101011";
                            forcast.DeliveryDestination = PlantCode + "-" + LocationCode;
                            forcast.CustomerMatCode     = CustMatNo;
                            string[] materialTemp = SharedBusinessRules.getMaterial(forcast.CustomerMatCode, forcast.OrderBy, PlantCode, LocationCode).Split(':');
                            if (materialTemp.Length > 1)
                            {
                                forcast.SAPCode                 = materialTemp[0];
                                forcast.PartsDevision           = materialTemp[1];
                                forcast.DeliveryDestinationCode = materialTemp[2];
                            }
                            forcast.CustomerPO          = "";
                            forcast.ReliabilityDevision = ReliabilityDevision;
                            forcast.Unit         = "ST";
                            forcast.PlngPeriod   = "D";
                            forcast.DeliveryDate = Convert.ToDateTime(dueDate[i]);
                            forcast.Quantity     = orderQty[i].ToString();
                            forcast.FileName     = fn;
                            forcast.Insert();
                        }
                        break;

                    default:
                        break;
                    }

                    if (line.Trim().StartsWith("PART ORDER SCHEDULE (MAIL)") || line.Trim().StartsWith("PURCHASE SHEET (MAIL)"))
                    {
                        if (line.Trim().StartsWith("PART ORDER SCHEDULE (MAIL)"))
                        {
                            ReliabilityDevision = "F";
                        }
                        else if (line.Trim().StartsWith("PURCHASE SHEET (MAIL)"))
                        {
                            ReliabilityDevision = "P";
                        }
                        lineIndex = 0;
                    }
                }

                sr.Close();
            }
        }

        //// Save file
        //string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        //filename = String.Format("THM_{0}_FORCAST_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        //AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        //// HATC Order
        //string CustCode = "40101010";
        //filename = Server.MapPath("~/Files/") + filename;
        //if (File.Exists(filename))
        //{
        //    string line = string.Empty;
        //    using (StreamReader sr = new StreamReader(filename))
        //    {
        //        int rowsCount = 0;
        //        int i = 0;
        //        List<string> str = new List<string>();

        //        string CustPartNo = string.Empty, CustomerCode = string.Empty, Desination = string.Empty;
        //        using (SqlProcedure sp = new SqlProcedure("sp_THM_Forcast_ClearData"))
        //        {
        //            sp.ExecuteNonQuery();
        //        }
        //        while ((line = sr.ReadLine()) != null)
        //        {
        //            rowsCount++;
        //            if (rowsCount % 16 == 0)
        //            {

        //                //Get Customer code
        //                CustomerCode = str[2].Substring(5, 10).Trim();
        //                Desination = str[9].Substring(8, 10).Trim();
        //                //Get Customer Part No && Array Date
        //                //string[] arrStrLine6;
        //                //arrStrLine6 = str[5].Split(Convert.ToChar(" "));
        //                //int getRow5 = 0;
        //                List<MQtyOrder> QtyOfDate = new List<MQtyOrder>();
        //                //CustPartNo = str[5].Split(Convert.ToChar(" "));
        //                CustPartNo = str[5].Substring(0, 31);
        //                #region DateOfOrder
        //                if (str[5].Substring(33, 4) == "DATE")
        //                {
        //                    //MessageBox.Show("Line OK");
        //                    string Month = "";
        //                    int startPostition = 0;
        //                    int endPostition = 0;
        //                    string flagPosition = "End";
        //                    //string flagSavePosition = "No";
        //                    //Merge stirng Date
        //                    for (int iRow5 = 37; iRow5 < str[5].Length; iRow5++)
        //                    {
        //                        if (str[5].Substring(iRow5, 1) != " ")
        //                        {
        //                            if (flagPosition == "End")
        //                            {
        //                                startPostition = iRow5;
        //                                flagPosition = "Start";
        //                            }
        //                            if (str[5].Substring(iRow5, 5) == "TOTAL")
        //                            {
        //                                //MessageBox.Show("End Line !!!");
        //                                //return;
        //                                break;
        //                            }
        //                            else
        //                            {
        //                                Month = Month + str[5].Substring(iRow5, 1);
        //                            }

        //                        }
        //                        else
        //                        {
        //                            if (flagPosition == "Start")
        //                            {
        //                                //flagPosition = "End";
        //                                //}
        //                                flagPosition = "End";
        //                                endPostition = iRow5;
        //                                //flagSavePosition = "NO";
        //                            }
        //                            if (Month != "")
        //                            {
        //                                //Save Date
        //                                MQtyOrder Qty = new MQtyOrder();
        //                                Qty.OrderDate = Month;
        //                                Qty.startPosition = startPostition;
        //                                Qty.endPosition = endPostition;
        //                                QtyOfDate.Add(Qty);
        //                                //MessageBox.Show(Month + " : " + startPostition + "," + endPostition);
        //                                Month = "";
        //                            }
        //                        }
        //                    }
        //                #endregion
        //                    #region QtyOfOrder
        //                    if (str[6].Substring(33, 4) == "QTY.")
        //                    {
        //                        //for (int iRow6 = 37; iRow6 < str[6].Length; iRow6++)
        //                        //{

        //                        //}
        //                        for (int iQty = 0; iQty < QtyOfDate.Count; iQty++)
        //                        {
        //                            //MQtyOrder Qty = new MQtyOrder();
        //                            //Qty = QtyOfDate[iQty];
        //                            //Qty.OrderQty =
        //                            string Qty = str[6].Substring(QtyOfDate[iQty].startPosition, QtyOfDate[iQty].endPosition - QtyOfDate[iQty].startPosition).ToString().Trim();
        //                            if (Qty == "")
        //                            {
        //                                QtyOfDate[iQty].OrderQty = 0;
        //                            }
        //                            else
        //                            {
        //                                QtyOfDate[iQty].OrderQty = Convert.ToInt32(Qty);
        //                            }
        //                            //QtyOfDate[iQty].OrderQty = str[6].Substring(QtyOfDate[iQty].startPosition, QtyOfDate[iQty].endPosition - QtyOfDate[iQty].startPosition);
        //                        }
        //                    }
        //                    #endregion
        //                    #region ShowData
        //                    //List<MT05> Data = new List<MT05>();
        //                    for (int iShow = 0; iShow < QtyOfDate.Count; iShow++)
        //                    {
        //                        MyCompany.Data.Objects.THMForcastImport Order = new MyCompany.Data.Objects.THMForcastImport();
        //                        Order.OrderBy = CustomerCode;
        //                        Order.DeliveryDestination = Desination;
        //                        Order.CustomerMatCode = CustPartNo;
        //                        Order.PartsDevision = "1";
        //                        Order.CustomerPO = "Not sure";
        //                        Order.ReliabilityDevision = "P";
        //                        //Order.DeliveryDate = QtyOfDate[iShow].OrderDate;
        //                        //Order.Quantity = Convert.ToDecimal( QtyOfDate[iShow].OrderQty);
        //                        Order.Unit = "ST";
        //                        Order.PlngPeriod = "D";
        //                        Order.SAPCode = "";//SharedBusinessRules.getSAPCode(Order.CustomerMatCode);
        //                        Order.Insert();

        //                    }
        //                    #endregion
        //                    str.Clear();
        //                    //rowsCount = 1;
        //                }

        //            }
        //            else
        //            {
        //                str.Add(line);
        //            }
        //        }
        //        sr.Close();
        //    }
        //}
    }
Пример #8
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("TSM_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);
        filename = Server.MapPath("~/Files/") + filename;
        string extfile = Path.GetExtension(filename);
        string fileCsv = filename.Replace(extfile, ".csv");

        ExcelToCSVCoversion(filename, fileCsv);
        if (File.Exists(fileCsv))
        {
            DataTable dt         = new DataTable();
            var       connString = string.Format(@"Provider=Microsoft.Jet.OleDb.4.0; Data Source={0};Extended Properties=""Text;HDR=YES;FMT=Delimited""", Path.GetDirectoryName(filename));
            using (OleDbConnection con = new OleDbConnection(connString))
            {
                var query = "SELECT * FROM [" + Path.GetFileName(fileCsv) + "]";
                using (var adapter = new OleDbDataAdapter(query, con))
                {
                    adapter.Fill(dt);
                    if (dt.Columns.Count == 18)
                    {
                        DataTable dtTemp = dt.AsEnumerable()
                                           .GroupBy(r => new { Col1 = r["PLACE"], Col2 = r["P-NO"], Col3 = r["DUE"] })
                                           .Select(g =>
                        {
                            var row      = dt.NewRow();
                            row["PLACE"] = g.Key.Col1;
                            row["P-NO"]  = g.Key.Col2;
                            row["QTY"]   = g.Sum(r => r.Field <int>("QTY"));
                            row["DUE"]   = g.Key.Col3;
                            return(row);
                        }).CopyToDataTable();
                        string CustCode = "40104011";
                        foreach (DataRow item in dtTemp.Rows)
                        {
                            MyCompany.Models.KMTForcastImport Forcast = new MyCompany.Models.KMTForcastImport();
                            Forcast.OrderBy             = CustCode;
                            Forcast.DeliveryDestination = item[5].ToString();
                            string[] arrCus = item[1].ToString().Split('-');
                            Forcast.CustomerMatCode = arrCus[0].ToString().Substring(arrCus[0].Length - 5) + "-" + arrCus[1].Substring(0, 4);
                            string[] materialTemp = SharedBusinessRules.getMaterial(Forcast.CustomerMatCode, Forcast.OrderBy, item[5].ToString(), "KMT").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Forcast.SAPCode = materialTemp[0];
                                if (materialTemp[1] == "1A")
                                {
                                    Forcast.PartsDevision = "1";
                                }
                                else if (materialTemp[1] == "1B")
                                {
                                    Forcast.PartsDevision = "2";
                                }
                                else
                                {
                                    Forcast.PartsDevision = materialTemp[1];
                                }

                                Forcast.DeliveryDestinationCode = materialTemp[2];
                                Forcast.Key1 = materialTemp[3];
                                Forcast.Key2 = materialTemp[4];
                                Forcast.Key3 = materialTemp[5];
                            }
                            Forcast.CustomerPO          = "";
                            Forcast.ReliabilityDevision = "P";
                            Forcast.Unit         = "ST";
                            Forcast.PlngPeriod   = "D";
                            Forcast.DeliveryDate = Convert.ToDateTime(item[4]);
                            Forcast.Quantity     = Convert.ToInt32(item[7].ToString());
                            Forcast.FileName     = fn;
                            Forcast.Insert();
                        }
                    }
                    else if (dt.Columns.Count == 16)
                    {
                        DataTable dtTemp = dt.AsEnumerable()
                                           .GroupBy(r => new { Col1 = r["RCV PLACE"], Col2 = r["ITEMNO"], Col3 = r["DUE"] })
                                           .Select(g =>
                        {
                            var row          = dt.NewRow();
                            row["RCV PLACE"] = g.Key.Col1;
                            row["ITEMNO"]    = g.Key.Col2;
                            row["QTY"]       = g.Sum(r => r.Field <int>("QTY"));
                            row["DUE"]       = g.Key.Col3;
                            return(row);
                        }).CopyToDataTable();
                        string CustCode = "40104011";
                        foreach (DataRow item in dtTemp.Rows)
                        {
                            MyCompany.Models.KMTForcastImport Forcast = new MyCompany.Models.KMTForcastImport();
                            Forcast.OrderBy             = CustCode;
                            Forcast.DeliveryDestination = item[7].ToString();
                            string[] arrCus = item[1].ToString().Split('-');
                            Forcast.CustomerMatCode = arrCus[0].ToString().Substring(arrCus[0].Length - 5) + "-" + arrCus[1].Substring(0, 4);
                            string[] materialTemp = SharedBusinessRules.getMaterial(Forcast.CustomerMatCode, Forcast.OrderBy, item[7].ToString(), "KMT").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Forcast.SAPCode = materialTemp[0];
                                if (materialTemp[1] == "1A")
                                {
                                    Forcast.PartsDevision = "1";
                                }
                                else if (materialTemp[1] == "1B")
                                {
                                    Forcast.PartsDevision = "2";
                                }
                                else
                                {
                                    Forcast.PartsDevision = materialTemp[1];
                                }

                                Forcast.DeliveryDestinationCode = materialTemp[2];
                                Forcast.Key1 = materialTemp[3];
                                Forcast.Key2 = materialTemp[4];
                                Forcast.Key3 = materialTemp[5];
                            }
                            Forcast.CustomerPO          = "";
                            Forcast.ReliabilityDevision = "F";
                            Forcast.Unit         = "ST";
                            Forcast.PlngPeriod   = "D";
                            Forcast.DeliveryDate = Convert.ToDateTime(item[5]);
                            Forcast.Quantity     = Convert.ToInt32(item[6].ToString());
                            Forcast.FileName     = fn;
                            Forcast.Insert();
                        }
                    }
                }
            }
        }
    }
Пример #9
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("TSM_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);
        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_TSM_Forcast_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                string[]  strCol = { "DeliveryDestination", "CustomerMatCode", "CustomerPO", "Quantity", "DeliveryDate", "FromTo", "StatusCode", "DeliveryDateOld" };
                DataTable dt     = new DataTable();
                foreach (string strItem in strCol)
                {
                    if (strItem == "Quantity")
                    {
                        dt.Columns.Add(strItem, typeof(int));
                    }
                    else
                    {
                        dt.Columns.Add(strItem);
                    }
                }
                while ((line = sr.ReadLine()) != null)
                {
                    string[] item = ParseCsvRow(line);
                    if (item.Length > 1 && (item[1].Trim() == "NEW" || item[1].Trim() == "RES"))
                    {
                        dt.Rows.Add(item[2].Trim(), item[3].Trim(), item[7].Trim(), Convert.ToInt32(item[9].Trim()), item[10].Trim(), "RTP:" + item[2].Trim(), item[1].Trim(), item[11].Trim());
                    }
                }
                DataTable dtTemp = dt.AsEnumerable()
                                   .GroupBy(r => new { Col1 = r["DeliveryDestination"], Col2 = r["CustomerMatCode"], Col3 = r["CustomerPO"], Col4 = r["DeliveryDate"], Col5 = r["FromTo"], Col6 = r["StatusCode"], Col7 = r["DeliveryDateOld"] })
                                   .Select(g =>
                {
                    var row = dt.NewRow();
                    row["DeliveryDestination"] = g.Key.Col1;
                    row["CustomerMatCode"]     = g.Key.Col2;
                    row["CustomerPO"]          = g.Key.Col3;
                    row["Quantity"]            = g.Sum(r => r.Field <int>("Quantity"));
                    row["DeliveryDate"]        = g.Key.Col4;
                    row["FromTo"]          = g.Key.Col5;
                    row["StatusCode"]      = g.Key.Col6;
                    row["DeliveryDateOld"] = g.Key.Col7;
                    return(row);
                }).CopyToDataTable();
                string CustCode = "40102011";

                foreach (DataRow item in dtTemp.Rows)
                {
                    string[] dmy = Convert.ToString(item[4]).Split('/');
                    MyCompany.Models.TSMForcastImport Forcast = new MyCompany.Models.TSMForcastImport();
                    Forcast.OrderBy             = CustCode;
                    Forcast.DeliveryDestination = Convert.ToString(item[0]);
                    Forcast.CustomerMatCode     = Convert.ToString(item[1]);
                    Forcast.CustomerPO          = Convert.ToString(item[2]);
                    Forcast.ReliabilityDevision = "P";
                    Forcast.Quantity            = Convert.ToInt32(Convert.ToString(item[3]));
                    Forcast.Unit         = "ST";
                    Forcast.PlngPeriod   = "D";
                    Forcast.DeliveryDate = Convert.ToDateTime(dmy[0] + "-" + dmy[1] + "-20" + dmy[2]);
                    string[] materialTemp = SharedBusinessRules.getMaterial(Forcast.CustomerMatCode, CustCode, Forcast.DeliveryDestination, "TSM").Split(':');
                    if (materialTemp.Length > 1)
                    {
                        Forcast.SAPCode                 = materialTemp[0];
                        Forcast.PartsDevision           = materialTemp[1];
                        Forcast.DeliveryDestinationCode = materialTemp[2];
                        Forcast.Key1 = materialTemp[3];
                        Forcast.Key2 = materialTemp[4];
                        Forcast.Key3 = materialTemp[5];
                    }
                    Forcast.FileName = fn;
                    if (Convert.ToString(item[6]) == "RES")
                    {
                        string[] dmyOld = Convert.ToString(item[7]).Split('/');
                        Forcast.DeliveryDateOld = Convert.ToDateTime(dmyOld[0] + "-" + dmyOld[1] + "-20" + dmyOld[2]);
                    }
                    Forcast.Condition = Convert.ToString(item[6]);
                    Forcast.Insert();
                }
            }
        }
    }
Пример #10
0
    protected void AsyncFileUpload1_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
    {
        // Save file
        string filename = System.IO.Path.GetFileName(AsyncFileUpload1.FileName);
        string fn       = filename;

        filename = String.Format("MMTH_{0}_ORDER_{1}", DateTime.Now.ToString("yyyyMMddHHmmss"), filename);
        AsyncFileUpload1.SaveAs(Server.MapPath("~/Files/") + filename);

        // HATC Order
        string CustCode = "40113011";

        filename = Server.MapPath("~/Files/") + filename;
        if (File.Exists(filename))
        {
            string line = string.Empty;
            using (StreamReader sr = new StreamReader(filename))
            {
                using (SqlProcedure sp = new SqlProcedure("sp_MMTH_Order_ClearData"))
                {
                    sp.ExecuteNonQuery();
                }
                int i = 1;
                while ((line = sr.ReadLine()) != null)
                {
                    if (line.Length > 0)
                    {
                        if (line.Contains("T099") && !line.Contains("9999999999"))
                        {
                            string[] item = line.Split(Convert.ToChar("|"));
                            MyCompany.Models.MMTHOrderImport Order = new MyCompany.Models.MMTHOrderImport();
                            Order.OrderBy             = CustCode;
                            Order.DeliveryDestination = item[2];
                            Order.CustomerMatCode     = item[7].Trim();
                            string[] materialTemp = SharedBusinessRules.getMaterial(item[7].Trim(), CustCode, item[2], "MMTh").Split(':');
                            if (materialTemp.Length > 1)
                            {
                                Order.SAPCode                 = materialTemp[0];
                                Order.PartsDevision           = materialTemp[1];
                                Order.DeliveryDestinationCode = materialTemp[2];
                                Order.Key1 = materialTemp[3];
                                Order.Key2 = materialTemp[4];
                                Order.Key3 = materialTemp[5];
                            }
                            Order.CustomerPO          = item[4].Trim();
                            Order.ReliabilityDevision = "P";
                            Order.DeliveryDate        = Convert.ToDateTime(item[5].Substring(0, 4).Trim() + "-" + item[5].Substring(5, 2).Trim() + "-" + item[5].Substring(8, 2).Trim());
                            Order.Quantity            = float.Parse(item[8]).ToString().Trim();
                            Order.Unit        = "ST";
                            Order.PlngPeriod  = "D";
                            Order.AddCode     = item[3] + ":" + item[6] + ":" + item[11] + ": :" + item[26] + ":" + i.ToString();
                            Order.PlantCode   = item[10];
                            Order.Arrivaltime = "00:00:00";
                            Order.FromTo      = item[1] + ":PLANT-" + item[2];
                            Order.Filename    = fn;
                            Order.Insert();
                            i++;
                        }
                    }
                }
                sr.Close();
            }
        }
    }