示例#1
0
        // 精确查找
        public List <string>[] PriciseSelect(PlateBO plateBO)
        {
            string plate = plateBO.plate;
            // string plate = "苏K225CA";
            string query = "SELECT * FROM `ocr`.`auto_ocr` WHERE plate='" + plate + "'";

            // 创建list存储数据
            List <string>[] list = new List <string> [7];
            list[0] = new List <string>();
            list[1] = new List <string>();
            list[2] = new List <string>();
            list[3] = new List <string>();
            list[4] = new List <string>();
            list[5] = new List <string>();
            list[6] = new List <string>();

            //Open connection
            if (this.OpenConnection() == true)
            {
                // 创建命令
                MySqlCommand cmd = new MySqlCommand(query, connection);
                // 读取数据
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    list[0].Add(dataReader["id"] + "");
                    list[1].Add(dataReader["plate"] + "");
                    list[2].Add(dataReader["department"] + "");
                    list[3].Add(dataReader["name"] + "");
                    list[4].Add(dataReader["phone"] + "");
                    list[5].Add(dataReader["car_wash"] + "");
                    list[6].Add(dataReader["create_time"] + "");
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(list);
            }
            else
            {
                return(list);
            }
        }
示例#2
0
        public List <string> FuzzySelectOO(PlateBO plateBO)
        {
            string plate = plateBO.plate;
            // string plate = "苏K225CA";
            string query = "SELECT * FROM `ocr`.`auto_ocr` WHERE plate like '%" + plate + "%'";

            // 创建list存储数据
            List <string> list = new List <string>();


            //Open connection
            if (this.OpenConnection() == true)
            {
                // 创建命令
                MySqlCommand cmd = new MySqlCommand(query, connection);
                // 读取数据
                MySqlDataReader dataReader = cmd.ExecuteReader();

                //Read the data and store them in the list
                while (dataReader.Read())
                {
                    string str = dataReader["id"] + ","
                                 + dataReader["plate"] + ","
                                 + dataReader["department"] + ","
                                 + dataReader["name"] + ","
                                 + dataReader["phone"] + ","
                                 + dataReader["car_wash"] + ","
                                 + dataReader["create_time"] + "";
                    string[] strArray = str.Split(',');
                    list.Add(str);
                }

                //close Data Reader
                dataReader.Close();

                //close Connection
                this.CloseConnection();

                //return list to be displayed
                return(list);
            }
            else
            {
                return(list);
            }
        }
示例#3
0
        // UPDATE `ocr`.`auto_ocr` SET `name` = '张进', `phone` = '18952' WHERE `id` = 'af20ca5b-b6bd-415b-a9ba-caadedc83df2'
        public void UpdateCarInfo(PlateBO plateBO)
        {
            string query = "UPDATE `ocr`.`auto_ocr` SET `plate` = '" + plateBO.plate + "', `name` = '" + plateBO.name + "', `phone` = '" + plateBO.phone + "', `department` = '" + plateBO.department + "' WHERE `id` = '" + plateBO.id + "'";

            //Open connection
            if (this.OpenConnection() == true)
            {
                //create mysql command
                MySqlCommand cmd = new MySqlCommand();
                //Assign the query using CommandText
                cmd.CommandText = query;
                //Assign the connection using Connection
                cmd.Connection = connection;

                //Execute query
                cmd.ExecuteNonQuery();

                //close connection
                this.CloseConnection();
            }
        }
示例#4
0
        //Insert statement
        public void Insert(PlateBO plateBO)
        {
            string id         = plateBO.id;
            string plate      = plateBO.plate;
            string department = plateBO.department;
            string name       = plateBO.name;
            string phone      = plateBO.phone;
            int    carWash    = plateBO.carWash;
            // INSERT INTO `ocr`.`auto_ocr`(`id`, `plate`, `department`, `name`, `phone`, `car_wash`) VALUES ('1', '苏K225CA', '云智', '进', '18952594881', 10);
            string query = "INSERT INTO `ocr`.`auto_ocr`(`id`, `plate`, `department`, `name`, `phone`, `car_wash`) VALUES ('" + id + "', '" + plate + "', '" + department + "', '" + name + "', '" + phone + "', " + carWash + ")";

            //open connection
            if (this.OpenConnection() == true)
            {
                //create command and assign the query and connection from the constructor
                MySqlCommand cmd = new MySqlCommand(query, connection);

                //Execute command
                cmd.ExecuteNonQuery();

                //close connection
                this.CloseConnection();
            }
        }