hisence-yolo-detection/HisenceYoloDetection/InsertSqlFrm.cs

199 lines
6.3 KiB
C#
Raw Normal View History

2024-05-31 10:14:57 +08:00
using OpenCvSharp;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using XKRS.Device.SimboVision.SimboHelper;
namespace HisenceYoloDetection
{
public partial class InsertSqlFrm : Form
{
public InsertSqlFrm()
{
InitializeComponent();
}
public SimboObjectDetection simboObjectDetection;
public PaddleOcrModel paddleOcrModel ;
public PaddleOcrModelCountry paddleOcrModelCountry ;
private void TypeBox_TextChanged(object sender, EventArgs e)
{
}
string BarPath = "";
string Cam1OnePath = "";
string Cam1TwoPath = "";
private void InsertBtn_Click(object sender, EventArgs e)
{
try
{
string type = TypeBox.Text;
string OcrBar = OcrBarBox.Text;
string moveX = moveXbox.Text;
string moveY = moveYbox.Text;
string moveZ = moveZbox.Text;
string Detect = DetectBArMatbox.Text;
string movetwoX = moveTwoXbox.Text;
string movetwoY = moveTwoYbox.Text;
string movetwoZ = moveTwoZbox.Text;
if (!Regex.IsMatch(moveX, @"^[0-9]+$"))
{
MessageBox.Show("第一次拍照移动的X只能是数字");
return;
}
if (!Regex.IsMatch(moveY, @"^[0-9]+$"))
{
MessageBox.Show("第一次拍照移动的Y只能是数字");
return;
}
if (!Regex.IsMatch(moveZ, @"^[0-9]+$"))
{
MessageBox.Show("第一次拍照移动的Z只能是数字");
return;
}
if (!Regex.IsMatch(movetwoX, @"^[0-9]+$"))
{
MessageBox.Show("第二次拍照移动的X只能是数字");
return;
}
if (!Regex.IsMatch(movetwoY, @"^[0-9]+$"))
{
MessageBox.Show("第二次拍照移动的Y只能是数字");
return;
}
if (!Regex.IsMatch(movetwoZ, @"^[0-9]+$"))
{
MessageBox.Show("第二次拍照移动的Z只能是数字");
return;
}
if (OcrBar != "" && Detect != "")
{
string sql = "insert into XK_Hisence VALUES('" + type + "','" + OcrBar + "',null,null," + moveX + "," + moveY + "," + moveZ + ",'" + Detect + "',null," + movetwoX + "," + movetwoY + "," + movetwoZ + ")";
SQLiteHelper.ExecuteSql(sql);
}
else
{
MessageBox.Show("插入的数据不能为NULL");
}
}
catch (Exception es)
{
}
}
private void queryALLBtn_Click(object sender, EventArgs e)
{
try
{
DataSet dataSet = SQLiteHelper.Query("select * from XK_Hisence");
InsertDataDgv.DataSource = dataSet.Tables[0];
}
catch (Exception es)
{
}
}
private void QueryoneBtn_Click(object sender, EventArgs e)
{
try
{
string type = TypeBox.Text;
string OcrBar = OcrBarBox.Text;
string moveX = moveXbox.Text;
string moveY = moveYbox.Text;
string moveZ = moveZbox.Text;
string Detect = DetectBArMatbox.Text;
string movetwoX = moveTwoXbox.Text;
string movetwoY = moveTwoYbox.Text;
string movetwoZ = moveTwoZbox.Text;
string sql = "select * from XK_Hisence where type='" + type + "' or OcrBar='" + OcrBar + "'";
DataSet dataSet = SQLiteHelper.Query(sql);
InsertDataDgv.DataSource = dataSet.Tables[0];
}
catch (Exception es)
{
}
}
/// <summary>
/// 打开条码的图片
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void button1_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请打开图片";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fName = openFileDialog.FileName;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
DetectBArMatbox.Text = fName;
BarPath = fName;
}
}
private void OpenDirBtn_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请打开图片";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fName = openFileDialog.FileName;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
Cam1MatCbx.Text = fName;
Cam1OnePath = fName;
}
}
private void OpenTwoDirBtn_Click(object sender, EventArgs e)
{
OpenFileDialog openFileDialog = new OpenFileDialog();
openFileDialog.Title = "请打开图片";
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
string fName = openFileDialog.FileName;
//File fileOpen = new File(fName);
//isFileHaveName = true;
//richTextBox1.Text = fileOpen.ReadFile();
//richTextBox1.AppendText("");
Cam2MatCbx.Text = fName;
Cam1TwoPath = fName;
}
}
}
}