using System;
using System.Data;
using System.Text;
using System.Windows.Forms;
using UAS_LabelMachine.Entity;
using UAS_LabelMachine.PublicMethod;
namespace UAS_LabelMachine
{
public partial class CustomerRule : Form
{
AutoSizeFormClass asc = new AutoSizeFormClass();
DataHelper dh;
StringBuilder sql = new StringBuilder();
DataTable dt;
string CUCODE = "";
public CustomerRule()
{
InitializeComponent();
}
private void CustomerRule_Load(object sender, EventArgs e)
{
asc.controllInitializeSize(this);
dh = SystemInf.dh;
dt = (DataTable)dh.ExecuteSql("select cu_name,cu_code from customer where rownum<500 and cu_auditstatuscode<>'DISABLE'", "select");
for (int i = 0; i < dt.Rows.Count; i++)
{
TreeNode node = new TreeNode(dt.Rows[i]["cu_name"].ToString());
node.Tag = dt.Rows[i]["cu_code"].ToString();
CustomerTreeView.Nodes.Add(node);
}
}
private void CustomerRule_SizeChanged(object sender, EventArgs e)
{
asc.controlAutoSize(this);
}
private void CustomerTreeView_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
{
//点中根节点的时候查询品牌下的采集方案
if (e.Node.Level == 0)
{
CUCODE = e.Node.Tag.ToString();
sql.Clear();
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");
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 + "'");
dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
if (dt.Rows.Count > 0)
{
BaseUtil.SetFormValue(this.Controls, dt);
switch (dt.Rows[0]["cu_print_custprodmatchmodel"].ToString())
{
case "Equal":
Equal.Checked = true;
break;
case "Expression":
Expression.Checked = true;
break;
default:
break;
}
switch (dt.Rows[0]["cu_print_recheck"].ToString())
{
case "BR":
BarcodeAndSpec.Checked = true;
break;
case "CP":
CustProdAndSpec.Checked = true;
break;
default:
break;
}
}
}
}
private void ButtonSaveScanGroup_Click(object sender, EventArgs e)
{
sql.Clear();
sql.Append("update customer set cu_print_midlotno='" + (cu_print_midlotno.Checked ? -1 : 0) + "',");
sql.Append("cu_print_midspec='" + (cu_print_midspec.Checked ? -1 : 0) + "',");
sql.Append("cu_print_midpo='" + (cu_print_midpo.Checked ? -1 : 0) + "',");
sql.Append("cu_print_midprod='" + (cu_print_midprod.Checked ? -1 : 0) + "',");
sql.Append("cu_print_middc='" + (cu_print_middc.Checked ? -1 : 0) + "',");
sql.Append("cu_print_outdc='" + (cu_print_outdc.Checked ? -1 : 0) + "',");
sql.Append("cu_print_outlotno='" + (cu_print_outlotno.Checked ? -1 : 0) + "',");
sql.Append("cu_print_outspec='" + (cu_print_outspec.Checked ? -1 : 0) + "',");
sql.Append("cu_print_outpo='" + (cu_print_outpo.Checked ? -1 : 0) + "',");
sql.Append("cu_print_outprod='" + (cu_print_outprod.Checked ? -1 : 0) + "',");
sql.Append("cu_print_checkonly='" + (cu_print_checkonly.Checked ? -1 : 0) + "',");
sql.Append("cu_print_papercount='" + cu_print_papercount.Value + "',");
sql.Append("cu_print_custprodmatchmodel='" + (Equal.Checked ? "Equal" : "Expression") + "',");
sql.Append("cu_print_recheck='" + (CustProdAndSpec.Checked ? "CP" : "BR") + "',");
sql.Append("cu_print_checkdatecode='" + (cu_print_checkdatecode.Checked ? -1 : 0) + "',");
sql.Append("cu_print_dateformat='" + cu_print_dateformat.Text + "',");
sql.Append("cu_print_limiteddate=" + cu_print_limiteddate.Value + ",");
sql.Append("cu_print_regexpression=:cu_print_regexpression where cu_code='" + CUCODE + "'");
dh.ExecuteSql(sql.ToString(), "update", cu_print_regexpression.Text);
MessageBox.Show("保存成功!", "提示");
}
///
/// 模糊搜索功能
///
///
///
private void Brand_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
{
if (Customer.Text != "")
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");
else
dt = (DataTable)dh.ExecuteSql("select cu_name,cu_code from customer where rownum<500 and cu_auditstatuscode<>'DISABLE'", "select");
CustomerTreeView.Nodes.Clear();
for (int i = 0; i < dt.Rows.Count; i++)
{
TreeNode node = new TreeNode(dt.Rows[i]["cu_name"].ToString());
node.Tag = dt.Rows[i]["cu_code"].ToString();
CustomerTreeView.Nodes.Add(node);
}
}
}
private void Equal_CheckedChanged(object sender, EventArgs e)
{
if (Equal.Checked)
cu_print_regexpression.Enabled = false;
else
cu_print_regexpression.Enabled = true;
}
private void DateFormat_CheckedChanged(object sender, EventArgs e)
{
Control ctl = sender as Control;
FormatExample1.Text = Convert.ToDateTime(FormatExample.Text).ToString(ctl.Text);
}
}
}