FrmSignaturePay.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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 CoreFS.CA06;
  10. using Infragistics.Win.UltraWinEditors;
  11. using Core.Mes.Client.Comm.Control;
  12. using Infragistics.Win.UltraWinGrid;
  13. using Core.Mes.Client.Comm.Tool;
  14. using Core.Mes.Client.Comm.Server;
  15. using CoreFS.SA06;
  16. using System.Collections;
  17. using Infragistics.Win;
  18. using System.IO;
  19. using Pur.Entity;
  20. using com.hnshituo.pur.vo;
  21. using Pur.configure;
  22. using Pur.PublicTools;
  23. using Pur.Pop_upWindow;
  24. namespace Pur
  25. {
  26. public partial class FrmSignaturePay : FrmPmsBase
  27. {
  28. public FrmSignaturePay()
  29. {
  30. InitializeComponent();
  31. }
  32. private void FrmSignaturePay_Load(object sender, EventArgs e)
  33. {
  34. DoQuery("");
  35. GridHelper.SetExcludeColumnsActive(ultraGrid1.DisplayLayout.Bands[0], new String[] { "TODEPT", "DEPTNAME", "ownername", "CERTPATH", "CERTDESC", "CHK" });
  36. }
  37. /// <summary>
  38. /// 重写基类方法
  39. /// </summary>
  40. /// <param name="sender"></param>
  41. /// <param name="ToolbarKey"></param>
  42. public override void ToolBar_Click(object sender, string ToolbarKey)
  43. {
  44. switch (ToolbarKey)
  45. {
  46. case "Query":
  47. DoQuery("");
  48. break;
  49. case "Add":
  50. DoSave();
  51. break;
  52. case "Delete":
  53. DoDelete();
  54. break;
  55. case "Close":
  56. this.Close();
  57. break;
  58. }
  59. }
  60. private void DoQuery(String strID)
  61. {
  62. SignaturePay sg = new SignaturePay();
  63. sg.Validflag = "1";
  64. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.configure.service.SignaturePayService", "get_SignaturePay", new object[] { sg});
  65. GridHelper.CopyDataToDatatable(dt, this.dataTable1, true);
  66. foreach (UltraGridRow ugr in ultraGrid1.Rows)
  67. {
  68. ugr.Cells["orgId"].Appearance.BackColor =Color.Transparent;
  69. ugr.Cells["orgId"].Appearance.BackHatchStyle = BackHatchStyle.Default;
  70. ugr.Cells["orgId"].Activation = Infragistics.Win.UltraWinGrid.Activation.ActivateOnly;
  71. }
  72. if (String.IsNullOrEmpty(strID))
  73. {
  74. publicPms.doActiveSelRow(ultraGrid1,"id",strID);
  75. }
  76. }
  77. private void DoSave()
  78. {
  79. ultraGrid1.UpdateData();
  80. ArrayList list = new ArrayList();
  81. string strid = "";
  82. //int count = 0;
  83. IQueryable<UltraGridRow> uGrid = ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  84. if (uGrid.Count() == 0)
  85. {
  86. MessageUtil.ShowTips("请选择要新增的数据!");
  87. return;
  88. }
  89. foreach (UltraGridRow ugr in uGrid)
  90. {
  91. String id = ugr.Cells["id"].Value.ToString().Trim();
  92. strid = id;
  93. String orgId = ugr.Cells["orgId"].Value.ToString().Trim();
  94. String orgName = ugr.Cells["orgName"].Value.ToString().Trim();
  95. String ownerUserid = ugr.Cells["ownerUserid"].Value.ToString().Trim();
  96. String ownerName = ugr.Cells["ownerName"].Value.ToString().Trim();
  97. String certDesc = ugr.Cells["certDesc"].Value.ToString().Trim();
  98. String deptName = ugr.Cells["DEPTNAME"].Text.ToString().Trim();
  99. String toDept = ugr.Cells["TODEPT"].Text.ToString().Trim();
  100. if (orgId == "") { MessageUtil.ShowTips("所属部门不能为空!"); return; }
  101. if (orgName == "") { MessageUtil.ShowTips("所属部门不能为空!"); return; }
  102. if (ownerUserid == "") { MessageUtil.ShowTips("所属人不能为空!"); return; }
  103. if (ownerName == "") { MessageUtil.ShowTips("所属人不能为空!"); return; }
  104. if (deptName == "") { MessageUtil.ShowTips("职位不能为空!"); return; }
  105. SignaturePay sg = new SignaturePay();
  106. sg.Validflag = "1";
  107. sg.OwnerUserid = ownerUserid;
  108. int count = this.execute<int>("com.hnshituo.pur.configure.service.SignaturePayService", "count", new object[] { sg });
  109. if (count <= 0) { MessageUtil.ShowTips("不存在用户:" + ownerName + "签名数据信息,不能进行此操作,请先上传签名文件!"); return; }
  110. SignaturePay sig = new SignaturePay();
  111. sig.Id = id;
  112. sig.CertDesc = certDesc;
  113. sig.OrgId = orgId;
  114. sig.OrgName = orgName;
  115. sig.OwnerName = ownerName;
  116. sig.OwnerUserid = ownerUserid;
  117. sig.UpdateUserid = UserInfo.GetUserID();
  118. sig.UpdateName = UserInfo.GetUserName();
  119. sig.UpdateTime = DateTime.Now;
  120. sig.DeptName = deptName;
  121. sig.ToDept = toDept;
  122. list.Add(sig);
  123. //}
  124. }
  125. if (list.Count <= 0)
  126. {
  127. MessageUtil.ShowTips("请选择要新增的数据!");
  128. return;
  129. }
  130. if (MessageUtil.ShowYesNoAndQuestion("是否保存签名?") == System.Windows.Forms.DialogResult.No) return;
  131. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SignaturePayService", "do_Save", new object[] { list });
  132. if (crt.Resultcode != 0)
  133. {
  134. MessageUtil.ShowTips("保存失败:"+crt.Resultmsg);
  135. return;
  136. }
  137. MessageUtil.ShowTips("操作成功");
  138. DoQuery(strid);
  139. }
  140. private void DoDelete()
  141. {
  142. ultraGrid1.UpdateData();
  143. ArrayList pram = new ArrayList();
  144. IQueryable<UltraGridRow> uGrid = ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  145. if (uGrid.Count() == 0)
  146. {
  147. MessageUtil.ShowTips("请选择要删除的数据!");
  148. return;
  149. }
  150. if (MessageUtil.ShowYesNoAndQuestion("是否确认删除签名文件?") != DialogResult.Yes)
  151. {
  152. return;
  153. }
  154. foreach (UltraGridRow ugr in uGrid)
  155. {
  156. string craftFilePathOld = ugr.Cells["certPathOld"].Text;
  157. if (FileHelper.Delete(craftFilePathOld) == false)
  158. {
  159. MessageUtil.ShowWarning("删除签名文件失败,请重试!");
  160. return;
  161. }
  162. pram.Add(ugr.Cells["id"].Value.ToString());
  163. }
  164. if (MessageUtil.ShowYesNoAndQuestion("是否删除签名?")!= DialogResult.Yes) return;
  165. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SignaturePayService", "do_Delete", new object[] { pram });
  166. if (crt.Resultcode !=0)
  167. {
  168. MessageUtil.ShowTips("删除成功!");
  169. }
  170. else
  171. {
  172. MessageUtil.ShowTips("删除失败:"+crt.Resultmsg); return;
  173. }
  174. DoQuery("");
  175. }
  176. /// <summary>
  177. /// 上传
  178. /// </summary>
  179. /// <param name="sender"></param>
  180. /// <param name="e"></param>
  181. private void craftImg_EditorButtonClick(object sender, EditorButtonEventArgs e)
  182. {
  183. UltraGridRow ugr = ultraGrid1.ActiveRow;
  184. string ownerid = ugr.GetValue("OWNERUSERID");
  185. string id = ugr.GetValue("id");
  186. String orgId = ugr.Cells["orgId"].Value.ToString().Trim();
  187. String orgName = ugr.Cells["orgName"].Value.ToString().Trim();
  188. String ownerUserid = ugr.Cells["ownerUserid"].Value.ToString().Trim();
  189. String ownerName = ugr.Cells["ownerName"].Value.ToString().Trim();
  190. String certPath = ugr.Cells["certPath"].Value.ToString().Trim();
  191. String certPathOld = ugr.Cells["certPathOld"].Value.ToString().Trim();
  192. String certDesc = ugr.Cells["certDesc"].Value.ToString().Trim();
  193. String deptName = ugr.Cells["DEPTNAME"].Text.ToString().Trim();
  194. String toDept = ugr.Cells["TODEPT"].Text.ToString().Trim();
  195. //String filePathOld = "PMS/Signature/" + ownerid + "/";
  196. if (e.Button.Key.ToLower().Equals("select"))
  197. {
  198. FrmPopFileShow down = new FrmPopFileShow(this.ob, certPathOld);
  199. down.DeleteButton.Visible = false;
  200. down.ShowDialog();
  201. }
  202. if (e.Button.Key.ToLower().Equals("insert"))
  203. {
  204. String fileName = "";
  205. String filena = "";
  206. if (String.IsNullOrEmpty(ownerid))
  207. {
  208. MessageUtil.ShowTips("没有所属人员id不允许上传,请先选择人员信息!");
  209. return;
  210. }
  211. OpenFileDialog file = new OpenFileDialog();
  212. file.Multiselect = false;
  213. DialogResult drStat;
  214. drStat = file.ShowDialog();
  215. if (drStat == DialogResult.OK)
  216. {
  217. fileName = file.FileName;
  218. FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  219. long s = fs.Length;
  220. if (s / 1024.0 > 20)
  221. {
  222. MessageUtil.ShowTips("图片大于20KB,请重新上传!");
  223. return;
  224. }
  225. String filePathlocal = System.IO.Path.GetFullPath(fileName);
  226. filena = System.IO.Path.GetFileName(fileName);
  227. }
  228. if (ultraGrid1.ActiveRow == null)
  229. {
  230. MessageUtil.ShowTips("未选择签名项");
  231. return;
  232. }
  233. if (String.IsNullOrEmpty(filena) || String.IsNullOrEmpty(fileName))
  234. {
  235. MessageUtil.ShowTips("请选择待上传文件");
  236. return;
  237. }
  238. SignaturePay sat = new SignaturePay();
  239. sat.OwnerUserid = ownerid;
  240. String filePathNew = "Pms/SignaturePay/" + ownerid + "/";
  241. sat.CertPath = filena;
  242. sat.CertPathOld = filePathNew + filena;
  243. sat.Id = id;
  244. sat.CertDesc = certDesc;
  245. sat.OrgId = orgId;
  246. sat.OrgName = orgName;
  247. sat.OwnerName = ownerName;
  248. sat.OwnerUserid = ownerUserid;
  249. sat.Image = FileHelper.FileToArray(fileName);
  250. sat.CreateUserid = UserInfo.GetUserID();
  251. sat.CreateName = UserInfo.GetUserName();
  252. sat.CreateTime = DateTime.Now;
  253. sat.Validflag = "1";
  254. sat.DeptName = deptName;
  255. sat.ToDept = toDept;
  256. if (GetCraftFileCraftNoCnt(filena, ownerid, toDept) > 0)
  257. {
  258. MessageUtil.ShowTips("已存在该签名文件:" + filena);
  259. return;
  260. }
  261. List<FileBean> list = new List<FileBean>();
  262. FileBean bean = new FileBean();
  263. bean = new FileBean();
  264. bean.setFileName(filena);
  265. bean.setPathName(filePathNew);
  266. bean.setFile(FileHelper.FileToArray(fileName));
  267. list.Add(bean);
  268. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  269. if (isSuccess)
  270. {
  271. CoreResult crt = new CoreResult();
  272. //开始写数据库
  273. if (String.IsNullOrEmpty(id))
  274. {
  275. crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SignaturePayService", "do_Insert", new object[] { sat });
  276. }
  277. else
  278. {
  279. crt = this.execute<CoreResult>("com.hnshituo.pur.configure.service.SignaturePayService", "do_Update", new object[] { sat });
  280. }
  281. if (crt.Resultcode != 0)
  282. {
  283. MessageUtil.ShowTips("上传失败:" + crt.Resultmsg);
  284. }
  285. else
  286. {
  287. MessageUtil.ShowTips("上传成功");
  288. DoQuery(crt.Resultmsg);
  289. }
  290. }
  291. else
  292. {
  293. MessageBox.Show("上传失败");
  294. }
  295. }
  296. }
  297. /// <summary>
  298. /// 判断是否之前已提交相同的文件
  299. /// </summary>
  300. /// <param name="craftNo"></param>
  301. /// <returns></returns>
  302. private int GetCraftFileCraftNoCnt(string CERT_PATH, string OwnerUserid,string toDept)
  303. {
  304. SignaturePay sat = new SignaturePay();
  305. sat.CertPath = CERT_PATH;
  306. sat.OwnerUserid = OwnerUserid;
  307. sat.Validflag = "1";
  308. sat.ToDept = toDept;
  309. int dt = this.execute<int>("com.hnshituo.pur.configure.service.SignaturePayService", "count", new object[] { sat });
  310. return dt;
  311. }
  312. private void ultraGrid1_AfterSelectChange(object sender, AfterSelectChangeEventArgs e)
  313. {
  314. try
  315. {
  316. ultraGrid1.UpdateData();
  317. foreach (UltraGridRow r in ultraGrid1.Rows)
  318. {
  319. r.Cells["CHK"].Value = r.Selected;
  320. }
  321. }
  322. catch { }
  323. }
  324. private void txt_selectMan_EditorButtonClick(object sender, EditorButtonEventArgs e)
  325. {
  326. SetectManByDept frm = new SetectManByDept(this.ob);
  327. frm.ShowDialog();
  328. if (frm.strTips == "1")
  329. {
  330. String strdeptId = frm.StrDeptId;
  331. String strDeptName = frm.StrDeptName;
  332. String strUserName = frm.StrUserName;
  333. String strUserId = frm.StrUserID;
  334. if (ultraGrid1.ActiveRow == null)
  335. {
  336. return;
  337. }
  338. else
  339. {
  340. UltraGridRow row = ultraGrid1.ActiveRow;
  341. row.Cells["orgId"].Value = strdeptId;
  342. row.Cells["orgName"].Value = strDeptName;
  343. row.Cells["ownername"].Value = strUserName;
  344. row.Cells["ownerUserid"].Value = strUserId;
  345. }
  346. }
  347. }
  348. }
  349. }