frmPopConfEvaUser.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  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 Pur.configure;
  11. using Pur.Entity;
  12. using Core.Mes.Client.Comm.Server;
  13. using Infragistics.Win.UltraWinGrid;
  14. using Core.Mes.Client.Comm.Control;
  15. using Pur.Entity.configureEntity;
  16. using System.Collections;
  17. using com.hnshituo.pur.vo;
  18. using Core.Mes.Client.Comm.Tool;
  19. using Pur.require_plan;
  20. using Infragistics.Win.UltraWinTree;
  21. using Infragistics.Win;
  22. using Infragistics.Win.UltraWinEditors;
  23. namespace Pur.pur_plan
  24. {
  25. public partial class frmPopConfEvaUser : FrmPmsBase
  26. {
  27. public frmPopConfEvaUser()
  28. {
  29. InitializeComponent();
  30. }
  31. //菜单按钮事件
  32. public override void ToolBar_Click(object sender, string ToolbarKey)
  33. {
  34. switch (ToolbarKey)
  35. {
  36. case "Query":
  37. Query();
  38. break;
  39. case "Add":
  40. confirm();
  41. break;
  42. case "Update":
  43. Update();
  44. break;
  45. case "Delete":
  46. Delete();
  47. break;
  48. }
  49. }
  50. /// <summary>
  51. /// 选择评标人员
  52. /// </summary>
  53. /// <param name="sender"></param>
  54. /// <param name="e"></param>
  55. private void txt_EVA_USERNAME_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  56. {
  57. if (ultraTree1.ActiveNode != null)
  58. {
  59. SetectManByDept frm = new SetectManByDept(this.ob, this.UserInfo.GetDeptid());
  60. frm.ShowDialog();
  61. txt_EVA_ORG_ID.Text = frm.StrDeptId;
  62. txt_EVA_ORG_NAME.Text = frm.StrDeptName;
  63. txt_EVA_USERID.Text = frm.StrUserID;
  64. txt_EVA_USERNAME.Text = frm.StrUserName;
  65. }
  66. }
  67. //刷新角色信息
  68. private void Query()
  69. {
  70. getSelEvaRole();
  71. }
  72. /// <summary>
  73. /// 添加
  74. /// </summary>
  75. private void confirm()
  76. {
  77. if (ultraTree1.ActiveNode != null)
  78. {
  79. //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key)
  80. //{
  81. // if (MessageUtil.ShowYesNoAndTips("当前所选评标人员所在科室【" + txt_EVA_ORG_NAME.Text + "】不为左侧树形结构所选科室,是否确定添加?").Equals(DialogResult.No))
  82. // {
  83. // return;
  84. // }
  85. //}
  86. if (string.IsNullOrEmpty(txt_EVA_ORG_ID.Text))
  87. {
  88. MessageUtil.ShowTips("请选择人员");
  89. return;
  90. }
  91. if (string.IsNullOrEmpty(cmb_EVA_ROLE_NAME.Text))
  92. {
  93. MessageUtil.ShowTips("请选择角色");
  94. return;
  95. }
  96. PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity();
  97. ConfEvaUserEntity.EvaGroupId = ultraTree1.ActiveNode.Key;
  98. ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id
  99. ConfEvaUserEntity.Validflag = "1";
  100. if (isExsitRow("com.hnshituo.pur.purplan.service.ConfEvaUserService", ConfEvaUserEntity)>0)
  101. {
  102. MessageUtil.ShowTips("所选评标人员分组存在相同用户,不能重复添加");
  103. return;
  104. }
  105. string strId = this.execute<string>("com.hnshituo.pur.utils.service.UtilsService", "getOddNumber", new object[] { "PUR_CONF_EVA_USER", "ID", ultraTree1.ActiveNode.Key, "3" });
  106. ConfEvaUserEntity.Id = strId;
  107. ConfEvaUserEntity.CreateName = UserInfo.GetUserName();
  108. ConfEvaUserEntity.CreateUserId = UserInfo.GetUserID();
  109. ConfEvaUserEntity.CreateTime = System.DateTime.Now;
  110. ConfEvaUserEntity.EvaRoleId = cmb_EVA_ROLE_NAME.Value.ToString();//角色Id
  111. ConfEvaUserEntity.EvaRoleName = cmb_EVA_ROLE_NAME.Text;//角色名称
  112. ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id
  113. ConfEvaUserEntity.EvaUsername = txt_EVA_USERNAME.Text;//用户名称
  114. ConfEvaUserEntity.EvaOrgId = txt_EVA_ORG_ID.Text;//科室Id
  115. ConfEvaUserEntity.EvaOrgName = txt_EVA_ORG_NAME.Text;//科室名称
  116. ConfEvaUserEntity.Validflag = "1";
  117. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.ConfEvaUserService", "doInsert", new object[] { ConfEvaUserEntity });
  118. if (crt.Resultcode != 0)
  119. {
  120. MessageUtil.ShowTips("添加失败 " + crt.Resultmsg);
  121. return;
  122. }
  123. MessageUtil.ShowTips("添加成功");
  124. //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key)
  125. //{
  126. // getSelEvaRole();//查询评标人员科室
  127. // UltraTreeNode utnd = ultraTree1.GetNodeByKey(txt_EVA_ORG_ID.Text);
  128. // ultraTree1.ActiveNode = utnd;
  129. // getSelEvaUsers(ultraTree1.ActiveNode.Key);
  130. // comm.doActiveSelRow(ultraGrid2, "ID", strId);
  131. //}
  132. //else
  133. //{
  134. getSelEvaUsers(ultraTree1.ActiveNode.Key);
  135. comm.doActiveSelRow(ultraGrid2, "ID", strId);
  136. //}
  137. }
  138. }
  139. /// <summary>
  140. /// 修改
  141. /// </summary>
  142. private void Update()
  143. {
  144. if (ultraGrid2.ActiveRow == null)
  145. { return; }
  146. if (string.IsNullOrEmpty(txt_EVA_ORG_ID.Text))
  147. {
  148. MessageUtil.ShowTips("请选择人员");
  149. return;
  150. }
  151. if (string.IsNullOrEmpty(cmb_EVA_ROLE_NAME.Text))
  152. {
  153. MessageUtil.ShowTips("请选择角色");
  154. return;
  155. }
  156. PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity();
  157. ConfEvaUserEntity.EvaGroupId = ultraTree1.ActiveNode.Key;
  158. //ConfEvaUserEntity.EvaOrgId = txt_EVA_ORG_ID.Text;//科室Id
  159. //ConfEvaUserEntity.EvaRoleId = cmb_EVA_ROLE_NAME.Value.ToString();//角色Id
  160. ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id
  161. ConfEvaUserEntity.Validflag = "1";
  162. if (txt_EVA_USERID.Text != ultraGrid2.ActiveRow.Cells["EVAUSERID"].Value.ToString())
  163. {
  164. if (isExsitRow("com.hnshituo.pur.purplan.service.ConfEvaUserService", ConfEvaUserEntity) > 0)
  165. {
  166. MessageUtil.ShowTips("所选评标人员分组存在相同用户,不能修改");
  167. return;
  168. }
  169. }
  170. //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key)
  171. //{
  172. // if (MessageUtil.ShowYesNoAndTips("当前所选评标人员所在科室【" + txt_EVA_ORG_NAME.Text + "】不为左侧树形结构所选科室,是否确定添加?").Equals(DialogResult.No))
  173. // {
  174. // return;
  175. // }
  176. //}
  177. ConfEvaUserEntity.Id = ultraGrid2.ActiveRow.Cells["ID"].Value.ToString();
  178. ConfEvaUserEntity.UpdateName = UserInfo.GetUserName();
  179. ConfEvaUserEntity.UpdateUserId = UserInfo.GetUserID();
  180. ConfEvaUserEntity.UpdateTime = System.DateTime.Now;
  181. ConfEvaUserEntity.EvaRoleName = cmb_EVA_ROLE_NAME.Text;//角色名称
  182. ConfEvaUserEntity.EvaUserid = txt_EVA_USERID.Text;//用户Id
  183. ConfEvaUserEntity.EvaUsername = txt_EVA_USERNAME.Text;//用户名称
  184. ConfEvaUserEntity.EvaOrgId = txt_EVA_ORG_ID.Text;//科室Id
  185. ConfEvaUserEntity.EvaOrgName = txt_EVA_ORG_NAME.Text;//科室名称
  186. ConfEvaUserEntity.Validflag = "1";
  187. if (MessageUtil.ShowYesNoAndQuestion("确定修改?") != DialogResult.Yes)
  188. {
  189. return;
  190. }
  191. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.ConfEvaUserService", "doUpdate", new object[] { ConfEvaUserEntity });
  192. if (crt.Resultcode != 0)
  193. {
  194. MessageUtil.ShowTips("修改失败 " + crt.Resultmsg);
  195. return;
  196. }
  197. MessageUtil.ShowTips("修改成功");
  198. //if (txt_EVA_ORG_ID.Text != ultraTree1.ActiveNode.Key)
  199. //{
  200. // getSelEvaRole();//查询评标人员科室
  201. // UltraTreeNode utnd = ultraTree1.GetNodeByKey(txt_EVA_ORG_ID.Text);
  202. // ultraTree1.ActiveNode = utnd;
  203. // getSelEvaUsers(ultraTree1.ActiveNode.Key);
  204. // comm.doActiveSelRow(ultraGrid2, "ID", ConfEvaUserEntity.Id);
  205. //}
  206. //else
  207. //{
  208. getSelEvaUsers(ultraTree1.ActiveNode.Key);
  209. comm.doActiveSelRow(ultraGrid2, "ID", ConfEvaUserEntity.Id);
  210. //}
  211. }
  212. /// <summary>
  213. /// 删除
  214. /// </summary>
  215. private void Delete()
  216. {
  217. if (ultraGrid2.ActiveRow == null)
  218. { return; }
  219. PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity();
  220. ConfEvaUserEntity.Id = ultraGrid2.ActiveRow.Cells["Id"].Value.ToString();
  221. ConfEvaUserEntity.Validflag = "0";
  222. ConfEvaUserEntity.DeleteName = UserInfo.GetUserName();
  223. ConfEvaUserEntity.DeleteUserId = UserInfo.GetUserID();
  224. ConfEvaUserEntity.DeleteTime = System.DateTime.Now;
  225. if (MessageUtil.ShowYesNoAndQuestion("确定删除?") != DialogResult.Yes)
  226. {
  227. return;
  228. }
  229. CoreResult crt = this.execute<CoreResult>("com.hnshituo.pur.purplan.service.ConfEvaUserService", "doUpdate", new object[] { ConfEvaUserEntity });
  230. if (crt.Resultcode != 0)
  231. {
  232. MessageUtil.ShowTips("删除失败 " + crt.Resultmsg);
  233. return;
  234. }
  235. MessageUtil.ShowTips("删除成功");
  236. getSelEvaUsers(ultraTree1.ActiveNode.Key);
  237. comm.doActiveSelRow(ultraGrid2, "ID", ConfEvaUserEntity.Id);
  238. }
  239. /// <summary>
  240. /// 选择节点
  241. /// </summary>
  242. /// <param name="sender"></param>
  243. /// <param name="e"></param>
  244. private void ultraTree1_AfterSelect(object sender, Infragistics.Win.UltraWinTree.SelectEventArgs e)
  245. {
  246. if (ultraTree1.ActiveNode != null)
  247. {
  248. getSelEvaUsers(ultraTree1.ActiveNode.Key);
  249. }
  250. }
  251. /// <summary>
  252. /// 查询选择评标人员角色信息
  253. /// </summary>
  254. private void getSelEvaUsers(string strEvaGroupId)
  255. {
  256. //PurTaskEvaUsersEntity TaskEvaUsersEntity = new PurTaskEvaUsersEntity();
  257. PurConfEvaUserEntity ConfEvaUserEntity = new PurConfEvaUserEntity();
  258. ConfEvaUserEntity.EvaGroupId = strEvaGroupId;
  259. ConfEvaUserEntity.Validflag = "1";
  260. DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.ConfEvaUserService", "find", new object[] { ConfEvaUserEntity, 0, 0 });
  261. GridHelper.CopyDataToDatatable(ref dt, ref dataTable1, true);
  262. GridHelper.RefreshAndAutoSize(ultraGrid2);
  263. ConfigureClassCommon.clearOldData(txt_EVA_ORG_ID.Parent);
  264. }
  265. /// <summary>
  266. /// 查询评标人员分组
  267. /// </summary>
  268. private void getSelEvaRole()
  269. {
  270. ultraTree1.Nodes.Clear();
  271. //评标人员科室
  272. //DataTable dt = this.execute<DataTable>("com.hnshituo.pur.purplan.service.ConfEvaUserService", "getConfEvaUser", new object[] { });
  273. //for (int i = 0; i < dt.Rows.Count; i++)
  274. //{
  275. // ultraTree1.Nodes.Add(dt.Rows[i]["evaorgid"].ToString(), dt.Rows[i]["evaorgname"].ToString());
  276. //}
  277. //评标人员分组
  278. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1227" }, this.ob);
  279. for (int j = 0; j < dt.Rows.Count; j++)
  280. {
  281. if (dt.Rows[j]["Validflag"].ToString() == "1")
  282. {
  283. ultraTree1.Nodes.Add(dt.Rows[j]["BASECODE"].ToString(), dt.Rows[j]["BASENAME"].ToString());
  284. }
  285. }
  286. }
  287. private void frmPopConfEvaUser_Load(object sender, EventArgs e)
  288. {
  289. //评标人员角色
  290. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1224" }, this.ob);
  291. dt.DefaultView.RowFilter = "Validflag='1'";
  292. dt = dt.DefaultView.ToTable();
  293. cmb_EVA_ROLE_NAME.DataSource = dt;
  294. cmb_EVA_ROLE_NAME.DisplayMember = "BASENAME";
  295. cmb_EVA_ROLE_NAME.ValueMember = "BASECODE";
  296. getSelEvaRole();
  297. }
  298. /// <summary>
  299. /// 绑定所有的下拉列表的数据
  300. /// </summary>
  301. private void getUltcmbBindValueList(DataTable dt, UltraComboEditor ultcmb)
  302. {
  303. for (int i = 0; i < dt.Rows.Count; i++)
  304. {
  305. ValueListItem vlItem = new ValueListItem(dt.Rows[i]["BASECODE"].ToString().Trim(), dt.Rows[i]["BASENAME"].ToString().Trim());
  306. ultcmb.Items.Add(vlItem);
  307. }
  308. }
  309. /// <summary>
  310. /// 移除无效数据
  311. /// </summary>
  312. /// <param name="dt"></param>
  313. private void removeNotValiflagData(DataTable dt)
  314. {
  315. for (int i = 0; i < dt.Rows.Count; )
  316. {
  317. if (dt.Rows[i]["VALIDFLAG"].ToString() == "0")
  318. {
  319. dt.Rows.RemoveAt(i);
  320. }
  321. else
  322. {
  323. i++;
  324. }
  325. }
  326. }
  327. /// <summary>
  328. /// 绑定下拉列表的数据
  329. /// </summary>
  330. /// <param name="dt"></param>
  331. /// <summary>
  332. private void getUltcmbBindData()
  333. {
  334. DataTable dt = ServerHelper.GetData("com.hnshituo.pur.configure.service.impl.CoreBaseInfoNew.doQuery", new Object[] { "1101" }, this.ob);
  335. removeNotValiflagData(dt);
  336. getUltcmbBindValueList(dt, cmb_EVA_ROLE_NAME);
  337. }
  338. /// <summary>
  339. /// 判断数据库中是否存在相同的列
  340. /// </summary>
  341. /// <param name="strJavaPackName"></param>
  342. /// <param name="o"></param>
  343. /// <returns>true存在</returns>
  344. public int isExsitRow(string strJavaPackName, object o)
  345. {
  346. DataTable dt = this.execute<DataTable>(strJavaPackName, "find", new object[] { o, 0, 0 });
  347. if (dt != null && dt.Rows.Count > 0)//存在相同的行
  348. {
  349. return dt.Rows.Count;
  350. }
  351. return 0;
  352. }
  353. /// <summary>
  354. /// 激活grid传值给控件
  355. /// </summary>
  356. /// <param name="sender"></param>
  357. /// <param name="e"></param>
  358. private void ultraGrid2_AfterRowActivate(object sender, EventArgs e)
  359. {
  360. cmb_EVA_ROLE_NAME.Text = ultraGrid2.ActiveRow.Cells["EVAROLENAME"].Value.ToString();//角色名称
  361. txt_EVA_ORG_ID.Text = ultraGrid2.ActiveRow.Cells["EVAORGID"].Value.ToString();//科室Id
  362. txt_EVA_USERID.Text = ultraGrid2.ActiveRow.Cells["EVAUSERID"].Value.ToString();//用户Id
  363. txt_EVA_USERNAME.Text = ultraGrid2.ActiveRow.Cells["EVAUSERNAME"].Value.ToString();//用户名称
  364. txt_EVA_ORG_NAME.Text = ultraGrid2.ActiveRow.Cells["EVAORGNAME"].Value.ToString();//科室名称
  365. }
  366. }
  367. }