S_CMN_009.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. /*******************************************************************************
  2. * Copyright(c) 2012 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:S_CMN_009.cs
  5. * 2.功能描述:成型线控件查询界面
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 庄天威 2014/09/17 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Text;
  14. using System.Windows.Forms;
  15. using Dongke.IBOSS.PRD.Basics.BaseControls;
  16. using Dongke.IBOSS.PRD.Basics.BaseResources;
  17. using Dongke.IBOSS.PRD.Basics.Library;
  18. using Dongke.IBOSS.PRD.Client.CommonModule;
  19. using Dongke.IBOSS.PRD.WCF.Proxys;
  20. namespace Dongke.IBOSS.PRD.Client.Controls
  21. {
  22. /// <summary>
  23. /// 成型线控件查询界面
  24. /// </summary>
  25. public partial class S_CMN_009 : FormBase
  26. {
  27. #region 成员变量
  28. private DataTable _dataSource; // 画面的数据源
  29. private DataRow _dataRow; // 返回原画面的DataRow
  30. private DataTable _dataDT; //返回选择数据源
  31. #endregion
  32. #region 构造函数
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. public S_CMN_009()
  37. {
  38. InitializeComponent();
  39. // 按钮
  40. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  41. this.btnOK.Text = ButtonText.BTN_OK;
  42. this.btnClose.Text = ButtonText.BTN_CANCEL;
  43. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  44. this.cbSelectAll.Visible = false;
  45. }
  46. public S_CMN_009(int flag)
  47. {
  48. InitializeComponent();
  49. // 按钮
  50. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  51. this.btnOK.Text = ButtonText.BTN_OK;
  52. this.btnClose.Text = ButtonText.BTN_CANCEL;
  53. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  54. if (flag == 1)
  55. {
  56. this.sel.Visible = true;
  57. this.cbSelectAll.Visible = true;
  58. }
  59. else
  60. {
  61. this.sel.Visible = false;
  62. this.cbSelectAll.Visible = false;
  63. }
  64. }
  65. public S_CMN_009(int flag,int NoGroutingFlag)
  66. {
  67. InitializeComponent();
  68. // 按钮
  69. // 按钮
  70. this.btnSearch.Text = ButtonText.BTN_SEARCH;
  71. this.btnOK.Text = ButtonText.BTN_OK;
  72. this.btnClose.Text = ButtonText.BTN_CANCEL;
  73. this.btnClearCondition.Text = ButtonText.BTN_CLEARCONDITION;
  74. if (flag == 1)
  75. {
  76. this.sel.Visible = true;
  77. this.cbSelectAll.Visible = true;
  78. }
  79. else
  80. {
  81. this.sel.Visible = false;
  82. this.cbSelectAll.Visible = false;
  83. }
  84. if(NoGroutingFlag == 1)
  85. {
  86. this.NoGroutingRreason.Visible = true;
  87. }
  88. else
  89. {
  90. this.NoGroutingRreason.Visible = false;
  91. }
  92. }
  93. #endregion
  94. #region 属性
  95. /// <summary>
  96. /// 获取或者设定画面的数据源。
  97. /// </summary>
  98. [Description("获取或者设定画面的数据源。")]
  99. public new DataTable DataSource
  100. {
  101. get
  102. {
  103. return _dataSource;
  104. }
  105. set
  106. {
  107. _dataSource = value;
  108. }
  109. }
  110. /// <summary>
  111. /// 返回选择的数据行
  112. /// </summary>
  113. public DataRow DataRow
  114. {
  115. get
  116. {
  117. return _dataRow;
  118. }
  119. set
  120. {
  121. _dataRow = value;
  122. }
  123. }
  124. /// <summary>
  125. /// 返回选择的组织多行
  126. /// </summary>
  127. public DataTable dataDT
  128. {
  129. get
  130. {
  131. return _dataDT;
  132. }
  133. set
  134. {
  135. _dataDT = value;
  136. }
  137. }
  138. #endregion
  139. #region 私有方法/函数
  140. /// <summary>
  141. /// 查询方法
  142. /// </summary>
  143. private void Search()
  144. {
  145. this.dgvGroutingLine.AutoGenerateColumns = false;
  146. // 清空之前的查询结果
  147. this.dgvGroutingLine.DataSource = null;
  148. // 根据查询条件查询数据源中的数据,并显示
  149. DataTable MouldTypeTable = this.DataSource.Copy();
  150. MouldTypeTable.DefaultView.RowFilter = GetFilterExpression();
  151. this.dgvGroutingLine.DataSource = MouldTypeTable.DefaultView.ToTable();
  152. this.dgvGroutingLine.Focus();
  153. // 当没有查询结果时,提示无查询结构消息
  154. if (this.dgvGroutingLine.RowCount <= 0)
  155. {
  156. MessageBox.Show(ControlsTips.DK_SearchBox_NoResult,
  157. this.Text,MessageBoxButtons.OK,MessageBoxIcon.Warning);
  158. this.txtUserCode.Focus();
  159. this.btnOK.Enabled = false;
  160. return;
  161. }
  162. this.btnOK.Enabled = true;
  163. //绑定未注浆原因
  164. BindNoGroutingRreason();
  165. }
  166. /// <summary>
  167. /// 提交时给取得的行赋值
  168. /// </summary>
  169. private void Commit()
  170. {
  171. if (this.sel.Visible)
  172. {
  173. if (this.dgvGroutingLine.CurrentCell != null)
  174. {
  175. this.dataDT = (DataTable)this.dgvGroutingLine.DataSource;
  176. this.DialogResult = DialogResult.OK;
  177. }
  178. }
  179. else
  180. {
  181. if (this.dgvGroutingLine.CurrentCell != null)
  182. {
  183. DataRow = this.dgvGroutingLine.GetDataRow(this.dgvGroutingLine.CurrentCell.RowIndex);
  184. this.DialogResult = DialogResult.OK;
  185. }
  186. }
  187. this.Close();
  188. }
  189. /// <summary>
  190. /// 根据画面输入内容拼接过滤条件
  191. /// </summary>
  192. /// <returns></returns>
  193. private string GetFilterExpression()
  194. {
  195. StringBuilder strbFilterExpressions = new StringBuilder();
  196. strbFilterExpressions.Append("(1=1");
  197. if (!string.IsNullOrEmpty(this.txtGroutingLineCode.Text))
  198. {
  199. // 成型线编码
  200. strbFilterExpressions.Append(string.Format(" AND GroutingLineCode LIKE '%{0}%'",
  201. Utility.SelectFilterLike(this.txtGroutingLineCode.Text.Trim())));
  202. }
  203. if (!string.IsNullOrEmpty(this.txtGroutingLineName.Text))
  204. {
  205. // 成型线名称
  206. strbFilterExpressions.Append(string.Format(" AND GroutingLineName LIKE '%{0}%'",
  207. Utility.SelectFilterLike(this.txtGroutingLineName.Text.Trim())));
  208. }
  209. if(!string.IsNullOrEmpty(this.txtUserCode.Text))
  210. {
  211. // 注浆编号
  212. //strbFilterExpressions.Append( " AND instr(','||:DefectTypeIDS||',',','||TP_MST_DefectType.DefectTypeID||',')>0 ");
  213. //strbFilterExpressions.Append(string.Format(" AND instr(','||{0}||',',','||UserCode||',')>0 ",
  214. // Utility.SelectFilterLike(this.txtUserCode.Text.Trim())));
  215. strbFilterExpressions.Append(string.Format(" AND UserCodeList LIKE '%{0}%'",
  216. Utility.SelectFilterLike(this.txtUserCode.Text.Trim())));
  217. }
  218. strbFilterExpressions.Append(")");
  219. return strbFilterExpressions.ToString();
  220. }
  221. /// <summary>
  222. /// 绑定未注浆状态
  223. /// </summary>
  224. private void BindNoGroutingRreason()
  225. {
  226. try
  227. {
  228. DataTable dtNoGroutingRreason = SystemModuleProxy.Service.GetDataDictionaryByType(
  229. Constant.DictionaryType.TPC004, Constant.INT_IS_ONE);
  230. DataRow drNull = dtNoGroutingRreason.NewRow();
  231. drNull["DICTIONARYID"] = -1;
  232. drNull["DICTIONARYTYPE"] = -1;
  233. drNull["DICTIONARYVALUE"] = "";
  234. drNull["REMARKS"] = "";
  235. dtNoGroutingRreason.Rows.InsertAt(drNull, 0);
  236. this.NoGroutingRreason.DataSource = dtNoGroutingRreason;
  237. this.NoGroutingRreason.ValueMember = "DictionaryID";
  238. this.NoGroutingRreason.DisplayMember = "DictionaryValue";
  239. }
  240. catch (Exception ex)
  241. {
  242. throw ex;
  243. }
  244. }
  245. #endregion
  246. #region 控件事件
  247. /// <summary>
  248. /// 双击事件
  249. /// </summary>
  250. private void dgvGroutingLine_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  251. {
  252. try
  253. {
  254. // 判断是否是双击列头,如果是双击列头的话,不做任何操作
  255. if (-1 < e.RowIndex && -1 < e.ColumnIndex)
  256. {
  257. //判断有没有复选框,如果有不做任何操作
  258. if (!this.sel.Visible)
  259. {
  260. Commit();
  261. }
  262. }
  263. }
  264. catch (Exception ex)
  265. {
  266. // 对异常进行共通处理
  267. ExceptionManager.HandleEventException(this.ToString(),
  268. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  269. }
  270. }
  271. private void S_CMN_007_Load(object sender, EventArgs e)
  272. {
  273. try
  274. {
  275. this.dgvGroutingLine.AutoGenerateColumns = false;
  276. if (!string.IsNullOrEmpty(this.txtGroutingLineCode.Text))
  277. {
  278. Search();
  279. }
  280. }
  281. catch (Exception ex)
  282. {
  283. // 对异常进行共通处理
  284. ExceptionManager.HandleEventException(this.ToString(),
  285. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  286. }
  287. }
  288. /// <summary>
  289. /// 查询按钮按下事件
  290. /// </summary>
  291. /// <param name="sender"></param>
  292. /// <param name="e"></param>
  293. private void btnSearch_Click(object sender, System.EventArgs e)
  294. {
  295. try
  296. {
  297. Search();
  298. }
  299. catch (Exception ex)
  300. {
  301. // 对异常进行共通处理
  302. ExceptionManager.HandleEventException(this.ToString(),
  303. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  304. }
  305. }
  306. /// <summary>
  307. /// KeyDown事件
  308. /// </summary>
  309. /// <param name="sender"></param>
  310. /// <param name="e"></param>
  311. private void dgvOrganization_KeyDown(object sender, KeyEventArgs e)
  312. {
  313. try
  314. {
  315. // 拷贝单元格文本到剪切板
  316. if (e.KeyData == (Keys.Control | Keys.C))
  317. {
  318. if (dgvGroutingLine.CurrentRow != null
  319. && !string.IsNullOrEmpty(dgvGroutingLine.CurrentRow.Cells[dgvGroutingLine.CurrentCell.ColumnIndex].EditedFormattedValue + ""))
  320. {
  321. Clipboard.SetText(dgvGroutingLine.CurrentRow.Cells[dgvGroutingLine.CurrentCell.ColumnIndex].EditedFormattedValue + "");
  322. }
  323. }
  324. else if (e.KeyData == Keys.Enter)
  325. {
  326. Commit();
  327. }
  328. }
  329. catch (Exception ex)
  330. {
  331. // 对异常进行共通处理
  332. ExceptionManager.HandleEventException(this.ToString(),
  333. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  334. }
  335. }
  336. /// <summary>
  337. /// 确定按钮按下事件
  338. /// </summary>
  339. /// <param name="sender"></param>
  340. /// <param name="e"></param>
  341. private void btnOK_Click(object sender, System.EventArgs e)
  342. {
  343. try
  344. {
  345. Commit();
  346. }
  347. catch (Exception ex)
  348. {
  349. // 对异常进行共通处理
  350. ExceptionManager.HandleEventException(this.ToString(),
  351. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  352. }
  353. }
  354. /// <summary>
  355. /// 关闭按钮按下事件
  356. /// </summary>
  357. /// <param name="sender"></param>
  358. /// <param name="e"></param>
  359. private void btnClose_Click(object sender, System.EventArgs e)
  360. {
  361. this.DialogResult = DialogResult.Cancel;
  362. this.Close();
  363. }
  364. #endregion
  365. private void cbSelectAll_CheckedChanged(object sender, EventArgs e)
  366. {
  367. foreach (DataGridViewRow gvrNow in this.dgvGroutingLine.Rows)
  368. {
  369. gvrNow.Cells["sel"].Value = this.cbSelectAll.Checked ? 1 : 0;
  370. }
  371. }
  372. private void btnClearCondition_Click(object sender, EventArgs e)
  373. {
  374. this.txtGroutingLineCode.Clear();
  375. this.txtGroutingLineName.Clear();
  376. this.txtUserCode.Clear();
  377. }
  378. }
  379. }