CustomerRule.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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_dateformat,nvl(cu_print_limiteddate,0)cu_print_limiteddate,cu_print_checkdatecode,cu_print_recheck,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. switch (dt.Rows[0]["cu_print_recheck"].ToString())
  61. {
  62. case "BR":
  63. BarcodeAndSpec.Checked = true;
  64. break;
  65. case "CP":
  66. CustProdAndSpec.Checked = true;
  67. break;
  68. default:
  69. break;
  70. }
  71. }
  72. }
  73. }
  74. private void ButtonSaveScanGroup_Click(object sender, EventArgs e)
  75. {
  76. sql.Clear();
  77. sql.Append("update customer set cu_print_midlotno='" + (cu_print_midlotno.Checked ? -1 : 0) + "',");
  78. sql.Append("cu_print_midspec='" + (cu_print_midspec.Checked ? -1 : 0) + "',");
  79. sql.Append("cu_print_midpo='" + (cu_print_midpo.Checked ? -1 : 0) + "',");
  80. sql.Append("cu_print_midprod='" + (cu_print_midprod.Checked ? -1 : 0) + "',");
  81. sql.Append("cu_print_middc='" + (cu_print_middc.Checked ? -1 : 0) + "',");
  82. sql.Append("cu_print_outdc='" + (cu_print_outdc.Checked ? -1 : 0) + "',");
  83. sql.Append("cu_print_outlotno='" + (cu_print_outlotno.Checked ? -1 : 0) + "',");
  84. sql.Append("cu_print_outspec='" + (cu_print_outspec.Checked ? -1 : 0) + "',");
  85. sql.Append("cu_print_outpo='" + (cu_print_outpo.Checked ? -1 : 0) + "',");
  86. sql.Append("cu_print_outprod='" + (cu_print_outprod.Checked ? -1 : 0) + "',");
  87. sql.Append("cu_print_checkonly='" + (cu_print_checkonly.Checked ? -1 : 0) + "',");
  88. sql.Append("cu_print_papercount='" + cu_print_papercount.Value + "',");
  89. sql.Append("cu_print_custprodmatchmodel='" + (Equal.Checked ? "Equal" : "Expression") + "',");
  90. sql.Append("cu_print_recheck='" + (CustProdAndSpec.Checked ? "CP" : "BR") + "',");
  91. sql.Append("cu_print_checkdatecode='" + (cu_print_checkdatecode.Checked ? -1 : 0) + "',");
  92. sql.Append("cu_print_dateformat='" + cu_print_dateformat.Text + "',");
  93. sql.Append("cu_print_limiteddate=" + cu_print_limiteddate.Value + ",");
  94. sql.Append("cu_print_regexpression=:cu_print_regexpression where cu_code='" + CUCODE + "'");
  95. dh.ExecuteSql(sql.ToString(), "update", cu_print_regexpression.Text);
  96. MessageBox.Show("保存成功!", "提示");
  97. }
  98. /// <summary>
  99. /// 模糊搜索功能
  100. /// </summary>
  101. /// <param name="sender"></param>
  102. /// <param name="e"></param>
  103. private void Brand_KeyDown(object sender, KeyEventArgs e)
  104. {
  105. if (e.KeyCode == Keys.Enter)
  106. {
  107. if (Customer.Text != "")
  108. 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");
  109. else
  110. dt = (DataTable)dh.ExecuteSql("select cu_name,cu_code from customer where rownum<500 and cu_auditstatuscode<>'DISABLE'", "select");
  111. CustomerTreeView.Nodes.Clear();
  112. for (int i = 0; i < dt.Rows.Count; i++)
  113. {
  114. TreeNode node = new TreeNode(dt.Rows[i]["cu_name"].ToString());
  115. node.Tag = dt.Rows[i]["cu_code"].ToString();
  116. CustomerTreeView.Nodes.Add(node);
  117. }
  118. }
  119. }
  120. private void Equal_CheckedChanged(object sender, EventArgs e)
  121. {
  122. if (Equal.Checked)
  123. cu_print_regexpression.Enabled = false;
  124. else
  125. cu_print_regexpression.Enabled = true;
  126. }
  127. private void DateFormat_CheckedChanged(object sender, EventArgs e)
  128. {
  129. Control ctl = sender as Control;
  130. FormatExample1.Text = Convert.ToDateTime(FormatExample.Text).ToString(ctl.Text);
  131. }
  132. }
  133. }