| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- 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, string account)
- {
- InitializeComponent();
- UserName = userName;
- TYPE = type;
- Account = account;
- }
- public RulesList(string type, string ruleId, string userName, string account)
- {
- InitializeComponent();
- UserName = userName;
- RULE_ID = ruleId;
- TYPE = type;
- Account = account;
- }
-
- string TYPE,RULE_ID,UserName,Account;
- DataTable dt;
- private void RulesList_Load(object sender, EventArgs e)
- {
- dt = ConnectDB.ExecuteSelect($"SELECT * FROM employee WHERE em_code = '{Account}' AND em_checkrule = 1");
- if (dt.Rows.Count == 0)
- {
- MessageBox.Show("该账户没有操作核对规则权限", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
- this.DialogResult = DialogResult.No;
- this.Close();
- return;
- }
- 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();
- }
- }
- }
|