frmRequestLeaveList.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using LYFZ.BLL;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.ComponentModel;
  5. using System.Data;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. namespace LYFZ.Software.MainBusiness.OAShopManagement
  10. {
  11. public class frmRequestLeaveList : LYFZ.Software.UI.OAShopManagement.frmRequestLeaveList
  12. {
  13. /// <summary>
  14. /// 当前事项角色
  15. /// </summary>
  16. MattersApplyType currentMatterRole = MattersApplyType.申请人;
  17. /// <summary>
  18. /// 不当查询的审核状态
  19. /// </summary>
  20. state currentAuditStatus = state.申请中;
  21. public frmRequestLeaveList(string parameter)
  22. :this()
  23. {
  24. this.currentMatterRole = (MattersApplyType)Enum.Parse(typeof(MattersApplyType), parameter);
  25. }
  26. public frmRequestLeaveList() {
  27. //我要申请
  28. this.btnAddApplication.Click += btnAddTask_Click;
  29. //审批申请
  30. this.btnApproving.Click += btnApproving_Click;
  31. //删除申请
  32. this.btndel.Click += btndel_Click;
  33. //关闭
  34. this.btnClose.Click += btnClose_Click;
  35. //dgv事件
  36. this.dgvTaskView.CellDoubleClick += dgvTaskView_CellDoubleClick;
  37. // this.dgvTaskView.RowsAdded += dgvTaskView_RowsAdded;
  38. //加载事件
  39. this.Load += frmMattersApply_Load;
  40. this.ucMatt.EventPaging += ucMatt_EventPaging;
  41. this.btnAddApplication.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Add);
  42. this.btndel.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Delete);
  43. this.btnApproving.Enabled = LYFZ.BLL.BLL_ErpUser.GetRights(LYFZ.BLL.BLL_ErpUser.CurrentUserRights.RequestLeave, CustomAttributes.OperatingAuthority.Audit);
  44. this.ucMatt.PageSize = LYFZ.BLL.BLL_SystemGlobalSetting.SysTemGlobalSetMoel.ReportFormPageSize;
  45. this.rdoapply.Click += RdoClick_Click;
  46. this.rdopassed.Click += RdoClick_Click;
  47. this.rdoNotpassed.Click += RdoClick_Click;
  48. }
  49. void RdoClick_Click(object sender, EventArgs e)
  50. {
  51. ComponentLibrary.RadioButtonEx rdoBtn = (ComponentLibrary.RadioButtonEx)sender;
  52. if (rdoBtn.Checked)
  53. {
  54. this.currentAuditStatus = (state)Convert.ToInt32(rdoBtn.Tag);
  55. }
  56. ucMatt.Bind();
  57. }
  58. //void dgvTaskView_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
  59. //{
  60. // if (!string.IsNullOrEmpty(this.dgvTaskView.Rows[e.RowIndex].Cells["Column5"].Value.ToString().Trim()))
  61. // {
  62. // this.dgvTaskView.Rows[e.RowIndex].Cells["Column5"].Value = LYFZ.Command.Command_Validate.DateTimeToString(this.dgvTaskView.Rows[e.RowIndex].Cells["Column5"].Value, "yyyy-MM-dd HH:mm");
  63. // }
  64. //}
  65. string GetWhereString()
  66. {
  67. string whereStr = " 1=1 ";//"Matter_Type=1 ";
  68. if (currentMatterRole == MattersApplyType.申请人)
  69. {
  70. whereStr += " and Matter_CreateName='" + LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID.Trim() + "'";
  71. }
  72. else if(currentMatterRole == MattersApplyType.审核人){
  73. whereStr += " and Matter_UpdateName='" + LYFZ.BLL.BLL_ErpUser.UsersModel.User_EmployeeID.Trim() + "'";
  74. }
  75. whereStr += " and Matter_state='" + this.currentAuditStatus.ToString().Trim() + "'";
  76. return whereStr;
  77. }
  78. public int ucMatt_EventPaging(UCPager.EventPagingArg e)
  79. {
  80. LYFZ.UCPager.PageData pageData = new LYFZ.UCPager.PageData();
  81. pageData.TableName = "tb_ErpShopEvententry";
  82. pageData.PageIndex = this.ucMatt.PageCurrent;
  83. pageData.PageSize = this.ucMatt.PageSize;
  84. pageData.QueryCondition = GetWhereString();
  85. pageData.QueryFieldName = " [ID]"
  86. +" ,[Matter_CreateName]"
  87. +" ,[Matter_CreateDatetime]"
  88. +" ,[Matter_content]"
  89. +" ,[Matter_state]"
  90. +" ,[Matter_UpdateName]"
  91. +" ,[Matter_UpdateDatetime]"
  92. +" ,[Matter_opinion]"
  93. +" ,[Matter_Type]"
  94. +" ,[Matter_Category]"
  95. +" ,[Matter_Title]"
  96. +" ,[Matter_StarLeaveTime]"
  97. +" ,[Matter_EndLeaveTime]"
  98. +" ,[Matter_LeadershipInstruction]"
  99. +" ,[Matter_InstructedPeople]"
  100. +" ,[Matter_InstructedTime] ";
  101. pageData.OrderStr = "ID desc";
  102. DataTable dt = null;
  103. LYFZ.ComponentLibrary.FrmLoadHandling.LoadDoWorkMethod(delegate(object obj, BackgroundWorker backgroundWorker)
  104. {
  105. dt = pageData.QueryDataTable().Tables[0];
  106. });
  107. try
  108. {
  109. if (dt != null)
  110. {
  111. this.dgvTaskView.Rows.Clear();
  112. for (int i = 0; i < dt.Rows.Count; i++)
  113. {
  114. DataGridViewRow row = new DataGridViewRow();
  115. row.CreateCells(this.dgvTaskView);
  116. row.Tag = dt.Rows[i];
  117. row.Cells[0].Value = dt.Rows[i]["ID"].ToString();
  118. row.Cells[1].Value = LYFZ.BLL.WageStatisticsProcess.GetClassCodeToCalssName(dt.Rows[i]["Matter_Category"].ToString());
  119. string Matter_Title = "无主题";
  120. if (dt.Rows[i]["Matter_Title"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Matter_Title"].ToString().Trim()))
  121. {
  122. Matter_Title = dt.Rows[i]["Matter_Title"].ToString();
  123. }
  124. row.Cells[2].Value = Matter_Title;
  125. row.Cells[3].Value = dt.Rows[i]["Matter_content"].ToString();
  126. if (LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_StarLeaveTime"], "yyyy-MM-dd HH:mm") == "")
  127. {
  128. row.Cells[4].Value = "";
  129. }
  130. else
  131. {
  132. row.Cells[4].Value = "从【" + LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_StarLeaveTime"], "yyyy-MM-dd HH:mm")
  133. + "】至【"
  134. + LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_EndLeaveTime"], "yyyy-MM-dd HH:mm") + "】";
  135. }
  136. row.Cells[5].Value = UserIDToName(dt.Rows[i]["Matter_CreateName"]);
  137. row.Cells[5].Tag = dt.Rows[i]["Matter_CreateName"].ToString();
  138. row.Cells[6].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_CreateDatetime"], "yyyy-MM-dd HH:mm");
  139. row.Cells[7].Value = dt.Rows[i]["Matter_state"].ToString();
  140. row.Cells[8].Value = UserIDToName(dt.Rows[i]["Matter_UpdateName"]);
  141. row.Cells[8].Tag = dt.Rows[i]["Matter_UpdateName"].ToString();
  142. row.Cells[9].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_UpdateDatetime"], "yyyy-MM-dd HH:mm");
  143. if (dt.Rows[i]["Matter_opinion"] != null)
  144. {
  145. row.Cells[10].Value = dt.Rows[i]["Matter_opinion"].ToString();
  146. }
  147. if (dt.Rows[i]["Matter_LeadershipInstruction"] != null)
  148. {
  149. row.Cells[11].Value = dt.Rows[i]["Matter_LeadershipInstruction"].ToString();
  150. }
  151. if (dt.Rows[i]["Matter_InstructedPeople"] != null)
  152. {
  153. row.Cells[12].Value = UserIDToName(dt.Rows[i]["Matter_InstructedPeople"]);
  154. row.Cells[12].Tag = dt.Rows[i]["Matter_InstructedPeople"].ToString();
  155. }
  156. row.Cells[13].Value = LYFZ.Command.Command_Validate.DateTimeToString(dt.Rows[i]["Matter_InstructedTime"], "yyyy-MM-dd HH:mm");
  157. this.dgvTaskView.Rows.Add(row);
  158. }
  159. this.ucMatt.TbDataSource = dt;
  160. }
  161. }
  162. catch (Exception ex){
  163. MessageBoxCustom.Show("加载数据出错:"+ex.Message);
  164. }
  165. return pageData.TotalCount;
  166. }
  167. string UserIDToName(object uid)
  168. {
  169. if (uid != null)
  170. {
  171. return UserIDToName(uid.ToString());
  172. }
  173. else {
  174. return "";
  175. }
  176. }
  177. public static string UserIDToName(string uid)
  178. {
  179. DataRow row = LYFZ.DAL.DAL_ErpUser.SimpleUserDataTable.Rows.Find(uid);
  180. if (row != null)
  181. {
  182. return row["User_Name"].ToString();
  183. }
  184. else {
  185. return "";
  186. }
  187. }
  188. //页面加载事件
  189. void frmMattersApply_Load(object sender, EventArgs e)
  190. {
  191. bool b;
  192. this.UcNavigationTool.LabTitle = "请假审批";
  193. switch (currentMatterRole)
  194. {
  195. case MattersApplyType.批示领导:
  196. this.tpMyApplication.Text = "请假审批管理";
  197. this.btnAddApplication.Visible = false;
  198. this.btnApproving.Visible = true;
  199. this.btndel.Visible = true;
  200. b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理请假申请管理);
  201. if (!b)
  202. {
  203. this.Close();
  204. return;
  205. }
  206. break;
  207. case MattersApplyType.申请人:
  208. this.UcNavigationTool.LabTitle = "请假申请";
  209. this.tpMyApplication.Text = "我的请假申请";
  210. this.btnAddApplication.Visible = true;
  211. this.btnApproving.Visible = false;
  212. this.btndel.Visible = true;
  213. b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理请假申请);
  214. if (!b)
  215. {
  216. this.Close();
  217. return;
  218. }
  219. break;
  220. case MattersApplyType.审核人:
  221. this.tpMyApplication.Text = "请假审批";
  222. this.btnAddApplication.Visible = false;
  223. this.btnApproving.Visible = true;
  224. this.btndel.Visible = false;
  225. b = LYFZ.Software.MainBusiness.VersionControl.StaticVersion.UIFunctionVersion(VersionControl.VersionFunctionEnum.店务管理请假审批);
  226. if (!b)
  227. {
  228. this.Close();
  229. return;
  230. }
  231. break;
  232. }
  233. ucMatt.Bind();
  234. }
  235. /// <summary>
  236. /// 公共刷新方法
  237. /// </summary>
  238. public void refresh()
  239. {
  240. ucMatt.Bind();
  241. }
  242. //dgv双击事件
  243. void dgvTaskView_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
  244. {
  245. if (this.currentMatterRole == MattersApplyType.申请人 && this.currentAuditStatus != state.申请通过)
  246. {
  247. if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
  248. {
  249. frmAddRequestLeave releaseApply = new frmAddRequestLeave();
  250. releaseApply.ID = this.dgvTaskView.CurrentRow.Cells["ID"].Value.ToString();
  251. if (releaseApply.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  252. {
  253. ucMatt.Bind();
  254. }
  255. }
  256. }
  257. }
  258. //关闭
  259. void btnClose_Click(object sender, EventArgs e)
  260. {
  261. this.Close();
  262. }
  263. /// <summary>
  264. /// 删除事件
  265. /// </summary>
  266. /// <param name="sender"></param>
  267. /// <param name="e"></param>
  268. void btndel_Click(object sender, EventArgs e)
  269. {
  270. if (this.currentMatterRole == MattersApplyType.申请人 || this.currentMatterRole == MattersApplyType.批示领导)
  271. {
  272. if (this.currentMatterRole == MattersApplyType.申请人 && this.currentAuditStatus == state.申请通过)
  273. {
  274. MessageBoxCustom.Show("已通过申请事项不能删除");
  275. return;
  276. }
  277. if (this.dgvTaskView.SelectedRows != null && this.dgvTaskView.SelectedRows.Count > 0)
  278. {
  279. if (MessageBoxCustom.Show("是否删除?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
  280. {
  281. BLL_ErpShopEvententry bll = new BLL_ErpShopEvententry();
  282. bool ret = true;
  283. foreach (DataGridViewRow row in this.dgvTaskView.SelectedRows)
  284. {
  285. if (!bll.Delete(Convert.ToInt32(row.Cells["ID"].Value.ToString())))
  286. {
  287. ret = false;
  288. break;
  289. }
  290. }
  291. if (ret)
  292. {
  293. ucMatt.Bind();
  294. }
  295. else
  296. {
  297. MessageBoxCustom.Show("删除失败");
  298. }
  299. }
  300. }
  301. else
  302. { MessageBoxCustom.Show("请选中信息"); }
  303. }
  304. else
  305. {
  306. MessageBoxCustom.Show("审核人只能审核申请,不能删除申请");
  307. }
  308. }
  309. /// <summary>
  310. ///
  311. /// </summary>
  312. /// <param name="sender"></param>
  313. /// <param name="e"></param>
  314. void btnApproving_Click(object sender, EventArgs e)
  315. {
  316. if (this.dgvTaskView.SelectedRows != null && this.dgvTaskView.SelectedRows.Count > 0)
  317. {
  318. frmRequestLeaveView applyView = new frmRequestLeaveView();
  319. applyView.ID = dgvTaskView.CurrentRow.Cells["ID"].Value.ToString();
  320. applyView.ApplyType = this.currentMatterRole;
  321. if (applyView.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  322. {
  323. ucMatt.Bind();
  324. }
  325. }
  326. else
  327. {
  328. MessageBoxCustom.Show("请选择申请事项");
  329. }
  330. }
  331. /// <summary>
  332. /// 我要申请
  333. /// </summary>
  334. /// <param name="sender"></param>
  335. /// <param name="e"></param>
  336. void btnAddTask_Click(object sender, EventArgs e)
  337. {
  338. frmAddRequestLeave releaseApply = new frmAddRequestLeave();
  339. if (releaseApply.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  340. {
  341. ucMatt.Bind();
  342. }
  343. }
  344. }
  345. }