| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- 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 UAS_Tools_HY.PublicMethods;
- namespace UAS_Tools_HY
- {
- public partial class RulesList : Form
- {
- public RulesList(string type,string userName)
- {
- InitializeComponent();
- UserName = userName;
- TYPE = type;
- }
- public RulesList(string type, string ruleId, string userName)
- {
- InitializeComponent();
- UserName = userName;
- RULE_ID = ruleId;
- TYPE = type;
- }
-
- string TYPE,RULE_ID,UserName;
- DataTable dt;
- private void RulesList_Load(object sender, EventArgs e)
- {
- dt = ConnectDB.ExecuteSelect($"SELECT * FROM g_packing_rules WHERE rule_id = '{RULE_ID}'");
- if(dt.Rows.Count > 0)
- {
- textBox1.Text = dt.Rows[0]["RULE_NAME"].ToString();
- textBox2.Text = dt.Rows[0]["RULE_VALUE"].ToString();
- textBox3.Text = dt.Rows[0]["RELE_REMARK"].ToString();
- textBox1.Focus();
- textBox1.SelectAll();
- }
- }
- private void Submit_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(textBox1.Text))
- {
- MessageBox.Show("请输入规则名称", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- if (string.IsNullOrEmpty(textBox2.Text))
- {
- MessageBox.Show("请输入规则内容", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- return;
- }
- string pattern = @"\{([^}]*)\}";
- var matches = Regex.Matches(textBox2.Text.Trim(), pattern);
- int totalLen = textBox2.Text.Trim().Length;
- int initLen = 0;
- int isContain = 0;
- foreach (Match match in matches)
- {
- initLen += match.Length;
- if (match.Value.Contains(",")){
- isContain += 1;
- }
- else
- {
- isContain += match.Groups[1].Value.Length;
- }
- }
- int otherLeng = totalLen - initLen + isContain;
- if(TYPE == "Add")
- {
- int insertCount = ConnectDB.ExecuteInsert($@"INSERT INTO g_packing_rules (rule_id, rule_name, rule_value, rule_length, rele_remark, update_time, update_user) VALUES
- (RULEID_SEQ.nextval, '{textBox1.Text.Trim()}', '{textBox2.Text.Trim()}', '{otherLeng}', '{textBox3.Text.Trim()}', sysdate, '{UserName}')");
- }
- else if(TYPE == "Modify")
- {
- int updateCount = ConnectDB.ExecuteUpdate($@"UPDATE g_packing_rules SET rule_name = '{textBox1.Text.Trim()}',rule_value = '{textBox2.Text.Trim()}',
- rule_length = '{otherLeng}',rele_remark = '{textBox3.Text.Trim()}',update_time = sysdate, update_user = '{UserName}' WHERE rule_id = '{RULE_ID}'");
- }
-
- this.DialogResult = DialogResult.OK;
- this.Close();
- }
- }
- }
|