PowerSetting.cs 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using System.Windows.Forms;
  5. using UAS_LabelMachine.Entity;
  6. namespace UAS_LabelMachine
  7. {
  8. public partial class PowerSetting : Form
  9. {
  10. public PowerSetting()
  11. {
  12. InitializeComponent();
  13. }
  14. DataHelper dh;
  15. DataTable dt;
  16. string condition = "";
  17. private void PowerSetting_Load(object sender, EventArgs e)
  18. {
  19. dh = SystemInf.dh;
  20. LoadData();
  21. ChooseAll.ChooseAll(PowerSetDGV);
  22. }
  23. private void AddRow_Click(object sender, EventArgs e)
  24. {
  25. if (PowerSetDGV.DataSource as DataTable != null)
  26. (PowerSetDGV.DataSource as DataTable).Rows.Add();
  27. }
  28. private void SaveGrid_Click(object sender, EventArgs e)
  29. {
  30. dt = (DataTable)PowerSetDGV.DataSource;
  31. string sql = "insert into labelprintpower(lpp_id,lpp_emcode,LPP_CLEANDETAIL,LPP_GENCODE,LPP_LABELMATAIN,LPP_SAVEDETAIL,LPP_COLLECTSTRATEGY,";
  32. sql += "LPP_ALLCOLLECT) values(labelprintpower_seq.nextval,:lpp_emcode,:LPP_CLEANDETAIL,:LPP_GENCODE,:LPP_LABELMATAIN,:LPP_SAVEDETAIL,";
  33. sql += ":LPP_COLLECTSTRATEGY,:LPP_ALLCOLLECT)";
  34. dh.UpDateTableByCondition(dt.GetChanges(), "labelprintpower", "lpp_id", sql.ToLower());
  35. 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");
  36. LoadData();
  37. }
  38. private void Delete_Click(object sender, EventArgs e)
  39. {
  40. dt = (DataTable)PowerSetDGV.DataSource;
  41. List<string> deleteid = new List<string>();
  42. for (int i = 0; i < dt.Rows.Count; i++)
  43. {
  44. if (PowerSetDGV.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True")
  45. {
  46. deleteid.Add(PowerSetDGV.Rows[i].Cells["lpp_id"].Value.ToString());
  47. }
  48. }
  49. if (deleteid.ToArray().Length > 0)
  50. {
  51. dh.DeleteDataByID("labelprintpower", "lpp_id", deleteid.ToArray());
  52. LoadData();
  53. }
  54. }
  55. private void LoadData()
  56. {
  57. 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;
  58. dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
  59. BaseUtil.FillDgvWithDataTable(PowerSetDGV, dt);
  60. }
  61. private void Screen_Click(object sender, EventArgs e)
  62. {
  63. condition = BaseUtil.GetScreenSqlCondition(em_code, em_name);
  64. LoadData();
  65. }
  66. }
  67. }