F_MST_0601.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0601.cs
  5. * 2.功能描述:温湿计信息一览
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 任海 2014/12/25 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseResources;
  14. using Dongke.IBOSS.PRD.Basics.DockPanel;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.WCF.Proxys;
  17. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. using Dongke.IBOSS.PRD.WCF.DataModels;
  20. namespace Dongke.IBOSS.PRD.Client.SystemModule
  21. {
  22. /// <summary>
  23. /// 温湿计信息一览
  24. /// </summary>
  25. public partial class F_MST_0601 : DockPanelBase
  26. {
  27. #region 成员变量
  28. // 单例模式使用
  29. private static F_MST_0601 _instance;
  30. // 检索用加载条件实体
  31. private ThermometerEntity _thermometerEntity = new ThermometerEntity();
  32. #endregion
  33. #region 构造函数
  34. /// <summary>
  35. /// 构造函数
  36. /// </summary>
  37. public F_MST_0601()
  38. {
  39. InitializeComponent();
  40. this.Text = FormTitles.F_MST_0601;
  41. this.tsbtnAdd.Text = ButtonText.TSBTN_ADD;
  42. this.tsbtnEdit.Text = ButtonText.TSBTN_EDIT;
  43. this.tsbtnAdaptive.Text = ButtonText.TSBTN_ADAPTIVE;
  44. this.tsbtnClose.Text = ButtonText.TSBTN_CLOSE;
  45. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  46. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  47. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  48. }
  49. #endregion
  50. #region 单例模式
  51. /// <summary>
  52. /// 单例模式,防止重复创建窗体
  53. /// </summary>
  54. public static F_MST_0601 Instance
  55. {
  56. get
  57. {
  58. if (_instance == null)
  59. {
  60. _instance = new F_MST_0601();
  61. }
  62. return _instance;
  63. }
  64. }
  65. #endregion
  66. #region 事件处理
  67. /// <summary>
  68. /// 页面加载事件
  69. /// </summary>
  70. /// <param name="sender"></param>
  71. /// <param name="e"></param>
  72. private void F_MST_0601_Load(object sender, EventArgs e)
  73. {
  74. try
  75. {
  76. this.dgvThermometer.AutoGenerateColumns = false;
  77. this.chkValueFlag.AllItemCheck();
  78. FormPermissionManager.FormPermissionControl(this.Name, this,
  79. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. }
  81. catch (Exception ex)
  82. {
  83. // 对异常进行共通处理
  84. ExceptionManager.HandleEventException(this.ToString(),
  85. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  86. }
  87. }
  88. /// <summary>
  89. /// 新建
  90. /// </summary>
  91. /// <param name="sender"></param>
  92. /// <param name="e"></param>
  93. private void tsbtnAdd_Click(object sender, EventArgs e)
  94. {
  95. try
  96. {
  97. F_MST_0602 frmMST0602 = new F_MST_0602(Constant.FormMode.Add, Constant.INT_IS_ZERO);
  98. DialogResult dialogresult = frmMST0602.ShowDialog();
  99. if (dialogresult.Equals(DialogResult.OK))
  100. {
  101. this.dgvThermometer.DataSource = null;
  102. //获取数据源
  103. DataSet srEntity = (DataSet)DoAsync(this.GetEntity);
  104. if (srEntity != null)
  105. {
  106. DataSet dsGoods = (DataSet)srEntity;
  107. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  108. {
  109. this.dgvThermometer.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  110. this.dgvThermometer.ReadOnly = true;
  111. }
  112. }
  113. }
  114. }
  115. catch (Exception ex)
  116. {
  117. // 对异常进行共通处理
  118. ExceptionManager.HandleEventException(this.ToString(),
  119. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  120. }
  121. }
  122. /// <summary>
  123. /// 编辑
  124. /// </summary>
  125. /// <param name="sender"></param>
  126. /// <param name="e"></param>
  127. private void tsbtnEdit_Click(object sender, EventArgs e)
  128. {
  129. try
  130. {
  131. DataGridViewRow currentRow = this.dgvThermometer.CurrentRow;
  132. if (currentRow != null)
  133. {
  134. int ThermometerID = Convert.ToInt32(currentRow.Cells["ThermometerID"].Value);
  135. F_MST_0602 frmMST0602 = new F_MST_0602(Constant.FormMode.Edit, ThermometerID);
  136. DialogResult dialogresult = frmMST0602.ShowDialog();
  137. if (dialogresult.Equals(DialogResult.OK))
  138. {
  139. this.dgvThermometer.DataSource = null;
  140. object obGoodsResult = DoAsync(new Dongke.IBOSS.PRD.Basics.DockPanel.AsyncMethod(GetEntity));
  141. if (obGoodsResult != null)
  142. {
  143. DataSet dsGoods = (DataSet)obGoodsResult;
  144. if (dsGoods.Tables.Count != Constant.INT_IS_ZERO)
  145. {
  146. this.dgvThermometer.DataSource = dsGoods.Tables[Constant.INT_IS_ZERO];
  147. this.dgvThermometer.ReadOnly = true;
  148. }
  149. }
  150. }
  151. }
  152. else
  153. {
  154. MessageBox.Show(Messages.MSG_CMN_W020, this.Text,
  155. MessageBoxButtons.OK, MessageBoxIcon.Warning);
  156. }
  157. }
  158. catch (Exception ex)
  159. {
  160. // 对异常进行共通处理
  161. ExceptionManager.HandleEventException(this.ToString(),
  162. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  163. }
  164. }
  165. /// <summary>
  166. /// 自适应列宽
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  171. {
  172. this.dgvThermometer.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  173. }
  174. /// <summary>
  175. /// 窗体关闭事件处理
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. private void tsbtnClose_Click(object sender, EventArgs e)
  180. {
  181. this.Close();
  182. }
  183. /// <summary>
  184. /// 查询按钮按下处理
  185. /// </summary>
  186. /// <param name="sender"></param>
  187. /// <param name="e"></param>
  188. private void btnSearch_Click(object sender, EventArgs e)
  189. {
  190. try
  191. {
  192. this.dgvThermometer.DataSource = null;
  193. //获取数据源
  194. DataSet srEntity = (DataSet)DoAsync(this.GetEntity);
  195. if (srEntity != null && srEntity.Tables.Count != 0)
  196. {
  197. this.BindGridView(srEntity.Tables[0]);
  198. if (this.dgvThermometer.Rows.Count == Constant.INT_IS_ZERO)
  199. {
  200. // 提示未查找到数据
  201. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  202. MessageBoxButtons.OK, MessageBoxIcon.Information);
  203. }
  204. }
  205. else
  206. {
  207. // 提示未查找到数据
  208. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  209. MessageBoxButtons.OK, MessageBoxIcon.Information);
  210. }
  211. }
  212. catch (Exception ex)
  213. {
  214. // 对异常进行共通处理
  215. ExceptionManager.HandleEventException(this.ToString(),
  216. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  217. }
  218. }
  219. /// <summary>
  220. /// 清空查询条件处理
  221. /// </summary>
  222. /// <param name="sender"></param>
  223. /// <param name="e"></param>
  224. private void btnClearCondition_Click(object sender, EventArgs e)
  225. {
  226. this.txtBuildingNo.Text = string.Empty;
  227. this.txtFloorNo.Text = string.Empty;
  228. this.txtLocationCode.Text = string.Empty;
  229. this.txtManagerName.Text = string.Empty;
  230. this.txtRemarks.Text = string.Empty;
  231. this.txtThermometerCode.Text = string.Empty;
  232. this.chkValueFlag.AllItemCheck();
  233. }
  234. /// <summary>
  235. /// 窗体关闭事件
  236. /// </summary>
  237. private void F_MST_0601_FormClosed(object sender, FormClosedEventArgs e)
  238. {
  239. _instance = null;
  240. }
  241. #endregion
  242. #region 私有方法
  243. /// <summary>
  244. /// 根据查询条件获取数据集合
  245. /// </summary>
  246. public DataSet GetEntity()
  247. {
  248. try
  249. {
  250. this._thermometerEntity.BuildingNo = this.txtBuildingNo.Text;
  251. this._thermometerEntity.FloorNo = this.txtFloorNo.Text;
  252. this._thermometerEntity.LocationCode = this.txtLocationCode.Text;
  253. this._thermometerEntity.ThermometerCode = this.txtThermometerCode.Text;
  254. this._thermometerEntity.ManagerName = this.txtManagerName.Text;
  255. this._thermometerEntity.Remarks = this.txtRemarks.Text;
  256. object[] objListValue = chkValueFlag.SelectedValues;
  257. if (objListValue.Length == Constant.INT_IS_ONE)
  258. {
  259. this._thermometerEntity.ValueFlag = (int)objListValue[Constant.INT_IS_ZERO];
  260. }
  261. else if (objListValue.Length == Constant.INT_IS_ZERO)
  262. {
  263. return null;
  264. }
  265. // 全选
  266. if (objListValue.Length == Constant.INT_IS_TWO)
  267. {
  268. this._thermometerEntity.ValueFlag = Constant.INT_IS_TWO;
  269. }
  270. return SystemModuleProxy.Service.GetThermometer(_thermometerEntity);
  271. }
  272. catch (Exception ex)
  273. {
  274. throw ex;
  275. }
  276. }
  277. /// <summary>
  278. /// 绑定页面数据源
  279. /// </summary>
  280. /// <param name="dtSourse">数据源TABLE</param>
  281. private void BindGridView(DataTable dtSourse)
  282. {
  283. this.dgvThermometer.DataSource = dtSourse;
  284. this.dgvThermometer.ReadOnly = true;
  285. }
  286. #endregion
  287. }
  288. }