123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Text;
- using System.Windows.Forms;
- using UAS_LabelMachine.Entity;
- namespace UAS_LabelMachine
- {
- public partial class PowerSetting : Form
- {
- public PowerSetting()
- {
- InitializeComponent();
- }
- DataHelper dh;
- DataTable dt;
- string condition = "";
- private void PowerSetting_Load(object sender, EventArgs e)
- {
- dh = SystemInf.dh;
- LoadData();
- }
- private void SaveGrid_Click(object sender, EventArgs e)
- {
- dt = ((DataTable)PowerSetDGV.DataSource).GetChanges();
- StringBuilder sql = new StringBuilder();
- List<string> SQLS = new List<string>();
- for (int i = 0; i < dt.Rows.Count; i++)
- {
- sql.Clear();
- sql.Append("MERGE INTO labelprintpower alias1 USING (select '" + dt.Rows[i]["em_code"].ToString() + "' em_code from dual) alias2 ");
- sql.Append("ON (alias1.lpp_emcode=alias2.em_code) WHEN MATCHED THEN UPDATE SET lpp_manual = '" + dt.Rows[i]["lpp_manual"].ToString() + "', ");
- sql.Append("lpp_cleandetail = '" + dt.Rows[i]["lpp_cleandetail"].ToString() + "' WHEN NOT MATCHED THEN INSERT (lpp_id,lpp_emcode,lpp_manual) VALUES (labelprintpower_seq.nextval,");
- sql.Append(" '" + dt.Rows[i]["em_code"].ToString() + "', '" + dt.Rows[i]["lpp_manual"].ToString() + "')");
- SQLS.Add(sql.ToString());
- }
- dh.ExecuteSQLTran(SQLS.ToArray());
- LoadData();
- }
- private void LoadData()
- {
- string sql = "select em_code,em_name,lpp_id,lpp_emcode,lpp_manual,lpp_cleandetail from employee left join labelprintpower on em_code = lpp_emcode " + condition;
- dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
- BaseUtil.FillDgvWithDataTable(PowerSetDGV, dt);
- }
- private void Screen_Click(object sender, EventArgs e)
- {
- condition = BaseUtil.GetScreenSqlCondition(em_code, em_name);
- LoadData();
- }
- }
- }
|