示例#1
0
        /// <summary>
        /// 按条码查询工件信息
        /// </summary>
        /// <param name="workId"></param>
        /// <param name="MoList"></param>
        /// <returns></returns>
        public bool QueryData(Int32 tab, ref List <ModalWeightInfoTable> MoList)
        {
            bool bRet = true;

            try
            {
                DataSet           dt;
                SQLiteParameter[] parameters =
                {
                    new SQLiteParameter("@Tab", DbType.Int32)
                };
                parameters[0].Value = tab;
                dt = SQLiteHelper.Query(SQL_SELECT_ONE, parameters);
                if (dt != null)
                {
                    if (MoList == null)
                    {
                        MoList = new List <ModalWeightInfoTable>();
                    }
                    foreach (DataRow dr in dt.Tables[0].Rows)
                    {
                        ModalWeightInfoTable tmp = new ModalWeightInfoTable();
                        tmp.Row2Model(dr);
                        MoList.Add(tmp);
                    }
                }
            }
            catch (Exception ex)
            {
                Util.LogManager.Logger.Error("查询记录是出现错误,错误为{0}", ex.ToString());
                bRet = false;
            }
            return(bRet);
        }
示例#2
0
        public bool QueryData(ref List <ModalWeightInfoTable> MoList)
        {
            bool bRet = true;

            try
            {
                DataSet dt = SQLiteHelper.Query(SQL_SELECT_ALL);
                if (dt != null)
                {
                    if (MoList == null)
                    {
                        MoList = new List <ModalWeightInfoTable>();
                    }
                    foreach (DataRow dr in dt.Tables[0].Rows)
                    {
                        ModalWeightInfoTable tmp = new ModalWeightInfoTable();
                        tmp.Row2Model(dr);
                        MoList.Add(tmp);
                    }
                }
            }
            catch (Exception ex)
            {
                Util.LogManager.Logger.Error("查询记录是出现错误,错误为{0}", ex.ToString());
                bRet = false;
            }
            return(bRet);
        }
示例#3
0
        /// <summary>
        /// 按时间查询工件信息
        /// </summary>
        /// <param name="workId"></param>
        /// <param name="MoList"></param>
        /// <returns></returns>
        public bool QueryData(string time1, string time2, ref List <ModalWeightInfoTable> MoList)
        {
            bool bRet = true;

            try
            {
                DataSet dt;
                string  sql = string.Format("{0}  where Time BETWEEN  '{1}'  AND '{2}'", SQL_SELECT, time1, time2);
                dt = SQLiteHelper.Query(sql);
                if (dt != null)
                {
                    if (MoList == null)
                    {
                        MoList = new List <ModalWeightInfoTable>();
                    }

                    foreach (DataRow dr in dt.Tables[0].Rows)
                    {
                        ModalWeightInfoTable tmp = new ModalWeightInfoTable();
                        tmp.Row2Model(dr);
                        MoList.Add(tmp);
                    }
                }
            }
            catch (Exception ex)
            {
                Util.LogManager.Logger.Error("查询记录是出现错误,错误为{0}", ex.ToString());
                bRet = false;
            }
            return(bRet);
        }
示例#4
0
        /// <summary>
        /// 克隆函数
        /// </summary>
        public object Clone()
        {
            ModalWeightInfoTable ds = new ModalWeightInfoTable();

            ds.Number     = Number;
            ds.BodyWeight = BodyWeight;
            ds.Time       = Time;
            ds.Tab        = Tab;
            return(ds);
        }
示例#5
0
        /// <summary>
        /// 删除一个
        /// </summary>
        /// <returns></returns>
        public int DeleteData(ModalWeightInfoTable Mo)
        {
            int iRet = 0;

            try
            {
                SQLiteParameter[] parameters = { new SQLiteParameter("@Number", DbType.Int32),
                                                 new SQLiteParameter("@Time",   DbType.String) };
                parameters[0].Value = Mo.Number;
                parameters[1].Value = Mo.Time;

                iRet = SQLiteHelper.ExecuteSql(SQL_DELETE_ONE, parameters);
            }
            catch (Exception ex)
            {
                Util.LogManager.Logger.Error("删除数据出现错误,错误为{0}", ex.ToString());
                iRet = 0;
            }
            return(iRet);
        }
示例#6
0
        /// <summary>
        /// 按条件查询条码信息
        /// </summary>
        /// <param name="condition"></param>
        /// <param name="MoList"></param>
        /// <returns></returns>
        public int AddData(ModalWeightInfoTable Mo)
        {
            int iRet = 0;

            try
            {
                SQLiteParameter[] parameters = { new SQLiteParameter("@Number",     DbType.Int32),
                                                 new SQLiteParameter("@BodyWeight", DbType.String),
                                                 new SQLiteParameter("@Time",       DbType.String),
                                                 new SQLiteParameter("@Tab",        DbType.Int32) };
                parameters[0].Value = Mo.Number;
                parameters[1].Value = Mo.BodyWeight;
                parameters[2].Value = Mo.Time;
                parameters[3].Value = Mo.Tab;

                iRet = SQLiteHelper.ExecuteSql(SQL_INSERT, parameters);
            }
            catch (Exception ex)
            {
                Util.LogManager.Logger.Error("插入数据库出现错误,错误为{0}", ex.ToString());
                iRet = 0;
            }
            return(iRet);
        }
示例#7
0
        private void Receive_Weight(Object sender, tcpCommEventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                ModalWeightInfoTable weightinfo = new ModalWeightInfoTable();
                weightDtaGrid.ItemsSource       = null;
                CacheRece = e.ReceiveMessage;

                weightinfo.Number     = ++number;
                weightinfo.BodyWeight = CacheRece;
                weightinfo.Time       = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                weightinfo.Tab        = 0;
                //WeightList.Add(weightinfo);
                //weightDtaGrid.ItemsSource = null;
                //weightDtaGrid.ItemsSource = WeightList;
                dal.AddData(weightinfo);
                List <ModalWeightInfoTable> templist = new List <ModalWeightInfoTable>();
                dal.QueryData(ref templist);
                weightDtaGrid.ItemsSource = null;
                weightDtaGrid.ItemsSource = templist;
                WeightList.Clear();
                WeightList = templist;
            });
        }
示例#8
0
        private void ElapseSpurtSend(object Sender, ElapsedEventArgs e)
        {
            if (timerBool)
            {
                lock (timerLock)
                {
                    if (timerBool)
                    {
                        timerBool = false;
                        int CurrentCount = 0; //喷码枪的初始值是1

                        string recStr = tcputility.SendAndReceive(String.Format("GET_COUNTER_INFO 1\n"));
                        if (recStr.Contains("ACK-GET_COUNTER_INFO"))
                        {
                            CurrentCount = Convert.ToInt32(recStr.Split(',')[2]);
                        }

                        if (CurrentCount > LastCount) //说明喷码了,或者到了时间间隔跳过了(时间大概20多秒),
                        {
                            List <ModalWeightInfoTable> UnSendList = new List <ModalWeightInfoTable>();
                            dal.QueryData(tab: 0, ref UnSendList);

                            if (UnSendList == null || UnSendList.Count == 0)
                            {
                                return;
                            }

                            ModalWeightInfoTable moWeiht = UnSendList[0];

                            string str = Regex.Match(moWeiht.BodyWeight, @"([0-9].[0-9]{1,})").Value.Replace(".", "");
                            recStr = tcputility.SendAndReceive(String.Format("D{0}{1}\n", str.PadRight(4, '0'), new Random().Next(0, 9)));

                            if (recStr.Contains("ACK-Auto Data Received")) //如果发送成功,记录下来
                            {
                                LastCount = CurrentCount;

                                this.Dispatcher.Invoke(() =>
                                {
                                    dal.UpData(moWeiht.Number, 1);

                                    List <ModalWeightInfoTable> templist = new List <ModalWeightInfoTable>();
                                    dal.QueryData(ref templist);
                                    weightDtaGrid.ItemsSource = null;
                                    weightDtaGrid.ItemsSource = templist;
                                    WeightList.Clear();
                                    WeightList = templist;

                                    SpurtList.Add(new ModalSpurtCodeInfo
                                    {
                                        Counter   = CurrentCount + 1,
                                        SpurtCode = str
                                    });
                                    SpurtDtaGrid.ItemsSource = null;
                                    SpurtDtaGrid.ItemsSource = SpurtList;
                                });
                            }
                            else
                            {
                                AutoDeleteMessageBox Auto = new AutoDeleteMessageBox(); // 自动关闭窗口
                                System.Windows.Forms.MessageBox.Show("发送喷码值失败!", "MessageBox");
                                return;
                            }
                        }
                        timerBool = true;
                    }
                }
            }
        }