CustomerRule.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. using System;
  2. using System.Data;
  3. using System.Text;
  4. using System.Windows.Forms;
  5. using UAS_LabelMachine.Entity;
  6. using UAS_LabelMachine.PublicMethod;
  7. namespace UAS_LabelMachine
  8. {
  9. public partial class CustomerRule : Form
  10. {
  11. AutoSizeFormClass asc = new AutoSizeFormClass();
  12. DataHelper dh;
  13. StringBuilder sql = new StringBuilder();
  14. DataTable dt;
  15. string CUCODE = "";
  16. public CustomerRule()
  17. {
  18. InitializeComponent();
  19. }
  20. private void CustomerRule_Load(object sender, EventArgs e)
  21. {
  22. asc.controllInitializeSize(this);
  23. dh = SystemInf.dh;
  24. dt = (DataTable)dh.ExecuteSql("select cu_name,cu_code from customer where rownum<500 and cu_auditstatuscode<>'DISABLE'", "select");
  25. for (int i = 0; i < dt.Rows.Count; i++)
  26. {
  27. TreeNode node = new TreeNode(dt.Rows[i]["cu_name"].ToString());
  28. node.Tag = dt.Rows[i]["cu_code"].ToString();
  29. CustomerTreeView.Nodes.Add(node);
  30. }
  31. }
  32. private void CustomerRule_SizeChanged(object sender, EventArgs e)
  33. {
  34. asc.controlAutoSize(this);
  35. }
  36. private void CustomerTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
  37. {
  38. //点中根节点的时候查询品牌下的采集方案
  39. if (e.Node.Level == 0)
  40. {
  41. CUCODE = e.Node.Tag.ToString();
  42. sql.Clear();
  43. sql.Append("select cu_print_midlotno,cu_print_midspec,cu_print_midpo,cu_print_midprod,nvl(cu_print_custprodmatchmodel,'Equal')cu_print_custprodmatchmodel,cu_print_outlotno,cu_print_outspec,cu_print_outpo");
  44. sql.Append(",cu_print_outprod,cu_print_checkonly,nvl(cu_print_papercount,0)cu_print_papercount,cu_print_regexpression from customer where cu_code='" + e.Node.Tag + "'");
  45. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  46. if (dt.Rows.Count > 0)
  47. {
  48. BaseUtil.SetFormValue(this.Controls, dt);
  49. switch (dt.Rows[0]["cu_print_custprodmatchmodel"].ToString())
  50. {
  51. case "Equal":
  52. Equal.Checked = true;
  53. break;
  54. case "Expression":
  55. Expression.Checked = true;
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61. }
  62. }
  63. private void ButtonSaveScanGroup_Click(object sender, EventArgs e)
  64. {
  65. sql.Clear();
  66. sql.Append("update customer set cu_print_midlotno='" + (cu_print_midlotno.Checked ? -1 : 0) + "',");
  67. sql.Append("cu_print_midspec='" + (cu_print_midspec.Checked ? -1 : 0) + "',");
  68. sql.Append("cu_print_midpo='" + (cu_print_midpo.Checked ? -1 : 0) + "',");
  69. sql.Append("cu_print_midprod='" + (cu_print_midprod.Checked ? -1 : 0) + "',");
  70. sql.Append("cu_print_outlotno='" + (cu_print_outlotno.Checked ? -1 : 0) + "',");
  71. sql.Append("cu_print_outspec='" + (cu_print_outspec.Checked ? -1 : 0) + "',");
  72. sql.Append("cu_print_outpo='" + (cu_print_outpo.Checked ? -1 : 0) + "',");
  73. sql.Append("cu_print_outprod='" + (cu_print_outprod.Checked ? -1 : 0) + "',");
  74. sql.Append("cu_print_checkonly='" + (cu_print_checkonly.Checked ? -1 : 0) + "',");
  75. sql.Append("cu_print_papercount='" + cu_print_papercount.Value + "',");
  76. sql.Append("cu_print_custprodmatchmodel='" + (Equal.Checked ? "Equal" : "Expression") + "',");
  77. sql.Append("cu_print_regexpression=:cu_print_regexpression where cu_code='" + CUCODE + "'");
  78. dh.ExecuteSql(sql.ToString(), "update", cu_print_regexpression.Text);
  79. MessageBox.Show("保存成功!", "提示");
  80. }
  81. /// <summary>
  82. /// 模糊搜索功能
  83. /// </summary>
  84. /// <param name="sender"></param>
  85. /// <param name="e"></param>
  86. private void Brand_KeyDown(object sender, KeyEventArgs e)
  87. {
  88. if (e.KeyCode == Keys.Enter)
  89. {
  90. if (Customer.Text != "")
  91. dt = (DataTable)dh.ExecuteSql("select cu_name,cu_code from customer where (cu_name like '%" + Customer.Text + "%' or cu_code like '%" + Customer.Text + "%') and cu_auditstatuscode<>'DISABLE'", "select");
  92. else
  93. dt = (DataTable)dh.ExecuteSql("select cu_name,cu_code from customer where rownum<500 and cu_auditstatuscode<>'DISABLE'", "select");
  94. CustomerTreeView.Nodes.Clear();
  95. for (int i = 0; i < dt.Rows.Count; i++)
  96. {
  97. TreeNode node = new TreeNode(dt.Rows[i]["cu_name"].ToString());
  98. node.Tag = dt.Rows[i]["cu_code"].ToString();
  99. CustomerTreeView.Nodes.Add(node);
  100. }
  101. }
  102. }
  103. private void Equal_CheckedChanged(object sender, EventArgs e)
  104. {
  105. if (Equal.Checked)
  106. cu_print_regexpression.Enabled = false;
  107. else
  108. cu_print_regexpression.Enabled = true;
  109. }
  110. }
  111. }