using System; using System.Collections.Generic; using System.Data; 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(); ChooseAll.ChooseAll(PowerSetDGV); } private void AddRow_Click(object sender, EventArgs e) { if (PowerSetDGV.DataSource as DataTable != null) (PowerSetDGV.DataSource as DataTable).Rows.Add(); } private void SaveGrid_Click(object sender, EventArgs e) { dt = (DataTable)PowerSetDGV.DataSource; string sql = "insert into labelprintpower(lpp_id,lpp_emcode,LPP_CLEANDETAIL,LPP_GENCODE,LPP_LABELMATAIN,LPP_SAVEDETAIL,LPP_COLLECTSTRATEGY,"; sql += "LPP_ALLCOLLECT) values(labelprintpower_seq.nextval,:lpp_emcode,:LPP_CLEANDETAIL,:LPP_GENCODE,:LPP_LABELMATAIN,:LPP_SAVEDETAIL,"; sql += ":LPP_COLLECTSTRATEGY,:LPP_ALLCOLLECT)"; dh.UpDateTableByCondition(dt.GetChanges(), "labelprintpower", "lpp_id", sql.ToLower()); dh.ExecuteSql("insert into MessageLog (ml_id,ml_date,ml_man,ml_content,code) select MessageLog_seq.nextval,sysdate,'"+User.UserName+"','修改打印权限','LabelPrint' from dual", "insert"); LoadData(); } private void Delete_Click(object sender, EventArgs e) { dt = (DataTable)PowerSetDGV.DataSource; List deleteid = new List(); for (int i = 0; i < dt.Rows.Count; i++) { if (PowerSetDGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True") { deleteid.Add(PowerSetDGV.Rows[i].Cells["lpp_id"].Value.ToString()); } } if (deleteid.ToArray().Length > 0) { dh.DeleteDataByID("labelprintpower", "lpp_id", deleteid.ToArray()); LoadData(); } } private void LoadData() { string sql = " select lpp_emcode,em_name,lpp_id,LPP_CLEANDETAIL,LPP_GENCODE,LPP_LABELMATAIN,LPP_SAVEDETAIL,LPP_COLLECTSTRATEGY,LPP_ALLCOLLECT from labelprintpower left join employee 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(); } } }