Ejemplo n.º 1
0
        /// <summary>
        /// 根据Id获取一行所有的信息(未测试)
        /// 历史记录表
        /// </summary>
        /// <param name="id">Id</param>
        /// <returns>null 代表没有此行或者数据收到损坏</returns>
        public HistoryModel GetHistoryTotalRecord(int id)
        {
            HistoryModel record = new HistoryModel();

            //连接数据库
            using (SQLiteConnection sqlConnect = new SQLiteConnection(ConnectingString))
            {
                sqlConnect.Open();

                String        commandString = String.Format("SELECT * FROM " + HistoryTableName + " WHERE Id='{0}'", id);
                SQLiteCommand command       = sqlConnect.CreateCommand();
                command.CommandText = commandString;

                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    if (reader.Read())
                    {
                        try
                        {
                            //读取所有的信息
                            record.Id          = id;
                            record.StartWork   = new HParaModel(reader["StartWork"].ToString());
                            record.IdlingWork  = new HParaModel(reader["IdlingWork"].ToString());
                            record.IdlingBreak = new HParaModel(reader["IdlingBreak"].ToString());
                            record.ReviseBegin = new HParaModel(reader["ReviseBegin"].ToString());
                            record.ReviseWork  = new HParaModel(reader["ReviseWork"].ToString());
                            record.ReviseEnd   = new HParaModel(reader["ReviseEnd"].ToString());
                            record.DemWork     = new HParaModel(reader["DemWork"].ToString());
                            record.AdjWork     = new HParaModel(reader["AdjWork"].ToString());
                            record.HighBreak   = new HParaModel(reader["HighBreak"].ToString());
                            record.Tem         = new RangeValue(reader["Tem"].ToString());
                            record.EquCode     = reader["EquCode"].ToString();

                            record.EquType = reader["EquType"].ToString();
                            record.HDate   = reader["HDate"].ToString();
                            record.HTime   = reader["HTime"].ToString();
                            record.IsPass  = bool.Parse(reader["IsPass"].ToString());
                        }
                        catch (Exception)
                        {
                            record = null;
                        }
                    }
                    else
                    {
                        record = null;
                    }
                }

                return(record);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取所有的简短信息(未测试)
        /// 历史记录表
        /// </summary>
        /// <returns></returns>
        public List <HistoryModel> GetHistoryAllShortRecord()
        {
            List <HistoryModel> datas = new List <HistoryModel>();

            //连接数据库
            using (SQLiteConnection sqlConnect = new SQLiteConnection(ConnectingString))
            {
                String commandString = "SELECT Id,EquType,HDate,HTime,IsPass FROM " + HistoryTableName;

                sqlConnect.Open();

                SQLiteCommand command = sqlConnect.CreateCommand();
                command.CommandText = commandString;


                using (SQLiteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        HistoryModel record = new HistoryModel();

                        try
                        {
                            //获取用于显示的简短数据
                            record.Id      = int.Parse(reader["Id"].ToString());
                            record.EquType = reader["EquType"].ToString();
                            record.HDate   = reader["HDate"].ToString();
                            record.HTime   = reader["HTime"].ToString();
                            record.IsPass  = bool.Parse(reader["IsPass"].ToString());
                            datas.Add(record);
                        }
                        catch (Exception e)
                        {
                        }
                    }
                }

                return(datas);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 插入一条新的记录(未测试)(插入可行,但未检查完整性)
        /// 历史记录表
        /// </summary>
        /// <param name="model">需要添加的新模型</param>
        /// <returns>插入表中自动生成的Id,-1代表失败</returns>
        public int AddHistoryRecord(HistoryModel model)
        {
            int    id  = -1;
            string sql = string.Format("Insert Into " + HistoryTableName +
                                       "(StartWork,IdlingWork, IdlingBreak, ReviseBegin,ReviseWork, ReviseEnd,DemWork,AdjWork,HighBreak,Tem,EquCode,EquType,HDate,HTime,IsPass) Values" +
                                       "('{0}', '{1}', '{2}', '{3}','{4}', '{5}', '{6}', '{7}','{8}', '{9}','{10}','{11}','{12}','{13}' , '{14}')",
                                       model.StartWork, model.IdlingWork, model.IdlingBreak, model.ReviseBegin, model.ReviseWork, model.ReviseEnd, model.DemWork,
                                       model.AdjWork, model.HighBreak, model.Tem, model.EquCode, /*model.IconHex,*/ model.EquType, model.HDate, model.HTime, model.IsPass.ToString());

            //连接数据库
            using (SQLiteConnection sqlConnect = new SQLiteConnection(ConnectingString))
            {
                //打开连接
                sqlConnect.Open();

                SQLiteCommand command = sqlConnect.CreateCommand();
                command.CommandText = sql;

                //如果成功插入则代表成功
                if (command.ExecuteNonQuery() == 1)
                {
                    String getIdCommandString = "SELECT last_insert_rowid() FROM " + HistoryTableName;

                    SQLiteCommand getIdCommand = sqlConnect.CreateCommand();
                    getIdCommand.CommandText = getIdCommandString;

                    //读取刚刚插入的ID,赋值给模型
                    using (SQLiteDataReader reader = getIdCommand.ExecuteReader())
                    {
                        reader.Read();
                        id = reader.GetInt32(0);
                    }
                }
            }

            return(id);
        }
        /// <summary>
        /// 历史测试记录是否符合要求
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public bool IsMatchRequire(HistoryModel model)
        {
            if (StartWork != null)
            {
                if (!StartWork.IsMatchTheRequire(model.StartWork))
                {
                    return(false);
                }
            }


            if (IdlingWork != null)
            {
                if (!IdlingWork.IsMatchTheRequire(model.IdlingWork))
                {
                    return(false);
                }
            }

            if (IdlingBreak != null)
            {
                if (!IdlingBreak.IsMatchTheRequire(model.IdlingBreak))
                {
                    return(false);
                }
            }

            if (ReviseBegin != null)
            {
                if (!ReviseBegin.IsMatchTheRequire(model.ReviseBegin))
                {
                    return(false);
                }
            }

            if (ReviseWork != null)
            {
                if (!ReviseWork.IsMatchTheRequire(model.ReviseWork))
                {
                    return(false);
                }
            }

            if (ReviseEnd != null)
            {
                if (!ReviseEnd.IsMatchTheRequire(model.ReviseEnd))
                {
                    return(false);
                }
            }

            if (DemWork != null)
            {
                if (!DemWork.IsMatchTheRequire(model.DemWork))
                {
                    return(false);
                }
            }

            if (AdjWork != null)
            {
                if (!AdjWork.IsMatchTheRequire(model.AdjWork))
                {
                    return(false);
                }
            }

            if (HighBreak != null)
            {
                if (!HighBreak.IsMatchTheRequire(model.HighBreak))
                {
                    return(false);
                }
            }

            if (Tem != null)
            {
                if (!Tem.IsInRange(model.Tem))
                {
                    return(false);
                }
            }

            return(true);
        }