F_TAT_0302.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_TAT_0301.cs
  5. * 2.功能描述:基本工资策略明细
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 任海 2014/12/12 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Collections.Generic;
  12. using System.ComponentModel;
  13. using System.Data;
  14. using System.Drawing;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. using Dongke.IBOSS.PRD.Basics.BaseControls;
  19. using Dongke.IBOSS.PRD.Basics.BaseResources;
  20. using Dongke.IBOSS.PRD.Client.CommonModule;
  21. using Dongke.IBOSS.PRD.Client.Controls;
  22. using Dongke.IBOSS.PRD.Basics.Library;
  23. using Dongke.IBOSS.PRD.WCF.Proxys;
  24. using Dongke.IBOSS.PRD.WCF.Proxys.SystemModuleService;
  25. using Dongke.IBOSS.PRD.WCF.Proxys.TATModuleService;
  26. using Dongke.IBOSS.PRD.WCF.DataModels;
  27. namespace Dongke.IBOSS.PRD.Client.TATModule
  28. {
  29. /// <summary>
  30. /// 基本工资策略明细
  31. /// </summary>
  32. public partial class F_TAT_0302 : FormBase
  33. {
  34. #region 成员变量
  35. // 窗体模式ID
  36. private Constant.FormMode _formType;
  37. // 操作实体ID
  38. private int? _entityId;
  39. // 操作实体名称
  40. private string _entityname;
  41. // 操作实体
  42. private BasicSalaryEntity _basicSalaryEntity = new BasicSalaryEntity();
  43. // 选择窗体弹出标识
  44. private bool _showFlag = true;
  45. // 数据源
  46. private DataSet _dsSourse;
  47. // 窗体加载完毕标识
  48. private bool _pageLoadOK = false;
  49. #endregion
  50. #region 构造函数
  51. /// <summary>
  52. /// 窗体构造
  53. /// </summary>
  54. /// <param name="formType">窗体开启模式</param>
  55. /// <param name="entityId">操作实体ID</param>
  56. public F_TAT_0302(Constant.FormMode formType, int entityId, string entityname)
  57. {
  58. InitializeComponent();
  59. this._formType = formType;
  60. this._entityId = entityId;
  61. this._entityname = entityname;
  62. }
  63. #endregion
  64. #region 事件处理
  65. /// <summary>
  66. /// 窗体加载
  67. /// </summary>
  68. /// <param name="sender"></param>
  69. /// <param name="e"></param>
  70. private void F_TAT_0302_Load(object sender, EventArgs e)
  71. {
  72. try
  73. {
  74. this.lblBasicSalaryDetail.Text = "当前选择的策略名称:" + _entityname;
  75. this.dgvBasicSalaryDetail.AutoGenerateColumns = false;
  76. //绑定工种信息
  77. this.BindJobs();
  78. this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
  79. //页面加载完毕
  80. this._pageLoadOK = true;
  81. //如果是审核及观看模式
  82. if (this._formType == Constant.FormMode.Display)
  83. {
  84. //列表设置为只读
  85. this.dgvBasicSalaryDetail.ReadOnly = true;
  86. this.dgvBasicSalaryDetail.IsSetInputColumnsColor = false;
  87. this.dgvBasicSalaryDetail.AllowUserToDeleteRows = false;
  88. //控件除关闭外全部不可用
  89. this.btnSave.Enabled = false;
  90. }
  91. }
  92. catch (Exception ex)
  93. {
  94. // 对异常进行共通处理
  95. ExceptionManager.HandleEventException(this.ToString(),
  96. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  97. }
  98. }
  99. /// <summary>
  100. /// 提交操作
  101. /// </summary>
  102. /// <param name="sender"></param>
  103. /// <param name="e"></param>
  104. private void btnSave_Click(object sender, EventArgs e)
  105. {
  106. try
  107. {
  108. int results = Conservation();
  109. if (results == Constant.INT_IS_ONE)
  110. {
  111. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "工种编码"),
  112. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  113. this.btnSave.Enabled = false;
  114. return;
  115. }
  116. if (results == Constant.INT_IS_TWO)
  117. {
  118. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "基本工资"),
  119. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  120. this.btnSave.Enabled = false;
  121. return;
  122. }
  123. if (results == Constant.INT_IS_THREE)
  124. {
  125. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "补贴"),
  126. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  127. this.btnSave.Enabled = false;
  128. return;
  129. }
  130. if (results == Constant.INT_IS_FOUR)
  131. {
  132. MessageBox.Show(string.Format(Messages.MSG_CMN_W005, "保底工资"),
  133. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  134. this.btnSave.Enabled = false;
  135. return;
  136. }
  137. //提交操作
  138. ServiceResultEntity srEntity =
  139. (ServiceResultEntity)DoAsync(() =>
  140. {
  141. return TATModuleProxy.Service.EditBasicSalaryDetail(Convert.ToInt32(this._entityId), _dsSourse);
  142. });
  143. ServiceResultEntityManager.HandleServiceResultEntity(srEntity, this.Text);
  144. if (srEntity.Status == Constant.ServiceResultStatus.Success)
  145. {
  146. this.DialogResult = DialogResult.OK;
  147. }
  148. }
  149. catch (Exception ex)
  150. {
  151. // 对异常进行共通处理
  152. ExceptionManager.HandleEventException(this.ToString(),
  153. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  154. }
  155. }
  156. private void dgvBasicSalaryDetail_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  157. {
  158. try
  159. {
  160. //变更后重新加载
  161. this._pageLoadOK = false;
  162. if (this.dgvBasicSalaryDetail.Rows.Count <= 1 || !this._showFlag)
  163. {
  164. return;
  165. }
  166. DataGridViewRow rowItem = this.dgvBasicSalaryDetail.Rows[e.RowIndex];
  167. DataGridViewColumn columnItem = this.dgvBasicSalaryDetail.Columns[e.ColumnIndex];
  168. if (columnItem.Name == "JobsCode")
  169. {
  170. //打开多选页面进行值绑定
  171. this._showFlag = false;
  172. FormUtility.BindJobsRowDataSource(this.dgvBasicSalaryDetail,
  173. e.RowIndex, columnItem.Name, string.Empty);
  174. this._showFlag = true;
  175. }
  176. //加载OK
  177. this._pageLoadOK = true;
  178. // 设置可输入单元格的颜色
  179. this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
  180. }
  181. catch (Exception ex)
  182. {
  183. // 对异常进行共通处理
  184. ExceptionManager.HandleEventException(this.ToString(),
  185. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  186. }
  187. }
  188. /// <summary>
  189. /// 行校验
  190. /// </summary>
  191. /// <param name="sender"></param>
  192. /// <param name="e"></param>
  193. private void dgvBasicSalaryDetail_RowValidating(object sender, DataGridViewCellCancelEventArgs e)
  194. {
  195. try
  196. {
  197. // 按Esc键时不校验
  198. if (!dgvBasicSalaryDetail.IsCurrentRowDirty)
  199. {
  200. this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
  201. return;
  202. }
  203. if (this.ActiveControl != null && "btnClose".Equals(this.ActiveControl.Name))
  204. {
  205. // 清除单元格的错误消息
  206. this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Empty;
  207. return;
  208. }
  209. DataGridViewRow row = dgvBasicSalaryDetail.CurrentRow;
  210. if (!row.IsNewRow)
  211. {
  212. // 判断工种编码能为空
  213. if (row.Cells["JobsCode"].Value == null
  214. || string.IsNullOrEmpty(row.Cells["JobsCode"].Value + string.Empty))
  215. {
  216. // 单元格的错误消息
  217. this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "工种编码");
  218. e.Cancel = true;
  219. this.btnSave.Enabled = false;
  220. return;
  221. }
  222. // 判断基本工资不能为空
  223. if (row.Cells["BasicSalary"].Value == null
  224. || string.IsNullOrEmpty(row.Cells["BasicSalary"].Value + string.Empty))
  225. {
  226. // 单元格的错误消息
  227. this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "基本工资");
  228. e.Cancel = true;
  229. this.btnSave.Enabled = false;
  230. return;
  231. }
  232. // 判断补贴不能为空
  233. if (row.Cells["Subsidy"].Value == null
  234. || string.IsNullOrEmpty(row.Cells["Subsidy"].Value + string.Empty))
  235. {
  236. // 单元格的错误消息
  237. this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "补贴");
  238. e.Cancel = true;
  239. this.btnSave.Enabled = false;
  240. return;
  241. }
  242. // 判断保底工资不能为空
  243. if (row.Cells["MinimumSalary"].Value == null
  244. || string.IsNullOrEmpty(row.Cells["MinimumSalary"].Value + string.Empty))
  245. {
  246. // 单元格的错误消息
  247. this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Format(Messages.MSG_CMN_W005, "保底工资");
  248. e.Cancel = true;
  249. this.btnSave.Enabled = false;
  250. return;
  251. }
  252. // 清除单元格的错误消息
  253. this.dgvBasicSalaryDetail.CurrentRow.ErrorText = string.Empty;
  254. }
  255. }
  256. catch (Exception ex)
  257. {
  258. // 对异常进行共通处理
  259. ExceptionManager.HandleEventException(this.ToString(),
  260. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  261. }
  262. }
  263. /// <summary>
  264. /// 根据数据是否变化,设置保存按钮的可用状态
  265. /// </summary>
  266. /// <param name="sender"></param>
  267. /// <param name="e"></param>
  268. private void dgvBasicSalaryDetail_RowValidated(object sender, DataGridViewCellEventArgs e)
  269. {
  270. try
  271. {
  272. this.SetSaveBtnStatus();
  273. }
  274. catch (Exception ex)
  275. {
  276. // 对异常进行共通处理
  277. ExceptionManager.HandleEventException(this.ToString(),
  278. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  279. }
  280. }
  281. /// <summary>
  282. /// 关闭窗体
  283. /// </summary>
  284. /// <param name="sender"></param>
  285. /// <param name="e"></param>
  286. private void btnClose_Click(object sender, EventArgs e)
  287. {
  288. this.Close();
  289. }
  290. #endregion
  291. #region 私有方法/函数
  292. /// <summary>
  293. /// 绑定对应工种明细
  294. /// </summary>
  295. private void BindJobs()
  296. {
  297. try
  298. {
  299. //获取对应工种明细
  300. ServiceResultEntity srEntityDetail
  301. = TATModuleProxy.Service.GetBasicSalaryDetailById(Convert.ToInt32(this._entityId));
  302. if (srEntityDetail.Data != null && srEntityDetail.Data.Tables.Count != 0)
  303. {
  304. this._dsSourse = srEntityDetail.Data;
  305. this.dgvBasicSalaryDetail.DataSource = srEntityDetail.Data.Tables[0];
  306. this.dgvBasicSalaryDetail.IsSetInputColumnsColor = true;
  307. }
  308. }
  309. catch (Exception ex)
  310. {
  311. throw ex;
  312. }
  313. }
  314. /// <summary>
  315. /// 保存时单元格必输项不能为空
  316. /// </summary>
  317. private int Conservation()
  318. {
  319. int isConservation = Constant.INT_IS_ZERO;
  320. DataTable datatBasicSalaryDetail = (DataTable)this.dgvBasicSalaryDetail.DataSource;
  321. foreach (DataRow drproductionData in datatBasicSalaryDetail.Rows)
  322. {
  323. if (drproductionData.RowState == DataRowState.Added || drproductionData.RowState == DataRowState.Modified)
  324. {
  325. if (drproductionData["JobsCode"].ToString() == "")
  326. {
  327. isConservation = Constant.INT_IS_ONE;
  328. break;
  329. }
  330. if (drproductionData["BasicSalary"].ToString() == "")
  331. {
  332. isConservation = Constant.INT_IS_TWO;
  333. break;
  334. }
  335. if (drproductionData["Subsidy"].ToString() == "")
  336. {
  337. isConservation = Constant.INT_IS_THREE;
  338. break;
  339. }
  340. if (drproductionData["MinimumSalary"].ToString() == "")
  341. {
  342. isConservation = Constant.INT_IS_FOUR;
  343. break;
  344. }
  345. }
  346. }
  347. return isConservation;
  348. }
  349. /// <summary>
  350. /// 设置保存按钮的可用状态
  351. /// </summary>
  352. private void SetSaveBtnStatus()
  353. {
  354. if (DataJudge.IsChange((DataTable)this.dgvBasicSalaryDetail.DataSource))
  355. {
  356. this.btnSave.Enabled = true;
  357. }
  358. else
  359. {
  360. this.btnSave.Enabled = false;
  361. }
  362. }
  363. #endregion
  364. }
  365. }