예제 #1
0
        /// <summary>
        /// 添加欠料表原采购回复
        /// </summary>
        /// <param name="iLoginEx"></param>
        /// <param name="i"></param>
        /// <returns></returns>
        public static int AddMaterialShortage(LoginEx iiLoginEx, Infolst i)
        {
            iLoginEx = iiLoginEx;
            int n = 0;

            try
            {
                OleDbConnection con = GetCon();
                OpenCon();
                string       sql = string.Format("insert into zhrs_t_zzcMaterialShortage(MCoding,MDate,MNumber,MExplain,MDescribe,MOther)values('{0}','{1}','{2}','{3}','{4}','{5}')", i.MCoding, i.Date, i.Num, i.Explain, i.Describe, i.MOther);
                OleDbCommand com = new OleDbCommand(sql, con);
                com.CommandTimeout = 3600;
                n = com.ExecuteNonQuery();
                CloseCon();
            }
            catch (Exception ex)
            {
                MessageBox.Show("错误: " + ex.Message);
            }
            finally
            {
                GC.Collect();
                GC.Collect(1);
            }
            return(n);
        }
예제 #2
0
        /// <summary>
        ///  提取方法
        /// </summary>
        /// <param name="one">材料编码</param>
        /// <param name="reg">判断格式是否日期(1-1)</param>
        /// <param name="str">判断字符串是否纯中文</param>
        /// <param name="g">判断格式是否数值字母k</param>
        /// <param name="num">判断格式是否纯数字</param>
        /// <param name="llst">llst的集合</param>
        /// <param name="su">截取字符串的数组集合</param>
        /// <param name="ii">数组集合的下标</param>
        private void NewMethod(string one, Regex reg, Regex str, Regex g, Regex num, Infolst llst, string[] su, int ii)
        {
            llst.MCoding = one;
            if (reg.Match(su[ii].ToString().Trim()).Success)
            {
                Match m = reg.Match(su[ii].Trim().ToString());
                if (m.Success)
                {
                    string strdate = iLoginEx.iYear().ToString() + "-" + m.Value;
                    llst.Date = DateTime.Parse(strdate.Trim()).ToString("yyyy-MM-dd");
                }
            }
            else if (num.Match(su[ii].Trim().ToString()).Success)
            {
                Match m = num.Match(su[ii].Trim().ToString());
                if (m.Success)
                {
                    llst.Num = m.Value;
                }
            }
            else if (g.Match(su[ii].Trim().ToString()).Success)
            {
                Match m = g.Match(su[ii].Trim().ToString());
                if (m.Success)
                {
                    string strin = (Convert.ToDouble(m.Value.Replace("K", "")) * 1000).ToString();

                    llst.Num = strin;
                }
            }
            else if (str.Match(su[ii].Trim().ToString()).Success)
            {
                Match m = str.Match(su[ii].Trim().ToString());
                if (m.Success)
                {
                    llst.Explain = m.Value;
                }
            }
            else
            {
                llst.Describe = su[ii].ToString().Trim();
            }
        }
예제 #3
0
        public DataSet GetExcelData(string strExcelFileName, string nameFile)
        {
            // string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;;Data Source=" + str + ";Extended Properties ='Excel 8.0;HDR=NO;IMEX=1'";
            // string strCon = string.Format("Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;'", strExcelFileName);//HDR=Yes;IMEX=1;
            string          strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strExcelFileName + ";Extended Properties='Excel 12.0;HDR=No;IMEX=1;'";
            OleDbConnection myConn = new OleDbConnection(strCon);
            string          strCom = " SELECT * FROM [table1$]";

            if (myConn.State == ConnectionState.Open)
            {
                myConn.Close();
            }
            myConn.Open();
            OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
            DataSet          myDataSet = new DataSet();

            myCommand.Fill(myDataSet, "[Sheet1$]");


            for (int i = 1; i < myDataSet.Tables[0].Rows.Count; i++)
            {
                string three = myDataSet.Tables[0].Rows[i][2].ToString();
                string tow   = myDataSet.Tables[0].Rows[i][1].ToString();
                string one   = myDataSet.Tables[0].Rows[i][0].ToString();

                Infolst lt = new Infolst();
                if (!String.IsNullOrEmpty(one) || !String.IsNullOrEmpty(tow))
                {
                    //判断文本是否为纯数字
                    if (Regex.IsMatch(tow, @"^\d+$"))
                    {
                        if (tow.Length == 5)
                        {
                            lt.MCoding = one;
                            lt.Date    = DateTime.FromOADate(Convert.ToInt32(tow)).ToString("yyyy-MM-dd");
                            lt.Num     = three;
                            lt.MOther  = nameFile;
                            lst.Add(lt);
                        }
                    }
                    else if (Regex.IsMatch(tow, @"^\d{1,2}[\u4e00-\u9fa5]{1}\d{1,2}[\u4e00-\u9fa5]{1}$"))//判断字符串是否(几月几日)的格式。
                    {
                        lt.MCoding = one;
                        lt.Date    = DateTime.Parse(tow.Trim()).ToString("yyyy-MM-dd");
                        lt.Num     = three;
                        lt.MOther  = nameFile;
                        lst.Add(lt);
                    }
                    else if (Regex.IsMatch(tow, @"^[\u4e00-\u9fa5]+$"))//判断字符串是否纯中文
                    {
                        lt.MCoding = one;
                        lt.Explain = tow;
                        lt.MOther  = nameFile;
                        lst.Add(lt);
                    }
                    else if (tow.Contains(","))
                    {
                        string[] subing = tow.Split(',');
                        Regex    reg    = new Regex(@"^\d{1,2}-\d{1,2}$");       //判断格式是否日期(1-1)
                        Regex    str    = new Regex(@"^[\u4e00-\u9fa5]+$");      //判断字符串是否纯中文
                        Regex    g      = new Regex(@"^\d+(.\d{1})[K]|\d+[K]$"); //判断格式是否数值字母k
                        Regex    num    = new Regex(@"^\d+$");                   //判断格式是否纯数字
                        for (int ei = 0; ei < subing.Length; ei++)
                        {
                            Infolst llsst = new Infolst();
                            if (subing[ei].Contains(":") || subing[ei].Contains(":"))
                            {
                                Infolst  llst = new Infolst();
                                string   eii  = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",");
                                string[] su   = eii.Split(',');
                                for (int ii = 0; ii < su.Length; ii++)
                                {
                                    NewMethod(one, reg, str, g, num, llst, su, ii);
                                }
                                if (!String.IsNullOrEmpty(llst.Num))
                                {
                                    llst.MOther = nameFile;
                                    lst.Add(llst);
                                }
                                else
                                {
                                    llst.Num    = three;
                                    llst.MOther = nameFile;
                                    lst.Add(llst);
                                }
                            }

                            else
                            {
                                llsst.MCoding  = one;
                                llsst.Describe = subing[ei].ToString();
                                llsst.MOther   = nameFile;
                                lst.Add(llsst);
                            }
                        }
                    }
                    else if (tow.Contains(","))
                    {
                        string[] subing = tow.Split(',');
                        Regex    reg    = new Regex(@"^\d{1,2}-\d{1,2}$");       //判断格式是否日期(1-1)
                        Regex    str    = new Regex(@"^[\u4e00-\u9fa5]+$");      //判断字符串是否纯中文
                        Regex    g      = new Regex(@"^\d+(.\d{1})[K]|\d+[K]$"); //判断格式是否数值字母k
                        Regex    num    = new Regex(@"^\d+$");                   //判断格式是否纯数字
                        for (int ei = 0; ei < subing.Length; ei++)
                        {
                            Infolst llsst = new Infolst();
                            if (subing[ei].Contains(":") || subing[ei].Contains(":"))
                            {
                                Infolst  llst = new Infolst();
                                string   eii  = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",");//.Replace("已扣", ",已扣").Replace("研发", ",").Replace("个", ",");
                                string[] su   = eii.Split(',');
                                for (int ii = 0; ii < su.Length; ii++)
                                {
                                    NewMethod(one, reg, str, g, num, llst, su, ii);
                                }
                                if (!String.IsNullOrEmpty(llst.Num))
                                {
                                    llst.MOther = nameFile;
                                    lst.Add(llst);
                                }
                                else
                                {
                                    llst.Num    = three;
                                    llst.MOther = nameFile;
                                    lst.Add(llst);
                                }
                            }
                            else
                            {
                                llsst.MCoding  = one;
                                llsst.Describe = subing[ei].ToString();
                                llsst.MOther   = nameFile;
                                lst.Add(llsst);
                            }
                        }
                    }
                    else if (tow.Contains(":") || tow.Contains(":"))
                    {
                        //  tow = tow.Replace("K-", "K,").Replace("复-","复,").Replace("到",",").Replace(" ",":").Replace("预计",":预计:").Replace(",港","");
                        string[] subing = tow.Split(',');
                        Regex    reg    = new Regex(@"^\d{1,2}-\d{1,2}$");       //判断格式是否日期(1-1)
                        Regex    str    = new Regex(@"^[\u4e00-\u9fa5]+$");      //判断字符串是否纯中文
                        Regex    g      = new Regex(@"^\d+(.\d{1})[K]|\d+[K]$"); //判断格式是否数值字母k
                        Regex    num    = new Regex(@"^\d+$");                   //判断格式是否纯数字
                        for (int ei = 0; ei < subing.Length; ei++)
                        {
                            Infolst llsst = new Infolst();
                            if (subing[ei].Contains(":") || subing[ei].Contains(":"))
                            {
                                Infolst llst = new Infolst();
                                string  eii  = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",");// Replace("K-", "K,每").Replace("预计", ",预计,").Replace("到台湾", ",到台湾,").Replace("香港", ",香港").Replace("到港", ",到港").Replace("号,", ",");

                                string[] su = eii.Split(',');

                                for (int ii = 0; ii < su.Length; ii++)
                                {
                                    NewMethod(one, reg, str, g, num, llst, su, ii);
                                }
                                if (String.IsNullOrEmpty(llst.Num))
                                {
                                    llst.Num    = three;
                                    llst.MOther = nameFile;
                                    lst.Add(llst);
                                }
                                else
                                {
                                    llst.MOther = nameFile;
                                    lst.Add(llst);
                                }
                            }
                            else
                            {
                                llsst.MCoding  = one;
                                llsst.Describe = subing[ei].ToString();
                                llsst.MOther   = nameFile;
                                lst.Add(llsst);
                            }
                        }
                    }
                    #region MyRegion
                    //else if (tow.Contains("至"))
                    //{
                    //    lt.MCoding = one;
                    //    lt.Explain = tow;
                    //    lst.Add(lt);
                    //}
                    //else if (tow.Contains("剩下的"))
                    //{
                    //    tow = tow.Replace("剩下的", ",剩下的");
                    //    string[] subing = tow.Split(',');
                    //    Regex reg = new Regex(@"^\d{1,2}-\d{1,2}$");//判断格式是否日期(1-1)
                    //    Regex str = new Regex(@"^[\u4e00-\u9fa5]+$");//判断字符串是否纯中文
                    //    Regex g = new Regex(@"^\d+(.\d{1})[K]|\d+[K]$");//判断格式是否数值字母k
                    //    Regex num = new Regex(@"^\d+$");//判断格式是否纯数字
                    //    for (int ei = 0; ei < subing.Length; ei++)
                    //    {
                    //        Infolst llsst = new Infolst();
                    //        if (subing[ei].Contains(":") || subing[ei].Contains(":"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",").Replace("寄出", ",寄出,").Replace("~10K", "K");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);
                    //        }
                    //        else if (subing[ei].Contains("寄出"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",").Replace("寄出", ",寄出,");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);
                    //        }
                    //        else if (subing[ei].Contains("已到"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",").Replace("已到香港", ",已到,");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);
                    //        }
                    //        else if (subing[ei].Contains("预计"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",").Replace("已到香港", ",已到,").Replace("预计", ",预计,").Replace("香港", ",香港,").Replace("剩下的", ",剩下的,");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);
                    //        }
                    //        else
                    //        {
                    //            llsst.MCoding = one;
                    //            llsst.Describe = subing[ei].ToString();
                    //            lst.Add(llsst);
                    //        }
                    //    }
                    //}
                    //else if (tow.Contains("已到") || tow.Contains("快递"))
                    //{
                    //    tow = tow.Replace(".", "-").Replace("已到", ":已到:").Replace("快递", ":快递");
                    //    string[] subing = tow.Split(',');
                    //    Regex reg = new Regex(@"^\d{1,2}-\d{1,2}$");//判断格式是否日期(1-1)
                    //    Regex str = new Regex(@"^[\u4e00-\u9fa5]+$");//判断字符串是否纯中文
                    //    Regex g = new Regex(@"^\d+(.\d{1})[K]|\d+[K]$");//判断格式是否数值字母k
                    //    Regex num = new Regex(@"^\d+$");//判断格式是否纯数字
                    //    for (int ei = 0; ei < subing.Length; ei++)
                    //    {
                    //        Infolst llsst = new Infolst();
                    //        if (subing[ei].Contains(":") || subing[ei].Contains(":"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",").Replace("寄出", ",寄出,").Replace("~10K", "K");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);
                    //        }
                    //        else if (subing[ei].Contains("寄出"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace(",", ",").Replace("寄出", ",寄出,");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);
                    //        }
                    //        else
                    //        {
                    //            llsst.MCoding = one;
                    //            llsst.Describe = subing[ei].ToString();
                    //            lst.Add(llsst);
                    //        }
                    //    }

                    //}
                    //else if (tow.Contains(" "))
                    //{

                    //    tow = tow.Replace("K-", "K,").Replace(" ", ":");
                    //    string[] subing = tow.Split(',');
                    //    Regex reg = new Regex(@"^\d{1,2}-\d{1,2}$");//判断格式是否日期(1-1)
                    //    Regex str = new Regex(@"^[\u4e00-\u9fa5]+$");//判断字符串是否纯中文
                    //    Regex g = new Regex(@"^\d+(.\d{1})[K]|\d+[K]$");//判断格式是否数值字母k
                    //    Regex num = new Regex(@"^\d+$");//判断格式是否纯数字
                    //    for (int ei = 0; ei < subing.Length; ei++)
                    //    {
                    //        Infolst llsst = new Infolst();
                    //        if (subing[ei].Contains(":") || subing[ei].Contains(":"))
                    //        {
                    //            Infolst llst = new Infolst();
                    //            string eii = subing[ei].Replace(":", ",").Replace(":", ",").Replace("/", "-").Replace("回,", ",").Replace("号,", ",").Replace(",", ",").Replace("K-", "K,每").Replace("预计", "预计,").Replace(".", "-").Replace("到台湾", ",到台湾,").Replace("香港", ",香港,");
                    //            string[] su = eii.Split(',');
                    //            for (int ii = 0; ii < su.Length; ii++)
                    //            {
                    //                NewMethod(one, reg, str, g, num, llst, su, ii);
                    //            }
                    //            lst.Add(llst);

                    //        }
                    //        else
                    //        {
                    //            llsst.MCoding = one;
                    //            llsst.Describe = subing[ei].ToString();
                    //            lst.Add(llsst);
                    //        }
                    //    }
                    //}
                    #endregion
                    else
                    {
                        lt.MCoding = one;
                        lt.Explain = tow;
                        lt.MOther  = nameFile;
                        lst.Add(lt);
                    }
                }
            }



            myConn.Close();
            return(myDataSet);
        }