C3031
2026-03-06 8db52bc296f662691a17aabeeabebd713e3b576d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
 
using LB_SmartVision.SQL;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using ReaLTaiizor.Forms;
using RJCP.IO.Ports;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
 
 
namespace LB_SmartVision.Forms
{
    public partial class CreateProductForm : Form
    {
        public List<string> listDatabaseName { get; set; }
        public bool bCreate = false;
 
        public CreateProductForm(List<string> listDatabaseNam = null)
        {
            InitializeComponent();
            // 禁止修改窗口大小
            //this.FormBorderStyle = FormBorderStyle.FixedDialog;
 
            uiButtonCreate.Enabled = false;
            if (listDatabaseNam == null)
                listDatabaseNam = LB_SqlCommand.GetUserDatabases();
 
            this.listDatabaseName = listDatabaseNam;
        }
 
 
        private void uiButtonTest_Click(object sender, EventArgs e)
        {
            uiButtonCreate.Enabled = false;
 
            LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
            List<string> lstProduct = (Products.Split(',')).ToList();
            if (lstProduct.Contains(uiTextBoxProductName.Text))
                MessageBox.Show($"产品[{uiTextBoxProductName.Text}]已存在!", "异常");
            else
                uiButtonCreate.Enabled = true;
        }
 
        private void uiButtonCreate_Click(object sender, EventArgs e)
        {
            if (LB_SmartVision.Tool.Tool.CopyDirectory(Path.Combine(GlobalVar.strApplicationPath + "所有产品\\", GlobalVar.strProductName)
                , Path.Combine(GlobalVar.strApplicationPath + "所有产品\\", uiTextBoxProductName.Text)))
            {
                LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
                List<string> lstProduct = (Products.Split(',')).ToList();
                lstProduct.Add(uiTextBoxProductName.Text);
                LB_SmartVision.Tool.Tool.WriteConfig("产品列表", string.Join(",", lstProduct));
                MessageBox.Show($"创建产品[{uiTextBoxProductName.Text}]成功!");
                this.Close();
            }
        }
 
        private void uiButtonCancel_Click(object sender, EventArgs e)
        {
            bCreate = false;
            this.Close();
        }
 
        private void uiComboBoxProducts_MouseClick(object sender, MouseEventArgs e)
        {
            uiButtonCreate.Enabled = false;
 
            uiComboBoxProducts.Items.Clear();
            uiComboBoxProducts.Items.Add("无");
 
            LB_SmartVision.Tool.Tool.ReadStringConfig("产品列表", out string Products);
            List<string> lstProduct = (Products.Split(',')).ToList();
            foreach (string DatabaseName in lstProduct)
                uiComboBoxProducts.Items.Add(DatabaseName);
        }
 
        private void uiTextBoxProductName_TextChanged(object sender, EventArgs e)
        {
            uiButtonCreate.Enabled = false;
        }
    }
}