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);
}
}
}
private void ButtonSaveScanGroup_Click(object sender, EventArgs e)
{
sql.Clear();
sql.Append("update customer set 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("where cu_code='" + CUCODE + "'");
dh.ExecuteSql(sql.ToString(), "update");
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)
{
}
private void DateFormat_CheckedChanged(object sender, EventArgs e)
{
Control ctl = sender as Control;
}
}
}