FrmStaffAwardPunish.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. using LYFZ.ComponentLibrary;
  2. using System;
  3. using System.Collections;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.FinancialManagement
  12. {
  13. public partial class FrmStaffAwardPunish : LYFZ.Software.UI.FinancialManagement.FrmStaffAwardPunish
  14. {
  15. LYFZ.BLL.BLL_ErpRewardPunishment rpbll = new BLL.BLL_ErpRewardPunishment();
  16. public FrmStaffAwardPunish()
  17. {
  18. this.Shown += FrmStaffAwardPunish_Shown;
  19. this.btnQuery.Click += btnQuery_Click;
  20. this.btnEntry.Click += btnEntry_Click;
  21. this.btnUpdate.Click += btnUpdate_Click;
  22. this.dgvData.MouseDoubleClick += dgvData_MouseDoubleClick;
  23. this.btnDelete.Click += btnDelete_Click;
  24. this.btnClose.Click += btnClose_Click;
  25. this.chkPenalty.Click += chkPenalty_Click;
  26. this.chkReward.Click += chkReward_Click;
  27. this.chkExecuteNot.Click += chkExecuteNot_Click;
  28. this.chkExecuteOK.Click += chkExecuteOK_Click;
  29. this.btn_print.Click += btn_print_Click;
  30. this.Resize += FrmStaffAwardPunish_Resize;
  31. }
  32. /// <summary>
  33. /// 打印员工奖罚单;
  34. /// </summary>
  35. /// <param name="sender"></param>
  36. /// <param name="e"></param>
  37. void btn_print_Click(object sender, EventArgs e)
  38. {
  39. if ( dgvData.CurrentRow != null )
  40. {
  41. Hashtable hashtable = new Hashtable();
  42. hashtable["CurrentRow"] = dgvData.CurrentRow;
  43. LYFZ.Software.MainBusiness.ReportPrint.ReportFixedFormat.PrintFixedFormat(LYFZ.EnumPublic.PrintTypeEnum.员工奖罚, hashtable);
  44. }
  45. else
  46. {
  47. MessageBox.Show("请选择要打印的行");
  48. }
  49. }
  50. /// <summary>
  51. /// 窗体加载事件
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. void FrmStaffAwardPunish_Shown(object sender, EventArgs e)
  56. {
  57. this.dtpDateTimeStart.DateValue = SDateTime.Now.ToString("yyyy-MM-dd");
  58. this.dtpDateTimeEnd.DateValue = this.dtpDateTimeStart.DateValue;
  59. LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.BindComboBoxTreeView_DepartmentAndEmployee(this.cmbtreevPenaltyAndRewardName, IsFirstNodeNull: true, IsShowResign: false);
  60. this.btnEntry.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StaffAwardPunishCompetence, CustomAttributes.OperatingAuthority.Add);
  61. this.btnUpdate.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StaffAwardPunishCompetence, CustomAttributes.OperatingAuthority.Update);
  62. this.btnDelete.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.StaffAwardPunishCompetence, CustomAttributes.OperatingAuthority.Delete);
  63. this.PublicFunctionRows();
  64. ///控制财务管理员工奖罚薪资执行的版本权
  65. List<Control> hideControl = new List<Control>();
  66. //LYFZSS.SystemSpecterPossessed.ISystemSpecterPossessed.GetMySystemSpecter = LYFZSS.SystemSpecterType.SST_D;
  67. hideControl.Add(this.chkExecuteOK);
  68. LYFZ.Software.MainBusiness.VersionControl.StaticVersion.BindVersionShowHideControl(VersionControl.VersionFunctionEnum.财务管理薪资执行, hideControl, null, null);
  69. }
  70. /// <summary>
  71. /// 查询
  72. /// </summary>
  73. /// <param name="sender"></param>
  74. /// <param name="e"></param>
  75. void btnQuery_Click(object sender, EventArgs e)
  76. {
  77. this.PublicFunctionRows();
  78. }
  79. /// <summary>
  80. /// 录入
  81. /// </summary>
  82. /// <param name="sender"></param>
  83. /// <param name="e"></param>
  84. void btnEntry_Click(object sender, EventArgs e)
  85. {
  86. LYFZ.Software.MainBusiness.FinancialManagement.StaffAwardPunish.FrmStaffAwardPunishEntry frm = new StaffAwardPunish.FrmStaffAwardPunishEntry();
  87. frm.ShowDialog();
  88. if (frm.IsSaveed)
  89. { this.PublicFunctionRows(); }
  90. }
  91. /// <summary>
  92. /// 修改
  93. /// </summary>
  94. /// <param name="sender"></param>
  95. /// <param name="e"></param>
  96. void btnUpdate_Click(object sender, EventArgs e)
  97. {
  98. if (this.dgvData.SelectedRows.Count == 0)
  99. { MessageBoxCustom.Show("请选择你要修改的数据!"); return; }
  100. LYFZ.Software.MainBusiness.FinancialManagement.StaffAwardPunish.FrmStaffAwardPunishUpdate frm = new StaffAwardPunish.FrmStaffAwardPunishUpdate();
  101. frm.StrOrderID = this.dgvData.CurrentRow.Cells["ID"].Value.ToString();
  102. frm.ShowDialog();
  103. if (frm.IsSaveed)
  104. { this.PublicFunctionRows(); }
  105. }
  106. /// <summary>
  107. /// 双击列表修改
  108. /// </summary>
  109. /// <param name="sender"></param>
  110. /// <param name="e"></param>
  111. void dgvData_MouseDoubleClick(object sender, MouseEventArgs e)
  112. {
  113. if (e.Location.Y > this.dgvData.ColumnHeadersHeight)
  114. {
  115. if (this.dgvData.SelectedRows.Count == 0)
  116. { MessageBoxCustom.Show("请选择你要修改的数据!"); return; }
  117. this.btnUpdate_Click(this, null);
  118. }
  119. }
  120. /// <summary>
  121. /// 删除
  122. /// </summary>
  123. /// <param name="sender"></param>
  124. /// <param name="e"></param>
  125. void btnDelete_Click(object sender, EventArgs e)
  126. {
  127. if (this.dgvData.SelectedRows.Count == 0)
  128. { MessageBoxCustom.Show("请选择你要删除的数据!"); return; }
  129. if (MessageBoxCustom.Show("你确定要删除吗?", "删除提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  130. {
  131. if (rpbll.Delete(Convert.ToInt32(this.dgvData.CurrentRow.Cells["ID"].Value)))
  132. {
  133. // 写入操作日志
  134. string logsContent = "删除奖罚相关人员:" + this.dgvData.CurrentRow.Cells["相关人员"].Value.ToString() + " 金额为:" + this.dgvData.CurrentRow.Cells["奖罚金额"].Value.ToString();
  135. LYFZ.BLL.BLL_ErpSystemLogs.WriteSystemLog(LYFZ.EnumPublic.SystemLogsType.删除员工奖罚, logsContent, LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID, LYFZ.BLL.BLL_ErpUser.UsersModel.User_Name);
  136. MessageBoxCustom.Show("删除成功!");
  137. this.PublicFunctionRows();
  138. }
  139. }
  140. }
  141. /// <summary>
  142. /// 关闭
  143. /// </summary>
  144. /// <param name="sender"></param>
  145. /// <param name="e"></param>
  146. void btnClose_Click(object sender, EventArgs e)
  147. {
  148. this.Close();
  149. }
  150. /// <summary>
  151. /// 奖
  152. /// </summary>
  153. /// <param name="sender"></param>
  154. /// <param name="e"></param>
  155. void chkPenalty_Click(object sender, EventArgs e)
  156. {
  157. this.chkExecuteNot.Checked = false;
  158. this.chkExecuteOK.Checked = false;
  159. this.chkReward.Checked = false;
  160. this.PublicFunctionRows();
  161. }
  162. /// <summary>
  163. /// 惩
  164. /// </summary>
  165. /// <param name="sender"></param>
  166. /// <param name="e"></param>
  167. void chkReward_Click(object sender, EventArgs e)
  168. {
  169. this.chkExecuteNot.Checked = false;
  170. this.chkExecuteOK.Checked = false;
  171. this.chkPenalty.Checked = false;
  172. this.PublicFunctionRows();
  173. }
  174. /// <summary>
  175. /// 未执行
  176. /// </summary>
  177. /// <param name="sender"></param>
  178. /// <param name="e"></param>
  179. void chkExecuteNot_Click(object sender, EventArgs e)
  180. {
  181. this.chkReward.Checked = false;
  182. this.chkExecuteOK.Checked = false;
  183. this.chkPenalty.Checked = false;
  184. this.PublicFunctionRows();
  185. }
  186. /// <summary>
  187. /// 已执行
  188. /// </summary>
  189. /// <param name="sender"></param>
  190. /// <param name="e"></param>
  191. void chkExecuteOK_Click(object sender, EventArgs e)
  192. {
  193. this.chkReward.Checked = false;
  194. this.chkExecuteNot.Checked = false;
  195. this.chkPenalty.Checked = false;
  196. this.PublicFunctionRows();
  197. }
  198. /// <summary>
  199. /// 窗体大小发生变化
  200. /// </summary>
  201. /// <param name="sender"></param>
  202. /// <param name="e"></param>
  203. void FrmStaffAwardPunish_Resize(object sender, EventArgs e)
  204. {
  205. switch (this.panelExecuteOK.Location.Y)
  206. {
  207. case 5: this.flowLayoutPanel1.Height = 40; break;
  208. case 39: this.flowLayoutPanel1.Height = 73; break;
  209. }
  210. }
  211. /// <summary>
  212. /// 绑定数据
  213. /// </summary>
  214. void PublicFunctionRows()
  215. {
  216. string StrWhere = " Where 1 = 1";
  217. if (!string.IsNullOrEmpty(this.cmbtreevPenaltyAndRewardName.Text.Trim()))
  218. { StrWhere += " And Rp_RelevantPeople='" + this.cmbtreevPenaltyAndRewardName.Tag.ToString().Trim() + "'"; }
  219. if (this.chkPenalty.Checked)
  220. { StrWhere += " And Rp_Type='惩罚'"; }
  221. if (this.chkReward.Checked)
  222. { StrWhere += " And Rp_Type='奖励'"; }
  223. if (this.chkExecuteNot.Checked)
  224. { StrWhere += " And Rp_Status='" + this.chkExecuteNot.Text.Trim() + "'"; }
  225. if (this.chkExecuteOK.Checked)
  226. { StrWhere += " And Rp_Status='" + this.chkExecuteOK.Text.Trim() + "'"; }
  227. if (!string.IsNullOrEmpty(this.dtpDateTimeStart.DateValue) && !string.IsNullOrEmpty(this.dtpDateTimeEnd.DateValue))
  228. { StrWhere += LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetDateTime("Rp_RPDatetime", this.dtpDateTimeStart.DateValue, this.dtpDateTimeEnd.DateValue); }
  229. DataTable newTable = new DataTable();
  230. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  231. {
  232. newTable = LYFZ.BLL.BLL_ErpOrderView.GetData_FinancialManagementUserRewardPunishment(StrWhere, "");
  233. });
  234. #region
  235. this.dgvData.DataColumns(newTable.Columns, strHideField: "ID");
  236. this.dgvData.Columns["相关人员"].Width = 120;
  237. this.dgvData.Columns["执行日期"].Width = 120;
  238. this.dgvData.Columns["奖罚类型"].Width = 120;
  239. this.dgvData.Columns["奖罚金额"].Width = 120;
  240. this.dgvData.Columns["是否执行"].Width = 120;
  241. this.dgvData.Columns["录单人"].Width = 120;
  242. this.dgvData.FillLastColumn();
  243. for (int t = 0; t < newTable.Rows.Count; t++)
  244. {
  245. DataGridViewRow dgvr = new DataGridViewRow();
  246. DataGridViewCell cell = null;
  247. cell = new DataGridViewTextBoxCell();
  248. cell.Value = newTable.Rows[t]["ID"].ToString().Trim(); ;
  249. dgvr.Cells.Add(cell);
  250. cell = new DataGridViewTextBoxCell();
  251. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(newTable.Rows[t]["相关人员"]);
  252. dgvr.Cells.Add(cell);
  253. cell = new DataGridViewTextBoxCell();
  254. cell.Value = newTable.Rows[t]["奖罚类型"].ToString().Trim();
  255. dgvr.Cells.Add(cell);
  256. cell = new DataGridViewTextBoxCell();
  257. cell.Value = newTable.Rows[t]["奖罚金额"].ToString().Trim();
  258. dgvr.Cells.Add(cell);
  259. cell = new DataGridViewTextBoxCell();
  260. cell.Value = newTable.Rows[t]["是否执行"].ToString().Trim();
  261. dgvr.Cells.Add(cell);
  262. cell = new DataGridViewTextBoxCell();
  263. cell.Value = Convert.ToDateTime(newTable.Rows[t]["执行日期"]).ToString("yyyy-MM-dd");
  264. dgvr.Cells.Add(cell);
  265. cell = new DataGridViewTextBoxCell();
  266. cell.Value = LYFZ.Software.MainBusiness.DoorCityProcess.PublicCodeClasses.GetUserName(newTable.Rows[t]["录单人"]);
  267. dgvr.Cells.Add(cell);
  268. cell = new DataGridViewTextBoxCell();
  269. cell.Value = newTable.Rows[t]["备注"].ToString().Trim();
  270. dgvr.Cells.Add(cell);
  271. this.dgvData.Rows.Add(dgvr);
  272. }
  273. #endregion
  274. this.dgvData.ClearSelection();
  275. }
  276. }
  277. }