F_PAM_0603.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_PAM_0603.cs
  5. * 2.功能描述:工资调整
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2015/08/28 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Client.CommonModule;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.WCF.Proxys;
  16. using Dongke.IBOSS.PRD.Basics.BaseControls;
  17. using Dongke.IBOSS.PRD.Basics.DockPanel;
  18. namespace Dongke.IBOSS.PRD.Client.PAMModule
  19. {
  20. /// <summary>
  21. /// 工资调整
  22. /// </summary>
  23. public partial class F_PAM_0603 : DockPanelBase
  24. {
  25. #region 成员变量
  26. //单例模式
  27. private static F_PAM_0603 _instance;
  28. // 最后选择行
  29. private int _selecedRow;
  30. #endregion
  31. #region 构造函数
  32. public F_PAM_0603()
  33. {
  34. InitializeComponent();
  35. this.Text = FormTitles.F_PAM_0603;
  36. this.gbxCondition.Text = Constant.LABEL_QUERY_CONDITIONS;
  37. }
  38. #endregion
  39. #region 单例模式
  40. /// <summary>
  41. /// 单例模式,防止重复创建窗体
  42. /// </summary>
  43. public static F_PAM_0603 Instance
  44. {
  45. get
  46. {
  47. if (_instance == null)
  48. {
  49. _instance = new F_PAM_0603();
  50. }
  51. return _instance;
  52. }
  53. }
  54. #endregion
  55. #region 事件
  56. /// <summary>
  57. /// 窗体加载
  58. /// </summary>
  59. private void F_PAM_0201_Load(object sender, EventArgs e)
  60. {
  61. this.dgvPayroll.AutoGenerateColumns = false;
  62. DateTime dt = DateTime.Now.Date;
  63. dtpStartTime.Value = new DateTime(dt.Year, dt.Month, 1);
  64. }
  65. /// <summary>
  66. /// 关闭窗体事件
  67. /// </summary>
  68. private void tsbtnClose_Click(object sender, EventArgs e)
  69. {
  70. this.Close();
  71. }
  72. /// <summary>
  73. /// 自适应事件
  74. /// </summary>
  75. private void tsbtnAdaptive_Click(object sender, EventArgs e)
  76. {
  77. //this.dgvJobsPayPlan.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells); ;
  78. }
  79. /// <summary>
  80. /// 窗体关闭事件
  81. /// </summary>
  82. private void F_PAM_0201_FormClosed(object sender, FormClosedEventArgs e)
  83. {
  84. _instance = null;
  85. }
  86. /// <summary>
  87. /// 搜索按钮事件
  88. /// </summary>
  89. /// <param name="sender"></param>
  90. /// <param name="e"></param>
  91. private void btnSearch_Click_1(object sender, EventArgs e)
  92. {
  93. try
  94. {
  95. DataTable dt = dgvPayroll.DataSource as DataTable;
  96. if (dt == null || dt.Rows.Count == 0)
  97. {
  98. return;
  99. }
  100. int returnValue = (int)DoAsync(new AsyncMethod(() =>
  101. {
  102. return PAMModuleProxy.Service.SavePayrollChange(dt);
  103. }));
  104. if (returnValue > 0) //等于O,表示未修改数据,影响行为0
  105. {
  106. // 提示信息
  107. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, this.Text, "保存"),
  108. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  109. }
  110. btnSearch_Click(sender, e);
  111. }
  112. catch (Exception ex)
  113. {
  114. // 对异常进行共通处理
  115. ExceptionManager.HandleEventException(this.ToString(),
  116. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  117. }
  118. }
  119. /// <summary>
  120. ///
  121. /// </summary>
  122. /// <param name="sender"></param>
  123. /// <param name="e"></param>
  124. private void dgvPayroll_SelectionChanged(object sender, EventArgs e)
  125. {
  126. try
  127. {
  128. if (this.dgvPayroll.CurrentCell != null)
  129. {
  130. //if (!this.tsbtnClose.ReadOnly)
  131. //{
  132. this._selecedRow = this.dgvPayroll.CurrentCell.RowIndex;
  133. //this.dgvDefect.DataSource = null;
  134. int staffid = Convert.ToInt32(this.dgvPayroll.Rows[_selecedRow].Cells["staffid"].Value.ToString());
  135. string yyyymm = this.dgvPayroll.Rows[_selecedRow].Cells["YYYYMM"].Value.ToString();
  136. DataSet ds = (DataSet)DoAsync(new AsyncMethod(() =>
  137. {
  138. return PAMModuleProxy.Service.GetPayrollInfo(yyyymm, staffid);
  139. }));
  140. if (ds != null)
  141. {
  142. //this.dgvInCheckededDetail.DataSource = ds.Tables[0];
  143. //this.dgvInCheckedWinDetail.DataSource = ds.Tables[1];
  144. //this.c_DataGridView1.DataSource = ds.Tables[2];
  145. //this.c_DataGridView2.DataSource = ds.Tables[3];
  146. }
  147. //}
  148. }
  149. }
  150. catch (Exception ex)
  151. {
  152. // 对异常进行共通处理
  153. ExceptionManager.HandleEventException(this.ToString(),
  154. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  155. }
  156. }
  157. /// <summary>
  158. /// 结算按钮事件
  159. /// </summary>
  160. /// <param name="sender"></param>
  161. /// <param name="e"></param>
  162. private void tsbtnPay_Click(object sender, EventArgs e)
  163. {
  164. }
  165. /// <summary>
  166. /// 搜索按钮事件
  167. /// </summary>
  168. /// <param name="sender"></param>
  169. /// <param name="e"></param>
  170. private void btnSearch_Click(object sender, EventArgs e)
  171. {
  172. try
  173. {
  174. // 记录当前选中行
  175. int selectRowIndex = this._selecedRow;
  176. // 异步处理
  177. this.btnSearch.Enabled = false;
  178. string year = dtpStartTime.Value.Year.ToString();
  179. string month = dtpStartTime.Value.Month.ToString().Length < 2 ? "0" + dtpStartTime.Value.Month.ToString() : dtpStartTime.Value.Month.ToString();
  180. DataSet dsProductionData = (DataSet)DoAsync(new AsyncMethod(() =>
  181. {
  182. return PAMModuleProxy.Service.GetPayroll(year + month);
  183. }));
  184. this.btnSearch.Enabled = true;
  185. if (dsProductionData != null)
  186. {
  187. //DataView dv = dsProductionData.Tables[0].DefaultView;
  188. //dv.RowFilter = "ADAmount=0";
  189. //DataSet ds = new DataSet();
  190. //ds.Tables.Add(dv.ToTable());
  191. foreach (DataRow r in dsProductionData.Tables[0].Rows)
  192. {
  193. r["TotalAmount"] = Convert.ToDecimal(r["Piecework"]) + Convert.ToDecimal(r["DamageSubsidy"]) + Convert.ToDecimal(r["RepairSubsidy"])
  194. + Convert.ToDecimal(r["QualityEXA"]) + Convert.ToDecimal(r["AdminEXA"]) + Convert.ToDecimal(r["ADAmount"]);
  195. }
  196. base.DataSource = dsProductionData;
  197. if (this.DataSource != null && this.DataSource.Tables.Count > Constant.INT_IS_ZERO)
  198. {
  199. this.dgvPayroll.DataSource = this.DataSource.Tables[0];
  200. if (this.DataSource.Tables[0].Rows.Count <= Constant.INT_IS_ZERO)
  201. {
  202. // 提示未查找到数据
  203. MessageBox.Show(Messages.MSG_CMN_I002, this.Text,
  204. MessageBoxButtons.OK, MessageBoxIcon.Information);
  205. }
  206. else
  207. {
  208. if (selectRowIndex >= Constant.INT_IS_ZERO)
  209. {
  210. if (selectRowIndex >= dsProductionData.Tables[0].Rows.Count)
  211. {
  212. // this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Selected = true;
  213. this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[this.dgvPayroll.Rows.Count - 1].Cells["YYYYMM"];
  214. }
  215. else
  216. {
  217. //this.dgvPayroll.Rows[selectRowIndex].Selected = true;
  218. this.dgvPayroll.CurrentCell = this.dgvPayroll.Rows[selectRowIndex].Cells["YYYYMM"];
  219. }
  220. }
  221. }
  222. }
  223. }
  224. foreach (DataGridViewRow row in this.dgvPayroll.Rows)
  225. {
  226. // 未注浆的,不能编辑
  227. object groutingFlag = row.Cells["AuditStatus"].Value;
  228. if (groutingFlag.ToString() == "1")
  229. {
  230. row.Cells["ADAmount"].ReadOnly = true;
  231. row.Cells["Remarks"].ReadOnly = true;
  232. }
  233. }
  234. this.dgvPayroll.IsSetInputColumnsColor = true;
  235. }
  236. catch (Exception ex)
  237. {
  238. this.btnSearch.Enabled = true;
  239. // 对异常进行共通处理
  240. ExceptionManager.HandleEventException(this.ToString(),
  241. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  242. }
  243. }
  244. #endregion
  245. private void tsbtnClose_Click_1(object sender, EventArgs e)
  246. {
  247. this.Close();
  248. }
  249. /// <summary>
  250. /// 自动列宽
  251. /// </summary>
  252. /// <param name="sender"></param>
  253. /// <param name="e"></param>
  254. private void tsbtnAdaptive_Click_1(object sender, EventArgs e)
  255. {
  256. this.dgvPayroll.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
  257. }
  258. private void F_PAM_0603_Shown(object sender, EventArgs e)
  259. {
  260. this.dgvPayroll.IsSetInputColumnsColor = true;
  261. }
  262. private void dgvPayroll_CellValidated(object sender, DataGridViewCellEventArgs e)
  263. {
  264. try
  265. {
  266. if (e.RowIndex < 0)
  267. {
  268. return;
  269. }
  270. DataGridViewRow rowItem = this.dgvPayroll.Rows[e.RowIndex];
  271. DataGridViewColumn columnItem = dgvPayroll.Columns[e.ColumnIndex];
  272. if ("ADAmount" == columnItem.Name)
  273. {
  274. object ADAmount = rowItem.Cells[e.ColumnIndex].FormattedValue;
  275. if (ADAmount == null || ADAmount.ToString() == string.Empty)
  276. {
  277. rowItem.Cells["ADAmount"].Value = 0;
  278. }
  279. //r["TotalAmount"] = Convert.ToDecimal(r["Piecework"]) + Convert.ToDecimal(r["DamageSubsidy"]) + Convert.ToDecimal(r["RepairSubsidy"])
  280. // + Convert.ToDecimal(r["QualityEXA"]) + Convert.ToDecimal(r["AdminEXA"]) + Convert.ToDecimal(r["QualityEXA"]) + Convert.ToDecimal(r["ADAmount"]);
  281. rowItem.Cells["TotalAmount"].Value =
  282. Convert.ToDecimal(rowItem.Cells["Piecework"].Value) + Convert.ToDecimal(rowItem.Cells["DamageSubsidy"].Value)
  283. + Convert.ToDecimal(rowItem.Cells["RepairSubsidy"].Value) + Convert.ToDecimal(rowItem.Cells["QualityEXA"].Value)
  284. + Convert.ToDecimal(rowItem.Cells["AdminEXA"].Value) + Convert.ToDecimal(rowItem.Cells["ADAmount"].Value)
  285. ;
  286. }
  287. }
  288. catch (Exception ex)
  289. {
  290. // 对异常进行共通处理
  291. ExceptionManager.HandleEventException(this.ToString(),
  292. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  293. }
  294. }
  295. private void dgvPayroll_Sorted(object sender, EventArgs e)
  296. {
  297. foreach (DataGridViewRow row in this.dgvPayroll.Rows)
  298. {
  299. // 未注浆的,不能编辑
  300. object groutingFlag = row.Cells["AuditStatus"].Value;
  301. if (groutingFlag.ToString() == "1")
  302. {
  303. row.Cells["ADAmount"].ReadOnly = true;
  304. row.Cells["Remarks"].ReadOnly = true;
  305. }
  306. }
  307. this.dgvPayroll.IsSetInputColumnsColor = true;
  308. }
  309. }
  310. }