F_MST_0801.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774
  1. /*******************************************************************************
  2. * Copyright(c) 2014 dongke All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0801.cs
  5. * 2.功能描述:商标管理
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/11/12 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.BaseControls;
  15. using Dongke.IBOSS.PRD.Client.CommonModule;
  16. using Dongke.IBOSS.PRD.Basics.Library;
  17. using Dongke.IBOSS.PRD.WCF.Proxys;
  18. using Dongke.IBOSS.PRD.Client.DataModels;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. /// <summary>
  22. /// 商标管理
  23. /// </summary>
  24. public partial class F_MST_0801 : FormBase
  25. {
  26. #region 成员变量
  27. // 窗体的单例模式
  28. private static F_MST_0801 _instance;
  29. // 工种数据源
  30. private DataTable _dtSourse;
  31. #endregion
  32. #region 构造函数
  33. /// <summary>
  34. /// 构造函数
  35. /// </summary>
  36. public F_MST_0801()
  37. {
  38. InitializeComponent();
  39. // 窗口标题
  40. this.Text = FormTitles.F_MST_0801;
  41. // 按钮
  42. this.btnSave.Text = ButtonText.BTN_SAVE;
  43. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  44. }
  45. #endregion
  46. #region 单例模式
  47. /// <summary>
  48. /// 单例模式,防止重复创建窗体
  49. /// </summary>
  50. public static F_MST_0801 Instance
  51. {
  52. get
  53. {
  54. if (_instance == null)
  55. {
  56. _instance = new F_MST_0801();
  57. }
  58. return _instance;
  59. }
  60. }
  61. #endregion
  62. #region 事件
  63. /// <summary>
  64. /// 窗体加载
  65. /// </summary>
  66. /// <param name="sender"></param>
  67. /// <param name="e"></param>
  68. private void F_MST_0801_Load(object sender, System.EventArgs e)
  69. {
  70. try
  71. {
  72. // 设置datagridview不自动创建列
  73. this.dgvDataLogo.AutoGenerateColumns = false;
  74. // 加载商标管理数据
  75. this.GetAllLogo();
  76. this.RefreshDataGridViewData();
  77. this.dgvDataLogo.IsSetInputColumnsColor = true;
  78. FormPermissionManager.FormPermissionControl(this.Name, this,
  79. LogInUserInfo.CurrentUser.CurrentUserEntity.UserRightData, LogInUserInfo.CurrentUser.CurrentUserEntity.FunctionData);
  80. this.dgvDataLogo.SelectionMode = DataGridViewSelectionMode.RowHeaderSelect;
  81. BindReadOnly();
  82. }
  83. catch (Exception ex)
  84. {
  85. // 对异常进行共通处理
  86. ExceptionManager.HandleEventException(this.ToString(),
  87. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  88. }
  89. }
  90. private void BindReadOnly()
  91. {
  92. foreach (DataGridViewRow row in this.dgvDataLogo.Rows)
  93. {
  94. if (row.Cells["AddFlag"].Value != null && row.Cells["AddFlag"].Value.ToString() == "0")
  95. {
  96. row.Cells["LogoCode"].ReadOnly = true;
  97. }
  98. }
  99. this.dgvDataLogo.IsSetInputColumnsColor = true;
  100. }
  101. /// <summary>
  102. /// 点击右上角关闭按钮
  103. /// </summary>
  104. /// <param name="sender"></param>
  105. /// <param name="e"></param>
  106. private void F_MST_0801_FormClosing(object sender, FormClosingEventArgs e)
  107. {
  108. try
  109. {
  110. // 关闭的时候需要判断是否有数据变化
  111. if (DataJudge.IsChange((DataTable)this.dgvDataLogo.DataSource))
  112. {
  113. DialogResult dialogResult = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  114. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  115. // 保存改变的数据
  116. if (dialogResult == DialogResult.Yes)
  117. {
  118. DataGridViewRow row = dgvDataLogo.CurrentRow;
  119. if (!row.IsNewRow)
  120. {
  121. // 判断商标编码不能为空
  122. if (row.Cells["LogoCode"].Value == null
  123. || string.IsNullOrEmpty(row.Cells["LogoCode"].Value + string.Empty))
  124. {
  125. // 错误消息
  126. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标编码"),
  127. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  128. e.Cancel = true;
  129. this.btnSave.Enabled = false;
  130. return;
  131. }
  132. // 判断商标名称不能为空
  133. if (row.Cells["LogoName"].Value == null
  134. || string.IsNullOrEmpty(row.Cells["LogoName"].Value + string.Empty))
  135. {
  136. // 单元格的错误消息
  137. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标名称"),
  138. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  139. e.Cancel = true;
  140. this.btnSave.Enabled = false;
  141. return;
  142. }
  143. }
  144. // 异步处理
  145. object result = DoAsync(new BaseAsyncMethod(SaveLogoData));
  146. if (result.Equals(Constant.INT_IS_ONE))
  147. {
  148. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "商标编码"),
  149. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  150. e.Cancel = true;
  151. this.btnSave.Enabled = false;
  152. return;
  153. }
  154. // 如果保存出错,不关闭窗体
  155. if (Convert.ToInt32(result) > Constant.INT_IS_ZERO)
  156. {
  157. e.Cancel = true;
  158. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "商标", "保存"),
  159. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  160. this.btnSave.Enabled = false;
  161. this._dtSourse.AcceptChanges();
  162. }
  163. else if (Convert.ToInt32(result) == (int)Constant.RETURN_IS_EXIST)
  164. {
  165. e.Cancel = true;
  166. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "商标名称"),
  167. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  168. }
  169. else
  170. {
  171. e.Cancel = true;
  172. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "商标", "保存"),
  173. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  174. }
  175. }
  176. else if (dialogResult == DialogResult.Cancel)
  177. {
  178. e.Cancel = true;
  179. }
  180. }
  181. }
  182. catch (Exception ex)
  183. {
  184. // 对异常进行共通处理
  185. ExceptionManager.HandleEventException(this.ToString(),
  186. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  187. }
  188. }
  189. /// <summary>
  190. /// 窗体关闭后,释放单例资源
  191. /// </summary>
  192. /// <param name="sender"></param>
  193. /// <param name="e"></param>
  194. private void F_MST_0801_FormClosed(object sender, FormClosedEventArgs e)
  195. {
  196. _instance = null;
  197. }
  198. /// <summary>
  199. /// 选中新行时,设置默认值
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. private void dgvDataJobs_DefaultValuesNeeded(object sender, DataGridViewRowEventArgs e)
  204. {
  205. // 设置有效属性为选中状态
  206. e.Row.Cells["ValueFlag"].Value = Constant.INT_IS_ONE;
  207. e.Row.Cells["DisplayNo"].Value = e.Row.Index + 1;
  208. }
  209. /// <summary>
  210. /// 工种管理信息输入格式控制
  211. /// </summary>
  212. /// <param name="sender"></param>
  213. /// <param name="e"></param>
  214. private void dgvDataJobs_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
  215. {
  216. try
  217. {
  218. TextBox tb = (e.Control as TextBox);
  219. if (tb != null)
  220. {
  221. string colName = this.dgvDataLogo.Columns[this.dgvDataLogo.CurrentCell.ColumnIndex].Name;
  222. if ("LogoCode" == colName)
  223. {
  224. tb.CharacterCasing = CharacterCasing.Upper;
  225. }
  226. else if ("TagCode" == colName)
  227. {
  228. tb.KeyPress += tb_KeyPress;
  229. tb.CharacterCasing = CharacterCasing.Upper;
  230. }
  231. else
  232. {
  233. tb.CharacterCasing = CharacterCasing.Normal;
  234. }
  235. }
  236. }
  237. catch (Exception ex)
  238. {
  239. // 对异常进行共通处理
  240. ExceptionManager.HandleEventException(this.ToString(),
  241. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  242. }
  243. }
  244. void tb_KeyPress(object sender, KeyPressEventArgs e)
  245. {
  246. if (((e.KeyChar < 'a' || e.KeyChar > 'z') && (e.KeyChar < 'A' || e.KeyChar > 'Z') && (e.KeyChar < '0' || e.KeyChar > '9')) && !char.IsControl(e.KeyChar))
  247. {
  248. e.Handled = true;
  249. }
  250. }
  251. /// <summary>
  252. /// 单元格验证,检查
  253. /// </summary>
  254. /// <param name="sender"></param>
  255. /// <param name="e"></param>
  256. private void dgvDataJobs_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
  257. {
  258. try
  259. {
  260. if (this.ActiveControl != null && "btnClose".Equals(this.ActiveControl.Name))
  261. {
  262. return;
  263. }
  264. if (!dgvDataLogo.CurrentRow.IsNewRow)
  265. {
  266. DataGridViewRow rowItem = dgvDataLogo.Rows[e.RowIndex];
  267. DataGridViewColumn columnItem = dgvDataLogo.Columns[e.ColumnIndex];
  268. object columnvalue = rowItem.Cells[columnItem.Name].EditedFormattedValue;
  269. // 商标编码
  270. if ("LogoCode".Equals(columnItem.Name))
  271. {
  272. if (columnvalue != null && !string.IsNullOrEmpty(columnvalue + string.Empty))
  273. {
  274. if (!Utility.IsUnique(columnvalue.ToString(),
  275. dgvDataLogo.CurrentRow.Index, this.dgvDataLogo, "LogoCode"))
  276. {
  277. // 单元格的错误消息
  278. this.dgvDataLogo.CurrentRow.ErrorText = string.Format(
  279. Messages.MSG_CMN_W006, "商标编码");
  280. e.Cancel = true;
  281. this.btnSave.Enabled = false;
  282. return;
  283. }
  284. }
  285. }
  286. // 清除单元格的错误消息
  287. this.dgvDataLogo.CurrentRow.ErrorText = string.Empty;
  288. BindReadOnly();
  289. }
  290. }
  291. catch (Exception ex)
  292. {
  293. // 对异常进行共通处理
  294. ExceptionManager.HandleEventException(this.ToString(),
  295. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  296. }
  297. }
  298. /// <summary>
  299. /// 根据数据是否变化,设置保存按钮的可用状态
  300. /// </summary>
  301. /// <param name="sender"></param>
  302. /// <param name="e"></param>
  303. private void dgvDataJobs_CellValidated(object sender, DataGridViewCellEventArgs e)
  304. {
  305. try
  306. {
  307. this.SetSaveBtnStatus();
  308. BindReadOnly();
  309. }
  310. catch (Exception ex)
  311. {
  312. // 对异常进行共通处理
  313. ExceptionManager.HandleEventException(this.ToString(),
  314. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  315. }
  316. }
  317. /// <summary>
  318. /// 行校验
  319. /// </summary>
  320. /// <param name="sender"></param>
  321. /// <param name="e"></param>
  322. private void dgvDataJobs_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
  323. {
  324. try
  325. {
  326. // 按Esc键时不校验
  327. if (!dgvDataLogo.IsCurrentRowDirty)
  328. {
  329. this.dgvDataLogo.IsSetInputColumnsColor = true;
  330. return;
  331. }
  332. if (this.ActiveControl != null && "btnClose".Equals(this.ActiveControl.Name))
  333. {
  334. // 清除单元格的错误消息
  335. this.dgvDataLogo.CurrentRow.ErrorText = string.Empty;
  336. return;
  337. }
  338. DataGridViewRow row = dgvDataLogo.CurrentRow;
  339. if (!row.IsNewRow)
  340. {
  341. // 判断商标编码能为空
  342. if (row.Cells["LogoCode"].Value == null
  343. || string.IsNullOrEmpty(row.Cells["LogoCode"].Value + string.Empty))
  344. {
  345. // 单元格的错误消息
  346. this.dgvDataLogo.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "商标编码");
  347. e.Cancel = true;
  348. this.btnSave.Enabled = false;
  349. return;
  350. }
  351. // 判断商标名称不能为空
  352. if (row.Cells["LogoName"].Value == null
  353. || string.IsNullOrEmpty(row.Cells["LogoName"].Value + string.Empty))
  354. {
  355. // 单元格的错误消息
  356. this.dgvDataLogo.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "商标名称");
  357. e.Cancel = true;
  358. this.btnSave.Enabled = false;
  359. return;
  360. }
  361. // 清除单元格的错误消息
  362. this.dgvDataLogo.CurrentRow.ErrorText = string.Empty;
  363. }
  364. }
  365. catch (Exception ex)
  366. {
  367. // 对异常进行共通处理
  368. ExceptionManager.HandleEventException(this.ToString(),
  369. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  370. }
  371. }
  372. /// <summary>
  373. /// 根据数据是否变化,设置保存按钮的可用状态
  374. /// </summary>
  375. /// <param name="sender"></param>
  376. /// <param name="e"></param>
  377. private void dgvDataJobs_RowValidated(object sender, DataGridViewCellEventArgs e)
  378. {
  379. try
  380. {
  381. this.SetSaveBtnStatus();
  382. }
  383. catch (Exception ex)
  384. {
  385. // 对异常进行共通处理
  386. ExceptionManager.HandleEventException(this.ToString(),
  387. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  388. }
  389. }
  390. /// <summary>
  391. /// 根据是否选中停用数据,加载数据
  392. /// </summary>
  393. /// <param name="sender"></param>
  394. /// <param name="e"></param>
  395. private void chkDisplayDisabledData_CheckedChanged(object sender, EventArgs e)
  396. {
  397. try
  398. {
  399. this.RefreshDataGridViewData();
  400. this.SetSaveBtnStatus();
  401. BindReadOnly();
  402. this.dgvDataLogo.IsSetInputColumnsColor = true;
  403. }
  404. catch (Exception ex)
  405. {
  406. // 对异常进行共通处理
  407. ExceptionManager.HandleEventException(this.ToString(),
  408. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  409. }
  410. }
  411. /// <summary>
  412. /// 单元格输入时,给自动生成的行设置颜色
  413. /// </summary>
  414. /// <param name="sender"></param>
  415. /// <param name="e"></param>
  416. private void dgvDataJobs_UserAddedRow(object sender, DataGridViewRowEventArgs e)
  417. {
  418. this.dgvDataLogo.IsSetInputColumnsColor = true;
  419. }
  420. /// <summary>
  421. /// 保存工种数据
  422. /// </summary>
  423. /// <param name="sender"></param>
  424. /// <param name="e"></param>
  425. private void btnSave_Click(object sender, EventArgs e)
  426. {
  427. try
  428. {
  429. int results = Conservation();
  430. if (results == Constant.INT_IS_ONE)
  431. {
  432. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标编码"),
  433. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  434. this.btnSave.Enabled = false;
  435. return;
  436. }
  437. if (results == Constant.INT_IS_TWO)
  438. {
  439. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "商标名称"),
  440. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  441. this.btnSave.Enabled = false;
  442. return;
  443. }
  444. if (results == Constant.INT_IS_TWO)
  445. {
  446. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "显示顺序"),
  447. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  448. this.btnSave.Enabled = false;
  449. return;
  450. }
  451. if (results == Constant.INT_IS_THREE)
  452. {
  453. MessageBox.Show("只能允许有一个默认商标",
  454. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  455. this.btnSave.Enabled = false;
  456. return;
  457. }
  458. if (results == Constant.INT_IS_FOUR)
  459. {
  460. MessageBox.Show("请选择一个默认商标",
  461. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  462. this.btnSave.Enabled = false;
  463. return;
  464. }
  465. // 异步处理
  466. this.btnSave.Enabled = false;
  467. this.btnCancel.Enabled = false;
  468. int result = (int)DoAsync(new BaseAsyncMethod(SaveLogoData));
  469. this.btnSave.Enabled = true;
  470. this.btnCancel.Enabled = true;
  471. // 工种数据保存成功
  472. if (result == Constant.INT_IS_TWO)
  473. {
  474. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "商标", "保存"),
  475. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  476. // 加载工种管理数据
  477. this._dtSourse.AcceptChanges();
  478. foreach (DataRow r in this._dtSourse.Rows)
  479. {
  480. r["AddFlag"] = 0;
  481. }
  482. this._dtSourse.AcceptChanges();
  483. this.btnSave.Enabled = false;
  484. }
  485. else if (result == Constant.INT_IS_ONE)
  486. {
  487. MessageBox.Show(string.Format(Messages.MSG_CMN_W006, "商标编码"),
  488. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  489. return;
  490. }
  491. else
  492. {
  493. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "商标", "保存"),
  494. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  495. }
  496. foreach (DataGridViewRow row in this.dgvDataLogo.Rows)
  497. {
  498. if (row.Cells["LogoCode"].Value != null)
  499. {
  500. row.Cells["LogoCode"].ReadOnly = true;
  501. }
  502. }
  503. this.dgvDataLogo.IsSetInputColumnsColor = true;
  504. }
  505. catch (Exception ex)
  506. {
  507. this.btnSave.Enabled = true;
  508. this.btnCancel.Enabled = true;
  509. // 对异常进行共通处理
  510. ExceptionManager.HandleEventException(this.ToString(),
  511. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  512. }
  513. }
  514. /// <summary>
  515. /// 设置排序时列表的颜色
  516. /// </summary>
  517. private void dgvDataJobs_Sorted(object sender, EventArgs e)
  518. {
  519. BindReadOnly();
  520. this.dgvDataLogo.IsSetInputColumnsColor = true;
  521. }
  522. /// <summary>
  523. /// 点击关闭按钮
  524. /// </summary>
  525. /// <param name="sender"></param>
  526. /// <param name="e"></param>
  527. private void btnCancel_Click(object sender, EventArgs e)
  528. {
  529. this.Close();
  530. }
  531. #endregion
  532. #region 私有方法
  533. /// <summary>
  534. /// 加载工种管理数据
  535. /// </summary>
  536. /// <returns></returns>
  537. private DataSet GetJobsData()
  538. {
  539. try
  540. {
  541. byte valueFlag = Convert.ToByte(chkDisplayDisabledData.Checked);
  542. return SystemModuleProxy.Service.GetJobsData(valueFlag);
  543. }
  544. catch (Exception ex)
  545. {
  546. throw ex;
  547. }
  548. }
  549. /// <summary>
  550. /// 获取工种管理的全部数据
  551. /// </summary>
  552. /// <param name="sUserInfo">用户信息</param>
  553. /// <returns></returns>
  554. /// <remarks>
  555. /// 2014.10.30 任海 新建
  556. /// </remarks>
  557. private void GetAllLogo()
  558. {
  559. try
  560. {
  561. DataSet dsResultAccount = (DataSet)DoAsync(new BaseAsyncMethod(() =>
  562. {
  563. return SystemModuleProxy.Service.GetAllLogoInfo();
  564. }));
  565. this._dtSourse = dsResultAccount.Tables[0];
  566. }
  567. catch (Exception ex)
  568. {
  569. throw ex;
  570. }
  571. }
  572. /// <summary>
  573. /// 得到工种信息
  574. /// </summary>
  575. /// <returns></returns>
  576. private void RefreshDataGridViewData()
  577. {
  578. try
  579. {
  580. if (this.chkDisplayDisabledData.Checked == false)
  581. {
  582. this._dtSourse.DefaultView.RowFilter = "ValueFlag=1";
  583. }
  584. else
  585. {
  586. this._dtSourse.DefaultView.RowFilter = null;
  587. }
  588. this.dgvDataLogo.DataSource = _dtSourse;
  589. this.btnSave.Enabled = false;
  590. }
  591. catch (Exception ex)
  592. {
  593. throw ex;
  594. }
  595. }
  596. /// <summary>
  597. /// 保存工种数据
  598. /// </summary>
  599. /// <returns>是否成功</returns>
  600. private object SaveLogoData()
  601. {
  602. try
  603. {
  604. // 获取当前datatJobsData数据源
  605. DataTable datatJobsData = (DataTable)this.dgvDataLogo.DataSource;
  606. int result = SystemModuleProxy.Service.SaveLogoData(datatJobsData);
  607. return result;
  608. }
  609. catch (Exception ex)
  610. {
  611. throw ex;
  612. }
  613. }
  614. /// <summary>
  615. /// 设置保存按钮的可用状态
  616. /// </summary>
  617. private void SetSaveBtnStatus()
  618. {
  619. if (DataJudge.IsChange((DataTable)this.dgvDataLogo.DataSource))
  620. {
  621. this.btnSave.Enabled = true;
  622. }
  623. else
  624. {
  625. this.btnSave.Enabled = false;
  626. }
  627. }
  628. /// <summary>
  629. /// 保存时单元格必输项不能为空
  630. /// </summary>
  631. private int Conservation()
  632. {
  633. int isConservation = Constant.INT_IS_ZERO;
  634. DataTable datatJobsData = (DataTable)this.dgvDataLogo.DataSource;
  635. foreach (DataRow drproductionData in datatJobsData.Rows)
  636. {
  637. if (drproductionData["LogoCode"].ToString() == string.Empty)
  638. {
  639. isConservation = Constant.INT_IS_ONE;
  640. break;
  641. }
  642. if (drproductionData["LogoName"].ToString() == string.Empty)
  643. {
  644. isConservation = Constant.INT_IS_TWO;
  645. break;
  646. }
  647. if (drproductionData["displayno"].ToString() == string.Empty)
  648. {
  649. isConservation = Constant.INT_IS_THREE;
  650. break;
  651. }
  652. }
  653. if (isConservation == 0)
  654. {
  655. DataRow[] drLength = datatJobsData.Select("valueflag=1 and isdefault=1");
  656. if (drLength.Length > 1)
  657. {
  658. isConservation = Constant.INT_IS_THREE;
  659. }
  660. else if (drLength.Length == 0)
  661. {
  662. isConservation = Constant.INT_IS_FOUR;
  663. }
  664. }
  665. return isConservation;
  666. }
  667. #endregion
  668. private void dgvDataLogo_CellContentClick(object sender, DataGridViewCellEventArgs e)
  669. {
  670. if (e.RowIndex != -1)
  671. {
  672. if (this.dgvDataLogo.CurrentCell != null)
  673. {
  674. DataGridViewRow rowItem = dgvDataLogo.Rows[e.RowIndex];
  675. DataGridViewColumn columnItem = dgvDataLogo.Columns[e.ColumnIndex];
  676. object columnvalue = rowItem.Cells[columnItem.Name].EditedFormattedValue;
  677. //if ("ValueFlag".Equals(columnItem.Name))
  678. //{
  679. int checkValue = Convert.ToInt32(this.dgvDataLogo.Rows[e.RowIndex].Cells["isdefault"].EditedFormattedValue);
  680. if (checkValue == Constant.INT_IS_ONE)
  681. {
  682. SetCheckBoxSelected(checkValue, e.RowIndex);
  683. }
  684. else
  685. {
  686. this.dgvDataLogo.Rows[e.RowIndex].Cells["isdefault"].Value = 0;
  687. }
  688. // }
  689. }
  690. }
  691. }
  692. /// <summary>
  693. /// 清空以前所选中的缺陷
  694. /// </summary>
  695. /// <param name="checkValue"></param>
  696. private void SetCheckBoxSelected(int checkValue, int rowIndex)
  697. {
  698. foreach (DataGridViewRow row in this.dgvDataLogo.Rows)
  699. {
  700. if(row.Index==rowIndex)
  701. {
  702. row.Cells["isdefault"].Value = 1;
  703. }
  704. else
  705. {
  706. row.Cells["isdefault"].Value = 0;
  707. }
  708. //if (row.Cells["AddFlag"].Value != null && row.Cells["AddFlag"].Value.ToString() == "0")
  709. //{
  710. // row.Cells["LogoCode"].ReadOnly = true;
  711. //}
  712. }
  713. this.dgvDataLogo.IsSetInputColumnsColor = true;
  714. //DataTable dtOrgDataSource = this.dgvDataLogo.DataSource as DataTable;
  715. //for (int i = 0; i < dtOrgDataSource.Rows.Count; i++)
  716. //{
  717. // if (i == rowIndex)
  718. // {
  719. // dtOrgDataSource.Rows[i]["isdefault"] = 1;
  720. // }
  721. // else
  722. // {
  723. // dtOrgDataSource.Rows[i]["isdefault"] = 0;
  724. // }
  725. //}
  726. }
  727. }
  728. }