Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="m">机器类型</param>
        public void Init(MachineLists m)
        {
            try
            {
                switch (m)
                {
                case MachineLists.真PQ:
                    this.Com.BaudRate = 4800;
                    this.Com.Parity   = Parity.None;
                    this.Com.DataBits = 8;
                    this.Com.StopBits = StopBits.One;
                    break;

                case MachineLists.假PQ:
                    this.Com.BaudRate = 1200;
                    this.Com.Parity   = Parity.Even;
                    this.Com.DataBits = 8;
                    this.Com.StopBits = StopBits.Two;
                    break;
                }
                this.machine       = m;
                this.Com.RtsEnable = true;
                this.Com.DtrEnable = true;
                this.Com.Open();
                exit   = false;
                thRead = new Thread(new ThreadStart(Flush));
                thRead.IsBackground = true;
                thRead.Start();
            }
            catch (Exception e)
            {
                Error = e.Message;
            }
        }
        /// <summary>
        /// 从条码和订单号比对得出是否外销
        /// </summary>
        /// <param name="OrderName"></param>
        /// <param name="BarCode"></param>
        /// <returns></returns>
        public static MachineLists GetMachine(string OrderName, string BarCode)
        {
            MachineLists result = MachineLists.内销;

            if (!CheckBar(BarCode))
            {
                return(result);
            }
            string tmp = BarCode.Substring(0, 8);

            if (OrderName.IndexOf(tmp) >= 0)
            {
                result = MachineLists.外销;
            }
            return(result);
        }
        /// <summary>
        /// 直接判断是否外销
        /// </summary>
        /// <param name="BarCode"></param>
        /// <returns></returns>
        public static MachineLists GetMachine(string BarCode)
        {
            //内销:211270 0059G 6A23 090 0033
            //外销:01020304 0059G 6A23 90 033
            MachineLists result = MachineLists.内销;

            if (!CheckBar(BarCode))
            {
                return(result);
            }
            string tmp = BarCode.Substring(12, 1);

            try
            {
                int month = Convert.ToInt16(tmp, 16);
                if (month <= 0 || month > 12)
                {
                    return(MachineLists.外销);
                }
            }
            catch
            { return(MachineLists.外销); }

            tmp = BarCode.Substring(13, 2);
            try
            {
                int day = int.Parse(tmp);
                if (day <= 0 || day > 31)
                {
                    return(MachineLists.外销);
                }
            }
            catch
            { return(MachineLists.外销); }
            return(result);
        }