MacStatusBase.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. 
  2. using DllEapEntity;
  3. using DllPubInfo;
  4. using Newtonsoft.Json;
  5. using RabbitMQ.Client;
  6. using System;
  7. using System.Collections;
  8. using System.Collections.Generic;
  9. using System.ComponentModel;
  10. using System.Data;
  11. using System.Drawing;
  12. using System.Linq;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using System.Windows.Forms;
  16. namespace DllXqManager
  17. {
  18. public partial class MacStatusBase : Form
  19. {
  20. private MacStatus CurrEntity = null;
  21. public delegate void closeForm();
  22. public delegate void AddRow(MacStatus id);
  23. public event closeForm eventcloseform = null;
  24. public event AddRow eventaddrow = null;
  25. private string StatusMqName = "";
  26. public MacStatusBase(MacStatus id)
  27. {
  28. InitializeComponent();
  29. SetCurrID(id);
  30. }
  31. public void SetCurrID(MacStatus id)
  32. {
  33. InitForm(id);
  34. }
  35. private void InitForm(MacStatus id)
  36. {
  37. CurrEntity = id;
  38. if (CurrEntity == null)
  39. {
  40. CurrEntity = new MacStatus();
  41. }
  42. //用实体的值去赋值界面控件显示的值
  43. string errorinfo = "";
  44. int result = DllPubInfo.PubInfo.InitFormControl<MacStatus>(panel1, CurrEntity, null, ref errorinfo);
  45. if (result < 0)
  46. MessageBox.Show(errorinfo);
  47. }
  48. private void button1_Click(object sender, EventArgs e)
  49. {
  50. InitForm(null);
  51. }
  52. private MacStatus CallIUBase(MacStatus entity)
  53. {
  54. try
  55. {
  56. string errorinfo = "";
  57. int result = PubInfo.UpdateRowFormControl(panel1, entity, ref errorinfo);
  58. if (result < 0)
  59. {
  60. MessageBox.Show("更新数据发生错误:" + errorinfo);
  61. return null;
  62. }
  63. entity.STime = DateTime.Now;
  64. Hashtable tempds = new Hashtable();
  65. string str = JsonConvert.SerializeObject(entity);
  66. tempds.Add(nameof(MacStatus), str);
  67. Hashtable reds = PubInfo.CallFunction("DllStatusShowBll.StatusShowBll", "IMacStatus", tempds);
  68. if (reds == null)
  69. return null;
  70. MacStatus reentity = JsonConvert.DeserializeObject<MacStatus>(reds[nameof(MacStatus)].ToString());
  71. return reentity;
  72. }
  73. catch (Exception e)
  74. {
  75. MessageBox.Show("操作发生错误,错误信息为:" + e.Message.ToString(), "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
  76. return null;
  77. }
  78. }
  79. private void button2_Click(object sender, EventArgs e)
  80. {
  81. //if(edit代码.Text.Trim()=="")
  82. //{
  83. // MessageBox.Show("代码不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  84. // edit代码.Focus();
  85. // return;
  86. //}
  87. if (editFCode.Text.Trim() == "")
  88. {
  89. MessageBox.Show("名称不能为空,请填写!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  90. editFCode.Focus();
  91. return;
  92. }
  93. MacStatus result = CallIUBase(CurrEntity);
  94. if(result!=null)
  95. {
  96. MessageBox.Show("操作成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  97. InitForm(result);
  98. eventaddrow?.Invoke(result);
  99. }
  100. }
  101. private void mmabase_FormClosing(object sender, FormClosingEventArgs e)
  102. {
  103. eventcloseform?.Invoke();
  104. }
  105. public void Selmma(DataRow row)
  106. {
  107. //if(row==null)
  108. //{
  109. // edit机型代码.Text = "";
  110. // return;
  111. //}
  112. //edit机型代码.Text = row["代码"].ToString();
  113. }
  114. private void btEmail_Click(object sender, EventArgs e)
  115. {
  116. //mmaquery temp = new mmaquery();
  117. //temp.eventselrow += Selmma;
  118. //temp.ShowDialog();
  119. }
  120. private void button3_Click(object sender, EventArgs e)
  121. {
  122. //if (CurrDs == null)
  123. //{
  124. // InitForm(0);
  125. // return;
  126. //}
  127. //CurrID = 0;
  128. //CurrDs.Tables[0].Rows[0]["id"] = 0;
  129. CurrEntity = new MacStatus();
  130. editMacCode.Text = "";
  131. }
  132. private void btEmail_Click_1(object sender, EventArgs e)
  133. {
  134. StatusColor temp = new StatusColor();
  135. temp.eventSelStandardStatus += Temp_eventSelRow;
  136. temp.ShowDialog();
  137. }
  138. private void Temp_eventSelRow(StandardStatus rows)
  139. {
  140. editFCode.Text = rows.FCode;
  141. editFCode.Tag = rows.ID;
  142. editStatusFName.Text = rows.FName;
  143. }
  144. private void MacStatusBase_Load(object sender, EventArgs e)
  145. {
  146. }
  147. }
  148. }