FrmBaseUser.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  1. using Core.Mes.Client.Comm.Control;
  2. using Core.Mes.Client.Comm.Format;
  3. using Core.Mes.Client.Comm.Server;
  4. using Core.Mes.Client.Comm.Tool;
  5. using Core.StlMes.Client.Lims.Data.PipeAndOutdec.封装类.实体类;
  6. using CoreFS.CA06;
  7. using Infragistics.Win.UltraWinGrid;
  8. using System;
  9. using System.Collections;
  10. using System.Collections.Generic;
  11. using System.ComponentModel;
  12. using System.Data;
  13. using System.Drawing;
  14. using System.IO;
  15. using System.Linq;
  16. using System.Text;
  17. using System.Windows.Forms;
  18. namespace Core.StlMes.Client.Lims.Data.PipeAndOutdec
  19. {
  20. public partial class FrmBaseUser : FrmBase
  21. {
  22. private string[] arrId;//数据权限
  23. public FrmBaseUser()
  24. {
  25. InitializeComponent();
  26. }
  27. private string fileName = "";//路径
  28. /// <summary>
  29. /// 重写基类方法
  30. /// </summary>
  31. /// <param name="sender"></param>
  32. /// <param name="ToolbarKey"></param>
  33. public override void ToolBar_Click(object sender, string ToolbarKey)
  34. {
  35. switch (ToolbarKey)
  36. {
  37. case "Query":
  38. doQueryData();
  39. break;
  40. case "Add":
  41. doAdd();
  42. break;
  43. case "Update":
  44. doUpdate();
  45. break;
  46. case "Delete":
  47. doDelete();
  48. break;
  49. case "Close":
  50. close();
  51. break;
  52. }
  53. }
  54. /// <summary>
  55. /// 查询
  56. /// </summary>
  57. private void doQueryData()
  58. {
  59. List<BaseUserOrderEntity> listSource = EntityHelper.GetData<BaseUserOrderEntity>(
  60. "com.steering.lims.data.pipe.FrmBaseUser.doQueryUser", new object[] { arrId }, this.ob);
  61. baseUserOrderEntityBindingSource.DataSource = listSource;
  62. }
  63. /// <summary>
  64. /// 新增
  65. /// </summary>
  66. private void doAdd()
  67. {
  68. this.ultraGrid1.UpdateData();
  69. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  70. if (checkMagRows.Count() == 0)
  71. {
  72. MessageUtil.ShowTips("请选择需要新增的用户信息!");
  73. return;
  74. }
  75. ArrayList parmList = new ArrayList();
  76. foreach(UltraGridRow row in checkMagRows)
  77. {
  78. BaseUserOrderEntity baseTity = (BaseUserOrderEntity)row.ListObject;
  79. baseTity.UserId = row.Cells["UserId"].Value.ToString();
  80. baseTity.UserName = row.Cells["UserId"].Text.ToString();
  81. baseTity.UserOrder = row.Cells["UserOrder"].Value.ToString();
  82. baseTity.UserGroup = row.Cells["UserGroup"].Value.ToString();
  83. baseTity.UserType = row.Cells["UserType"].Value.ToString();
  84. baseTity.SignaturePath = row.Cells["SignaturePath"].Text;
  85. baseTity.UserId2 = row.Cells["UserId2"].Value.ToString();
  86. baseTity.UserName2 = row.Cells["UserId2"].Text.ToString();
  87. baseTity.SignaturePath2 = row.Cells["SignaturePath2"].Text;
  88. baseTity.DeptId = UserInfo.GetDeptid();
  89. string baseEntity = JSONFormat.Format(baseTity);
  90. parmList.Add(baseEntity);
  91. }
  92. CoreClientParam ccp = new CoreClientParam();
  93. ccp.ServerName = "com.steering.lims.data.pipe.FrmBaseUser";
  94. ccp.MethodName = "doAdd";
  95. ccp.ServerParams = new object[] { parmList,UserInfo.GetUserName() };
  96. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  97. if (ccp.ReturnCode != -1)
  98. {
  99. if (ccp.ReturnInfo.Equals("新增成功!"))
  100. {
  101. doQueryData();
  102. MessageUtil.ShowTips(ccp.ReturnInfo);
  103. }
  104. else
  105. {
  106. MessageUtil.ShowTips(ccp.ReturnInfo);
  107. }
  108. }
  109. }
  110. /// <summary>
  111. /// 修改
  112. /// </summary>
  113. private void doUpdate()
  114. {
  115. this.ultraGrid1.UpdateData();
  116. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  117. if (checkMagRows.Count() == 0)
  118. {
  119. MessageUtil.ShowTips("请选择需要修改的用户信息!");
  120. return;
  121. }
  122. ArrayList parmList = new ArrayList();
  123. foreach (UltraGridRow row in checkMagRows)
  124. {
  125. BaseUserOrderEntity baseTity = (BaseUserOrderEntity)row.ListObject;
  126. baseTity.UserId = row.Cells["UserId"].Value.ToString();
  127. baseTity.UserOrder = row.Cells["UserOrder"].Value.ToString();
  128. baseTity.UserGroup = row.Cells["UserGroup"].Value.ToString();
  129. baseTity.SignaturePath = row.Cells["SignaturePath"].Text;
  130. baseTity.UserId2 = row.Cells["UserId2"].Value.ToString();
  131. baseTity.UserName2 = row.Cells["UserId2"].Text.ToString();
  132. baseTity.SignaturePath2 = row.Cells["SignaturePath2"].Text;
  133. string baseEntity = JSONFormat.Format(baseTity);
  134. parmList.Add(baseEntity);
  135. }
  136. CoreClientParam ccp = new CoreClientParam();
  137. ccp.ServerName = "com.steering.lims.data.pipe.FrmBaseUser";
  138. ccp.MethodName = "doUpdate";
  139. ccp.ServerParams = new object[] { parmList };
  140. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  141. if (ccp.ReturnCode != -1)
  142. {
  143. if (ccp.ReturnInfo.Equals("修改成功!"))
  144. {
  145. doQueryData();
  146. MessageUtil.ShowTips(ccp.ReturnInfo);
  147. }
  148. else
  149. {
  150. MessageUtil.ShowTips(ccp.ReturnInfo);
  151. }
  152. }
  153. }
  154. /// <summary>
  155. /// 删除
  156. /// </summary>
  157. private void doDelete()
  158. {
  159. this.ultraGrid1.UpdateData();
  160. IQueryable<UltraGridRow> checkMagRows = this.ultraGrid1.Rows.AsQueryable().Where(" CHK = 'True'");
  161. if (checkMagRows.Count() == 0)
  162. {
  163. MessageUtil.ShowTips("请选择需要删除的用户信息!");
  164. return;
  165. }
  166. ArrayList parmList = new ArrayList();
  167. foreach (UltraGridRow row in checkMagRows)
  168. {
  169. BaseUserOrderEntity baseTity = (BaseUserOrderEntity)row.ListObject;
  170. baseTity.UserId = row.Cells["UserId"].Value.ToString();
  171. string baseEntity = JSONFormat.Format(baseTity);
  172. parmList.Add(baseEntity);
  173. }
  174. CoreClientParam ccp = new CoreClientParam();
  175. ccp.ServerName = "com.steering.lims.data.pipe.FrmBaseUser";
  176. ccp.MethodName = "doDelete";
  177. ccp.ServerParams = new object[] { parmList };
  178. ccp = ob.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  179. if (ccp.ReturnCode != -1)
  180. {
  181. if (ccp.ReturnInfo.Equals("删除成功!"))
  182. {
  183. doQueryData();
  184. MessageUtil.ShowTips(ccp.ReturnInfo);
  185. }
  186. else
  187. {
  188. MessageUtil.ShowTips(ccp.ReturnInfo);
  189. }
  190. }
  191. }
  192. /// <summary>
  193. /// 关闭
  194. /// </summary>
  195. private void close()
  196. {
  197. this.Close();
  198. }
  199. private void FrmBaseUser_Load(object sender, EventArgs e)
  200. {
  201. EntityHelper.ShowGridCaption<BaseUserOrderEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  202. arrId = this.ValidDataPurviewIds;//获取数据权限
  203. initUser();
  204. }
  205. private void initUser()
  206. {
  207. DataTable dt = ServerHelper.GetData("com.steering.lims.data.pipe.FrmBaseUser.doQueryUserMa", new object[] { arrId }, ob);
  208. if(dt.Rows.Count > 0)
  209. {
  210. ultraComboEditor1.DataSource = dt;
  211. ultraComboEditor1.DisplayMember = "USERNAME";
  212. ultraComboEditor1.ValueMember = "USERID";
  213. ultraComboEditor5.DataSource = dt;
  214. ultraComboEditor5.DisplayMember = "USERNAME";
  215. ultraComboEditor5.ValueMember = "USERID";
  216. }
  217. }
  218. private void craftImg_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  219. {
  220. this.ultraGrid1.UpdateData();
  221. UltraGridRow row = ultraGrid1.ActiveRow;
  222. //string askSubItem = row.GetValue("PLINE_CODE");
  223. string userId = row.Cells["UserId"].Value.ToString();
  224. string filePath = "Lims/autograph/" + userId + "/";
  225. if (e.Button.Key.ToLower().Equals("select"))
  226. {
  227. FormFileDown down = new FormFileDown(this.ob, row.Cells["SignaturePath"].Text);
  228. down.CtrlFileDown1.Button3.Visible = false;
  229. down.ShowDialog();
  230. }
  231. if (e.Button.Key.ToLower().Equals("insert"))
  232. {
  233. if (userId.Equals(""))
  234. {
  235. MessageUtil.ShowTips("没有用户不允许上传!");
  236. return;
  237. }
  238. FormFileDown down = new FormFileDown(this.ob, filePath);
  239. down.CtrlFileDown1.FilePath = filePath;
  240. List<FileBean> list = new List<FileBean>();
  241. FileBean bean = new FileBean();
  242. OpenFileDialog file = new OpenFileDialog();
  243. file.Multiselect = false;
  244. DialogResult drStat;
  245. drStat = file.ShowDialog();
  246. if (drStat == DialogResult.OK)
  247. {
  248. fileName = file.FileName;
  249. FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  250. long s = fs.Length;
  251. if (s / 1024.0 > 50)
  252. {
  253. MessageUtil.ShowTips("图片大于50KB,请重新上传!");
  254. return;
  255. }
  256. string filena = System.IO.Path.GetFileName(fileName);
  257. //DataTable dt = ServerHelper.GetData("com.steering.lims.data.pipe.FrmBaseUser.doQueryPath", new object[] { row.Cells["UserId"].Value.ToString() }, ob);
  258. //if (dt.Rows.Count > 0)
  259. //{
  260. // //string seturl = dt.Rows[0]["SIGNATURE_PATH"].ToString();
  261. // //bool isdelete = Core.Mes.Client.Comm.Server.FileHelper.Delete(seturl);
  262. // CoreClientParam ccp = new CoreClientParam();
  263. // ccp.ServerName = "com.steering.mes.signature.FrmTubeRollFileManage";
  264. // ccp.MethodName = "updateMinStgnature1";
  265. // ccp.ServerParams = new object[] { filePath + filena, row.Cells["UserId"].Value.ToString() };
  266. // ccp = this.ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  267. // if (ccp.ReturnCode == -1) { MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question); return; }
  268. //}
  269. bean = new FileBean();
  270. bean.setFileName(filena);
  271. bean.setPathName(filePath);
  272. bean.setFile(FileHelper.FileToArray(fileName));
  273. list.Add(bean);
  274. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  275. if (isSuccess)
  276. {
  277. MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  278. }
  279. else
  280. {
  281. MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  282. }
  283. ultraGrid1.ActiveCell.Value = filena;
  284. ultraGrid1.ActiveRow.Cells["SignaturePath"].Value = filePath + filena;
  285. //ultraGrid1.ActiveRow.Cells["SignaturePath"].Value = fileName;
  286. }
  287. }
  288. }
  289. private void craftImg2_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  290. {
  291. this.ultraGrid1.UpdateData();
  292. UltraGridRow row = ultraGrid1.ActiveRow;
  293. //string askSubItem = row.GetValue("PLINE_CODE");
  294. string userId2 = row.Cells["UserId2"].Value.ToString();
  295. string filePath = "Lims/autograph/" + userId2 + "2/";
  296. if (e.Button.Key.ToLower().Equals("select"))
  297. {
  298. FormFileDown down = new FormFileDown(this.ob, row.Cells["SignaturePath2"].Text);
  299. down.CtrlFileDown1.Button3.Visible = false;
  300. down.ShowDialog();
  301. }
  302. if (e.Button.Key.ToLower().Equals("insert"))
  303. {
  304. if (userId2.Equals(""))
  305. {
  306. MessageUtil.ShowTips("没有复审人不允许上传!");
  307. return;
  308. }
  309. FormFileDown down = new FormFileDown(this.ob, filePath);
  310. down.CtrlFileDown1.FilePath = filePath;
  311. List<FileBean> list = new List<FileBean>();
  312. FileBean bean = new FileBean();
  313. OpenFileDialog file = new OpenFileDialog();
  314. file.Multiselect = false;
  315. DialogResult drStat;
  316. drStat = file.ShowDialog();
  317. if (drStat == DialogResult.OK)
  318. {
  319. fileName = file.FileName;
  320. FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read);
  321. long s = fs.Length;
  322. if (s / 1024.0 > 50)
  323. {
  324. MessageUtil.ShowTips("图片大于50KB,请重新上传!");
  325. return;
  326. }
  327. string filena = System.IO.Path.GetFileName(fileName);
  328. bean = new FileBean();
  329. bean.setFileName(filena);
  330. bean.setPathName(filePath);
  331. bean.setFile(FileHelper.FileToArray(fileName));
  332. list.Add(bean);
  333. bool isSuccess = Core.Mes.Client.Comm.Server.FileHelper.Upload(list);
  334. if (isSuccess)
  335. {
  336. MessageBox.Show("上传成功", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  337. }
  338. else
  339. {
  340. MessageBox.Show("上传失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Question);
  341. }
  342. ultraGrid1.ActiveCell.Value = filena;
  343. ultraGrid1.ActiveRow.Cells["SignaturePath2"].Value = filePath + filena;
  344. //ultraGrid1.ActiveRow.Cells["SignaturePath"].Value = fileName;
  345. }
  346. }
  347. }
  348. }
  349. }