frmMattersApply.cs 15 KB

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