F_MST_0207.cs 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296
  1. /*******************************************************************************
  2. * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
  3. * 类的信息:
  4. * 1.程序名称:F_MST_0204.cs
  5. * 2.功能描述:范围权限
  6. * 编辑履历:
  7. * 作者 日期 版本 修改内容
  8. * 王鑫 2014/09/17 1.00 新建
  9. *******************************************************************************/
  10. using System;
  11. using System.Data;
  12. using System.Windows.Forms;
  13. using Dongke.IBOSS.PRD.Basics.BaseControls;
  14. using Dongke.IBOSS.PRD.Basics.BaseResources;
  15. using Dongke.IBOSS.PRD.Basics.Library;
  16. using Dongke.IBOSS.PRD.Client.CommonModule;
  17. using Dongke.IBOSS.PRD.Client.Controls;
  18. using Dongke.IBOSS.PRD.WCF.Proxys;
  19. namespace Dongke.IBOSS.PRD.Client.SystemModule
  20. {
  21. public partial class F_MST_0207 : FormBase
  22. {
  23. #region 成员变量
  24. // 传过来的用户ID
  25. private int _userID;
  26. // 页面的数据源
  27. DataSet _userRightData;
  28. // 是否是第一次加载页面
  29. bool _isFirstLoad = true;
  30. //查看工号权限
  31. bool _viewUser = false; //默认是否选中
  32. // 工号权限
  33. bool _user = false; //默认是否选中
  34. // 查看成型线
  35. bool _viewGroutingLine = false;
  36. // 操作成型线
  37. bool _groutingLine = false;//
  38. // 操作温湿度
  39. bool _thermometer = false;
  40. // 查看温湿度
  41. bool _viewThermometer = false;
  42. // 操作部门
  43. bool _organization = false;
  44. // 查看部门
  45. bool _viewOrganization = false;
  46. // 操作工序
  47. bool _proceduce = false;
  48. // 查看工序
  49. bool _viewProceduce = false;
  50. // 数据表的数据源
  51. private DataTable _dtDataGird = null;
  52. private string _userCodeValue;
  53. private bool _ShowFlag = true;
  54. private int? _purviewID = null;
  55. private int? _purviewType = null;
  56. #endregion
  57. #region 构造函数
  58. public F_MST_0207()
  59. {
  60. InitializeComponent();
  61. }
  62. public F_MST_0207(int userID)
  63. {
  64. InitializeComponent();
  65. this._userID = userID;
  66. // 设置标题
  67. this.Text = FormTitles.F_MST_0204;
  68. // 工具栏按钮文本赋值
  69. this.btnSave.Text = ButtonText.BTN_SAVE;
  70. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  71. }
  72. public F_MST_0207(int userID, string userCode)
  73. {
  74. InitializeComponent();
  75. this._userID = userID;
  76. // 设置标题
  77. this.Text = FormTitles.F_MST_0204;
  78. // 工具栏按钮文本赋值
  79. this.btnSave.Text = ButtonText.BTN_SAVE;
  80. this.btnCancel.Text = ButtonText.BTN_CLOSE;
  81. }
  82. #endregion
  83. #region 事件
  84. /// <summary>
  85. /// 窗体加载事件
  86. /// </summary>
  87. /// <param name="sender"></param>
  88. /// <param name="e"></param>
  89. private void F_MST_0204_Load(object sender, EventArgs e)
  90. {
  91. try
  92. {
  93. // 保存按钮不可用
  94. //this.btnSave.Enabled = false;
  95. this._userRightData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetUserRightData));
  96. if (this._userRightData != null && this._userRightData.Tables.Count >= Constant.INT_IS_ZERO)
  97. {
  98. //加载用户列表
  99. DataSet functionUsers = (DataSet)DoAsync(new BaseAsyncMethod(GetFunctionUsers));
  100. //this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData);
  101. //this.btnCancel.Enabled = true;
  102. if (functionUsers != null)
  103. {
  104. this.dgvFunctionUsers.AutoGenerateColumns = false;
  105. this.dgvFunctionUsers.DataSource = functionUsers.Tables[0];
  106. //this.dgvFunctionUsers.Columns["UserCode"].ReadOnly = true;
  107. this.dgvFunctionUsers.Columns["UserName1"].ReadOnly = true;
  108. this.dgvFunctionUsers.Columns["OrganizationName1"].ReadOnly = true;
  109. this._dtDataGird = functionUsers.Tables[0];
  110. //
  111. ////DataView dv = functionUsers.Tables[0].DefaultView;
  112. ////dv.RowFilter = "FunctionCode='-100'";
  113. ////this.dgvFunctionUsers.DataSource = dv.ToTable();
  114. }
  115. //查看业务部门树的生成
  116. this.InitOrganizationTreeView(this._userRightData.Tables[0], true);
  117. this.tvwViewOrganization.ExpandAll();
  118. // 操作业务部门树的生成
  119. this.InitOrganizationTreeView(this._userRightData.Tables[1], false);
  120. this.tvwOrganization.ExpandAll();
  121. // 设置DataGridView属性
  122. this.dgvViewUser.AutoGenerateColumns = false;
  123. this.dgvViewUser.Columns[5].ReadOnly = true;
  124. // 工号权限的绑定
  125. this.dgvViewUser.DataSource = this._userRightData.Tables[2];
  126. // 设置DataGridView属性
  127. this.dgvUser.AutoGenerateColumns = false;
  128. this.dgvUser.Columns[5].ReadOnly = true;
  129. // 工号权限的绑定
  130. this.dgvUser.DataSource = this._userRightData.Tables[3];
  131. // 设置DataGridView属性
  132. this.dgvViewGroutingLine.AutoGenerateColumns = false;
  133. this.dgvViewGroutingLine.Columns[3].ReadOnly = true;
  134. // 查看成型线权限的绑定
  135. this.dgvViewGroutingLine.DataSource = this._userRightData.Tables[4];
  136. // 设置DataGridView属性
  137. this.dgvGroutingLine.AutoGenerateColumns = false;
  138. this.dgvGroutingLine.Columns[3].ReadOnly = true;
  139. // 操作成型线权限的绑定
  140. this.dgvGroutingLine.DataSource = this._userRightData.Tables[5];
  141. // 生成查看生产线及工序树
  142. InitGroutingLineTreeView(this._userRightData.Tables[6], this._userRightData.Tables[8]);
  143. this.tvwGroutinProductionLine.ExpandAll();
  144. InitGroutingLineTreeCKView(this._userRightData.Tables[7], this._userRightData.Tables[9]);
  145. this.tvwGroutinProductionLineCK.ExpandAll();
  146. // 撤销工序范围 InitCancelTreeCKView
  147. DataTable dtCopy = this._userRightData.Tables[6].Copy();
  148. dtCopy.TableName = "newtable";
  149. foreach (DataRow dr in dtCopy.Rows)
  150. {
  151. dr["purviewtype"] = -99;
  152. }
  153. dtCopy.AcceptChanges();
  154. this._userRightData.Tables.Add(dtCopy);
  155. InitCancelTreeCKView(dtCopy, this._userRightData.Tables[12]);
  156. this.treeViewCancel.ExpandAll();
  157. // 设置DataGridView属性
  158. this.dgvViewThermometer.AutoGenerateColumns = false;
  159. this.dgvViewThermometer.Columns[3].ReadOnly = true;
  160. // 查看温湿计权限的绑定
  161. this.dgvViewThermometer.DataSource = this._userRightData.Tables[10];
  162. // 设置DataGridView属性
  163. this.dgvThermometer.AutoGenerateColumns = false;
  164. this.dgvThermometer.Columns[3].ReadOnly = true;
  165. // 操作温湿计权限的绑定
  166. this.dgvThermometer.DataSource = this._userRightData.Tables[11];
  167. //
  168. DataView dv = functionUsers.Tables[0].DefaultView;
  169. dv.RowFilter = "Purviewid='-100'";
  170. this.dgvFunctionUsers.DataSource = dv.ToTable();
  171. }
  172. this._isFirstLoad = false;
  173. }
  174. catch (Exception ex)
  175. {
  176. // 对异常进行共通处理
  177. ExceptionManager.HandleEventException(this.ToString(),
  178. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  179. }
  180. }
  181. /// <summary>
  182. /// 根据系统功能ID取得使用该功能的用户列表
  183. /// </summary>
  184. /// <returns></returns>
  185. private DataSet GetFunctionUsers()
  186. {
  187. try
  188. {
  189. return SystemModuleProxy.Service.GetFunctionUserPurviewList();
  190. }
  191. catch (Exception ex)
  192. {
  193. throw ex;
  194. }
  195. }
  196. /// <summary>
  197. /// 窗体关闭时事件
  198. /// </summary>
  199. /// <param name="sender"></param>
  200. /// <param name="e"></param>
  201. private void F_MST_0204_FormClosing(object sender, FormClosingEventArgs e)
  202. {
  203. try
  204. {
  205. // 判断数据是否被修改过,修改过需要提示保存消息
  206. //if (DataJudge.IsChange(this._userRightData))
  207. //if (this.btnSave.Enabled)
  208. if (DataJudge.IsChange(this._dtDataGird))
  209. {
  210. DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
  211. MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
  212. if (result == DialogResult.Yes)
  213. {
  214. // 保存数据
  215. btnSave_Click(sender, e);
  216. }
  217. else if (result == DialogResult.Cancel)
  218. {
  219. e.Cancel = true;
  220. }
  221. }
  222. }
  223. catch (Exception ex)
  224. {
  225. // 对异常进行共通处理
  226. ExceptionManager.HandleEventException(this.ToString(),
  227. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  228. }
  229. }
  230. /// <summary>
  231. /// 组织机构范围权限的子节点选择后,父节点自动选择
  232. /// 父节点选择之后,子节点自动选择
  233. /// 选择之后修改后台数据源
  234. /// </summary>
  235. /// <param name="sender"></param>
  236. /// <param name="e"></param>
  237. private void tvwViewOrganization_AfterCheck(object sender, TreeViewEventArgs e)
  238. {
  239. try
  240. {
  241. //int purviewID = Convert.ToInt32(e.Node.Tag);
  242. //foreach (DataRow dataRow in _userRightData.Tables[0].Rows)
  243. //{
  244. // if (purviewID == Convert.ToInt32(dataRow["PurviewID"]))
  245. // {
  246. // dataRow["RightFlag"] = e.Node.Checked;
  247. // break;
  248. // }
  249. //}
  250. //if (!this._isFirstLoad)
  251. //{
  252. // // 保存按钮状态改变
  253. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  254. //}
  255. }
  256. catch (Exception ex)
  257. {
  258. // 对异常进行共通处理
  259. ExceptionManager.HandleEventException(this.ToString(),
  260. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  261. }
  262. }
  263. /// <summary>
  264. /// 窗体关闭
  265. /// </summary>
  266. /// <param name="sender"></param>
  267. /// <param name="e"></param>
  268. private void btnCancel_Click(object sender, EventArgs e)
  269. {
  270. this.Close();
  271. }
  272. //保存按钮事件
  273. private void btnSave_Click(object sender, EventArgs e)
  274. {
  275. try
  276. {
  277. this.btnSave.Enabled = false;
  278. this.btnCancel.Enabled = false;
  279. int returnAffectRows = (int)DoAsync(new BaseAsyncMethod(SaveUserRightInfo));
  280. this.btnSave.Enabled = true;
  281. this.btnCancel.Enabled = true;
  282. if (returnAffectRows > Constant.INT_IS_ZERO)
  283. {
  284. this._dtDataGird.AcceptChanges();
  285. // 提示信息
  286. MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "修改用户范围权限", "保存"),
  287. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
  288. this.Close();
  289. }
  290. else
  291. {
  292. // 提示信息
  293. MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "修改用户范围权限", "保存"),
  294. this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
  295. }
  296. }
  297. catch (Exception ex)
  298. {
  299. this.btnSave.Enabled = true;
  300. this.btnCancel.Enabled = true;
  301. // 对异常进行共通处理
  302. ExceptionManager.HandleEventException(this.ToString(),
  303. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  304. }
  305. }
  306. /// <summary>
  307. /// 操作部门树结点改变
  308. /// </summary>
  309. /// <param name="sender"></param>
  310. /// <param name="e"></param>
  311. private void tvwOrganization_AfterCheck(object sender, TreeViewEventArgs e)
  312. {
  313. try
  314. {
  315. //int purviewID = Convert.ToInt32(e.Node.Tag);
  316. //foreach (DataRow dataRow in _userRightData.Tables[1].Rows)
  317. //{
  318. // if (purviewID == Convert.ToInt32(dataRow["PurviewID"]))
  319. // {
  320. // dataRow["RightFlag"] = e.Node.Checked;
  321. // break;
  322. // }
  323. //}
  324. //if (!this._isFirstLoad)
  325. //{
  326. // // 保存按钮状态改变
  327. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  328. //}
  329. }
  330. catch (Exception ex)
  331. {
  332. // 对异常进行共通处理
  333. ExceptionManager.HandleEventException(this.ToString(),
  334. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  335. }
  336. }
  337. /// <summary>
  338. /// 操作业务部门树形全部收缩
  339. /// </summary>
  340. /// <param name="sender"></param>
  341. /// <param name="e"></param>
  342. private void btnOrganizationCollapse_Click(object sender, EventArgs e)
  343. {
  344. this.tvwOrganization.CollapseAll();
  345. }
  346. /// <summary>
  347. /// 操作员范围选择发生改变,保存按钮状态
  348. /// </summary>
  349. /// <param name="sender"></param>
  350. /// <param name="e"></param>
  351. private void dgvUser_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  352. {
  353. //if (!this._isFirstLoad)
  354. //{
  355. // // 保存按钮状态改变
  356. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  357. //}
  358. }
  359. // <summary>
  360. /// 操作员范围选择发生改变,保存按钮状态
  361. /// </summary>
  362. /// <param name="sender"></param>
  363. /// <param name="e"></param>
  364. private void dgvUser_CellValueChanged_1(object sender, DataGridViewCellEventArgs e)
  365. {
  366. //if (!this._isFirstLoad)
  367. //{
  368. // // 保存按钮状态改变
  369. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  370. //}
  371. }
  372. /// <summary>
  373. /// 生产线单元格值改变
  374. /// </summary>
  375. /// <param name="sender"></param>
  376. /// <param name="e"></param>
  377. private void dgvViewGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  378. {
  379. //if (!this._isFirstLoad)
  380. //{
  381. // // 保存按钮状态改变
  382. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  383. //}
  384. }
  385. /// <summary>
  386. /// 操作成型生产线单元格值改变
  387. /// </summary>
  388. /// <param name="sender"></param>
  389. /// <param name="e"></param>
  390. private void dgvGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  391. {
  392. //if (!this._isFirstLoad)
  393. //{
  394. // // 保存按钮状态改变
  395. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  396. //}
  397. }
  398. /// <summary>
  399. /// 查看生产线及工序范围权限选中改变事件
  400. /// </summary>
  401. /// <param name="sender"></param>
  402. /// <param name="e"></param>
  403. private void tvwGroutinProductionLine_AfterCheck(object sender, TreeViewEventArgs e)
  404. {
  405. try
  406. {
  407. //int purviewID = Convert.ToInt32(e.Node.Tag);
  408. ////起始为ProductionLine_为成型生产线,否则为工序
  409. //foreach (DataRow dataRow in (e.Node.Name.StartsWith("ProductionLine_") ? _userRightData.Tables[6].Rows : _userRightData.Tables[8].Rows))
  410. //{
  411. // if (purviewID == Convert.ToInt32(dataRow["PurviewID"]))
  412. // {
  413. // dataRow["RightFlag"] = e.Node.Checked;
  414. // break;
  415. // }
  416. // if (e.Node.Parent != null)
  417. // {
  418. // if (e.Node.Checked)
  419. // e.Node.Parent.Checked = true;
  420. // }
  421. //}
  422. //if (!this._isFirstLoad)
  423. //{
  424. // // 保存按钮状态改变
  425. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  426. //}
  427. }
  428. catch (Exception ex)
  429. {
  430. // 对异常进行共通处理
  431. ExceptionManager.HandleEventException(this.ToString(),
  432. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  433. }
  434. }
  435. /// <summary>
  436. /// 温湿计范围权限改变后
  437. /// </summary>
  438. /// <param name="sender"></param>
  439. /// <param name="e"></param>
  440. private void dgvThermometer_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  441. {
  442. //if (!this._isFirstLoad)
  443. //{
  444. // // 保存按钮状态改变
  445. // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
  446. //}
  447. }
  448. /// <summary>
  449. /// 操作工序范围选定值改变后
  450. /// </summary>
  451. /// <param name="sender"></param>
  452. /// <param name="e"></param>
  453. private void tvwGroutinProductionLineCK_AfterCheck(object sender, TreeViewEventArgs e)
  454. {
  455. }
  456. /// <summary>
  457. /// 操作工序展开所有节点
  458. /// </summary>
  459. /// <param name="sender"></param>
  460. /// <param name="e"></param>
  461. private void btnCKOpen_Click(object sender, EventArgs e)
  462. {
  463. this.tvwGroutinProductionLineCK.ExpandAll();
  464. }
  465. /// <summary>
  466. /// 操作工序折叠所有节点
  467. /// </summary>
  468. /// <param name="sender"></param>
  469. /// <param name="e"></param>
  470. private void btnCKClose_Click(object sender, EventArgs e)
  471. {
  472. this.tvwGroutinProductionLineCK.CollapseAll();
  473. }
  474. #endregion
  475. #region 私有方法
  476. /// <summary>
  477. /// 加载查看工序树结点
  478. /// </summary>
  479. /// <param name="GroutingLineTable"></param>
  480. /// <param name="ProductionLineTable"></param>
  481. private void InitCancelTreeCKView(DataTable GroutingLineTable, DataTable ProductionLineTable)
  482. {
  483. foreach (DataRow row in GroutingLineTable.Rows)
  484. {
  485. TreeNode sNode;
  486. sNode = new TreeNode();
  487. sNode.Text = '[' + row["ProductionLineCode"].ToString() + ']' + row["ProductionLinename"].ToString();
  488. sNode.Name = "ProductionLine_" + row["ProductionLineCode"].ToString();
  489. sNode.Tag = row["PurviewID"];
  490. if (Convert.ToBoolean(row["RightFlag"]))
  491. {
  492. sNode.Checked = true;
  493. }
  494. // this.tvwGroutinProductionLineCK.Nodes.Add(sNode);
  495. this.treeViewCancel.Nodes.Add(sNode);
  496. InitCancelProcedureTreeView(sNode, ProductionLineTable);
  497. }
  498. }
  499. /// <summary>
  500. /// 生成查看成工序树
  501. /// </summary>
  502. /// <param name="GroutingLineTable"></param>
  503. /// <param name="ProductionLineTable"></param>
  504. private void InitCancelProcedureTreeView(TreeNode sNode, DataTable ProductionLineTable)
  505. {
  506. DataRow[] rows = ProductionLineTable.Select
  507. ("ProductionLineid=" + sNode.Tag.ToString());
  508. foreach (DataRow row in rows)
  509. {
  510. TreeNode childNode;
  511. childNode = sNode.Nodes.Add('[' + row["ProcedureCode"].ToString() + ']' + row["Procedurename"].ToString());
  512. childNode.Name = "Procedure_" + row["ProcedureCode"].ToString();
  513. childNode.Tag = row["PurviewID"];
  514. if (Convert.ToBoolean(row["RightFlag"]))
  515. {
  516. childNode.Checked = true;
  517. }
  518. }
  519. }
  520. /// 获取员工档案数据集
  521. /// </summary>
  522. /// <returns></returns>
  523. private DataSet GetUserRightData()
  524. {
  525. return SystemModuleProxy.Service.GetUserRightData(-2);
  526. }
  527. /// <summary>
  528. /// 根据取得的数据,生成部门树
  529. /// </summary>
  530. /// <param name="treeTable"></param>
  531. /// <param name="isViewOrganization">是否是查看部门</param>
  532. private void InitOrganizationTreeView(DataTable treeTable, bool isViewOrganization)
  533. {
  534. try
  535. {
  536. TreeNode node = null;
  537. DataRow[] organizationRows = treeTable.Select
  538. ("OrganizationCode LIKE '0%' AND LEN(OrganizationCode) = 3");
  539. // 递归生成功能权限树
  540. this.InitTreeView(treeTable, organizationRows, node, isViewOrganization);
  541. }
  542. catch (Exception ex)
  543. {
  544. throw ex;
  545. }
  546. }
  547. /// <summary>
  548. /// 递归创建部门树
  549. /// </summary>
  550. /// <param name="treeTable"></param>
  551. /// <param name="rows"></param>
  552. /// <param name="node"></param>
  553. private void InitTreeView(DataTable treeTable, DataRow[] rows, TreeNode node, bool isViewOrganization)
  554. {
  555. foreach (DataRow row in rows)
  556. {
  557. TreeNode sNode;
  558. if (node == null)
  559. {
  560. sNode = new TreeNode();
  561. sNode.Text = '[' + row["OrganizationCode"].ToString() + ']' + row["OrganizationName"].ToString();
  562. sNode.Name = row["OrganizationCode"].ToString();
  563. sNode.Tag = row["PurviewID"];
  564. if (Convert.ToBoolean(row["RightFlag"]))
  565. {
  566. sNode.Checked = true;
  567. }
  568. if (isViewOrganization)
  569. {
  570. this.tvwViewOrganization.Nodes.Add(sNode);
  571. }
  572. else
  573. {
  574. this.tvwOrganization.Nodes.Add(sNode);
  575. }
  576. }
  577. else
  578. {
  579. sNode = node.Nodes.Add('[' + row["OrganizationCode"].ToString() + ']' + row["OrganizationName"].ToString());
  580. sNode.Name = row["OrganizationCode"].ToString();
  581. sNode.Tag = row["PurviewID"];
  582. if (Convert.ToBoolean(row["RightFlag"]))
  583. {
  584. sNode.Checked = true;
  585. }
  586. }
  587. string filterExpression = "OrganizationCode LIKE '" + row["OrganizationCode"].ToString()
  588. + "%' AND LEN(OrganizationCode) = " + (row["OrganizationCode"].ToString().Length + 3);
  589. DataRow[] subRows = treeTable.Select(filterExpression);
  590. // 递归方法
  591. InitTreeView(treeTable, subRows, sNode, isViewOrganization);
  592. }
  593. }
  594. /// <summary>
  595. /// 将全部节点选择或者取消选中
  596. /// </summary>
  597. /// <param name="treeView"></param>
  598. /// <param name="flag"></param>
  599. private void CheckTreeview(TreeView treeView, bool flag)
  600. {
  601. TreeNodeCollection nodes = treeView.Nodes;
  602. foreach (TreeNode node in nodes)
  603. {
  604. CheckSubNodes(node, flag);
  605. }
  606. }
  607. /// <summary>
  608. /// 递归选中节点或者取消选中节点
  609. /// </summary>
  610. /// <param name="treeNode"></param>
  611. /// <param name="flag"></param>
  612. private void CheckSubNodes(TreeNode treeNode, bool flag)
  613. {
  614. treeNode.Checked = flag;
  615. foreach (TreeNode node in treeNode.Nodes)
  616. {
  617. CheckSubNodes(node, flag);
  618. }
  619. }
  620. /// <summary>
  621. /// 生成查看成型线树
  622. /// </summary>
  623. /// <param name="GroutingLineTable"></param>
  624. /// <param name="ProductionLineTable"></param>
  625. private void InitGroutingLineTreeView(DataTable GroutingLineTable, DataTable ProductionLineTable)
  626. {
  627. foreach (DataRow row in GroutingLineTable.Rows)
  628. {
  629. TreeNode sNode;
  630. sNode = new TreeNode();
  631. sNode.Text = '[' + row["ProductionLineCode"].ToString() + ']' + row["ProductionLinename"].ToString();
  632. sNode.Name = "ProductionLine_" + row["ProductionLineCode"].ToString();
  633. sNode.Tag = row["PurviewID"];
  634. if (Convert.ToBoolean(row["RightFlag"]))
  635. {
  636. sNode.Checked = true;
  637. }
  638. this.tvwGroutinProductionLine.Nodes.Add(sNode);
  639. InitGroutingProductionTreeView(sNode, ProductionLineTable);
  640. }
  641. }
  642. /// <summary>
  643. /// 加载查看工序树结点
  644. /// </summary>
  645. /// <param name="GroutingLineTable"></param>
  646. /// <param name="ProductionLineTable"></param>
  647. private void InitGroutingLineTreeCKView(DataTable GroutingLineTable, DataTable ProductionLineTable)
  648. {
  649. foreach (DataRow row in GroutingLineTable.Rows)
  650. {
  651. TreeNode sNode;
  652. sNode = new TreeNode();
  653. sNode.Text = '[' + row["ProductionLineCode"].ToString() + ']' + row["ProductionLinename"].ToString();
  654. sNode.Name = "ProductionLine_" + row["ProductionLineCode"].ToString();
  655. sNode.Tag = row["PurviewID"];
  656. if (Convert.ToBoolean(row["RightFlag"]))
  657. {
  658. sNode.Checked = true;
  659. }
  660. this.tvwGroutinProductionLineCK.Nodes.Add(sNode);
  661. InitGroutingProductionTreeView(sNode, ProductionLineTable);
  662. }
  663. }
  664. /// <summary>
  665. /// 生成查看成工序树
  666. /// </summary>
  667. /// <param name="GroutingLineTable"></param>
  668. /// <param name="ProductionLineTable"></param>
  669. private void InitGroutingProductionTreeView(TreeNode sNode, DataTable ProductionLineTable)
  670. {
  671. DataRow[] rows = ProductionLineTable.Select
  672. ("ProductionLineid=" + sNode.Tag.ToString());
  673. foreach (DataRow row in rows)
  674. {
  675. TreeNode childNode;
  676. childNode = sNode.Nodes.Add('[' + row["ProcedureCode"].ToString() + ']' + row["Procedurename"].ToString());
  677. childNode.Name = "Procedure_" + row["ProcedureCode"].ToString();
  678. childNode.Tag = row["PurviewID"];
  679. if (Convert.ToBoolean(row["RightFlag"]))
  680. {
  681. childNode.Checked = true;
  682. }
  683. }
  684. }
  685. #endregion
  686. /// <summary>
  687. /// 绑定原来数据只能删除不能编辑
  688. /// </summary>
  689. private void BindReadOnly()
  690. {
  691. foreach (DataGridViewRow row in this.dgvFunctionUsers.Rows)
  692. {
  693. if (row.Cells["AddFlag"].Value != null)
  694. {
  695. row.Cells["UserCode1"].ReadOnly = true;
  696. }
  697. }
  698. this.dgvFunctionUsers.IsSetInputColumnsColor = true;
  699. }
  700. /// <summary>
  701. /// 操作部门
  702. /// </summary>
  703. /// <param name="sender"></param>
  704. /// <param name="e"></param>
  705. private void tvwOrganization_AfterSelect(object sender, TreeViewEventArgs e)
  706. {
  707. try
  708. {
  709. //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
  710. //{
  711. this._purviewID = Convert.ToInt32(e.Node.Tag);
  712. this._purviewType = 2;
  713. DataView dv = this._dtDataGird.DefaultView;
  714. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  715. this.dgvFunctionUsers.DataSource = dv.ToTable();
  716. BindReadOnly();
  717. //}
  718. }
  719. catch (Exception ex)
  720. {
  721. this.btnCancel.Enabled = true;
  722. // 对异常进行共通处理
  723. ExceptionManager.HandleEventException(this.ToString(),
  724. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  725. }
  726. }
  727. // 查看部门
  728. private void tvwViewOrganization_AfterSelect(object sender, TreeViewEventArgs e)
  729. {
  730. try
  731. {
  732. //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
  733. //{
  734. this._purviewID = Convert.ToInt32(e.Node.Tag);
  735. this._purviewType = 1;
  736. DataView dv = this._dtDataGird.DefaultView;
  737. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  738. this.dgvFunctionUsers.DataSource = dv.ToTable();
  739. BindReadOnly();
  740. //}
  741. }
  742. catch (Exception ex)
  743. {
  744. this.btnCancel.Enabled = true;
  745. // 对异常进行共通处理
  746. ExceptionManager.HandleEventException(this.ToString(),
  747. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  748. }
  749. }
  750. /// <summary>
  751. /// 操作工序
  752. /// </summary>
  753. /// <param name="sender"></param>
  754. /// <param name="e"></param>
  755. private void tvwGroutinProductionLineCK_AfterSelect(object sender, TreeViewEventArgs e)
  756. {
  757. try
  758. {
  759. //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
  760. //{
  761. this._purviewID = Convert.ToInt32(e.Node.Tag);
  762. if (e.Node.Name.Contains("ProductionLine_"))
  763. {
  764. this._purviewType = 8;
  765. }
  766. else
  767. {
  768. this._purviewType = 10;
  769. }
  770. DataView dv = this._dtDataGird.DefaultView;
  771. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  772. this.dgvFunctionUsers.DataSource = dv.ToTable();
  773. BindReadOnly();
  774. //}
  775. }
  776. catch (Exception ex)
  777. {
  778. this.btnCancel.Enabled = true;
  779. // 对异常进行共通处理
  780. ExceptionManager.HandleEventException(this.ToString(),
  781. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  782. }
  783. }
  784. /// <summary>
  785. /// 查看工序
  786. /// </summary>
  787. /// <param name="sender"></param>
  788. /// <param name="e"></param>
  789. private void tvwGroutinProductionLine_AfterSelect(object sender, TreeViewEventArgs e)
  790. {
  791. try
  792. {
  793. //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
  794. //{
  795. this._purviewID = Convert.ToInt32(e.Node.Tag);
  796. if (e.Node.Name.Contains("ProductionLine_"))
  797. {
  798. this._purviewType = 7;
  799. }
  800. else
  801. {
  802. this._purviewType = 9;
  803. }
  804. DataView dv = this._dtDataGird.DefaultView;
  805. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  806. this.dgvFunctionUsers.DataSource = dv.ToTable();
  807. BindReadOnly();
  808. //}
  809. }
  810. catch (Exception ex)
  811. {
  812. this.btnCancel.Enabled = true;
  813. // 对异常进行共通处理
  814. ExceptionManager.HandleEventException(this.ToString(),
  815. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  816. }
  817. }
  818. /// <summary>
  819. /// 操作工号
  820. /// </summary>
  821. /// <param name="sender"></param>
  822. /// <param name="e"></param>
  823. private void dgvUser_SelectionChanged(object sender, EventArgs e)
  824. {
  825. try
  826. {
  827. if (this.dgvUser.CurrentCell != null)
  828. {
  829. this._purviewID = Convert.ToInt32(this.dgvUser.Rows[this.dgvUser.CurrentCell.RowIndex].Cells["dgUserID"].Value);
  830. this._purviewType = 4;
  831. DataView dv = this._dtDataGird.DefaultView;
  832. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  833. this.dgvFunctionUsers.DataSource = dv.ToTable();
  834. BindReadOnly();
  835. }
  836. }
  837. catch (Exception ex)
  838. {
  839. this.btnCancel.Enabled = true;
  840. // 对异常进行共通处理
  841. ExceptionManager.HandleEventException(this.ToString(),
  842. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  843. }
  844. }
  845. /// <summary>
  846. /// 查看工号
  847. /// </summary>
  848. /// <param name="sender"></param>
  849. /// <param name="e"></param>
  850. private void dgvViewUser_SelectionChanged(object sender, EventArgs e)
  851. {
  852. try
  853. {
  854. if (this.dgvViewUser.CurrentCell != null)
  855. {
  856. this._purviewID = Convert.ToInt32(this.dgvViewUser.Rows[this.dgvViewUser.CurrentCell.RowIndex].Cells["dgvViewUserID"].Value);
  857. this._purviewType = 3;
  858. DataView dv = this._dtDataGird.DefaultView;
  859. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  860. this.dgvFunctionUsers.DataSource = dv.ToTable();
  861. BindReadOnly();
  862. }
  863. }
  864. catch (Exception ex)
  865. {
  866. this.btnCancel.Enabled = true;
  867. // 对异常进行共通处理
  868. ExceptionManager.HandleEventException(this.ToString(),
  869. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  870. }
  871. }
  872. /// <summary>
  873. /// 操作成型线
  874. /// </summary>
  875. /// <param name="sender"></param>
  876. /// <param name="e"></param>
  877. private void dgvGroutingLine_SelectionChanged(object sender, EventArgs e)
  878. {
  879. try
  880. {
  881. if (this.dgvGroutingLine.CurrentCell != null)
  882. {
  883. this._purviewID = Convert.ToInt32(this.dgvGroutingLine.Rows[this.dgvGroutingLine.CurrentCell.RowIndex].Cells["dgGroutingLineID"].Value);
  884. this._purviewType = 6;
  885. DataView dv = this._dtDataGird.DefaultView;
  886. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  887. this.dgvFunctionUsers.DataSource = dv.ToTable();
  888. BindReadOnly();
  889. }
  890. }
  891. catch (Exception ex)
  892. {
  893. this.btnCancel.Enabled = true;
  894. // 对异常进行共通处理
  895. ExceptionManager.HandleEventException(this.ToString(),
  896. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  897. }
  898. }
  899. /// <summary>
  900. /// 查看成型线
  901. /// </summary>
  902. /// <param name="sender"></param>
  903. /// <param name="e"></param>
  904. private void dgvViewGroutingLine_SelectionChanged(object sender, EventArgs e)
  905. {
  906. try
  907. {
  908. if (this.dgvViewGroutingLine.CurrentCell != null)
  909. {
  910. this._purviewID = Convert.ToInt32(this.dgvViewGroutingLine.Rows[this.dgvViewGroutingLine.CurrentCell.RowIndex].Cells["dgViewGroutingLineID"].Value);
  911. this._purviewType = 5;
  912. DataView dv = this._dtDataGird.DefaultView;
  913. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  914. this.dgvFunctionUsers.DataSource = dv.ToTable();
  915. BindReadOnly();
  916. }
  917. }
  918. catch (Exception ex)
  919. {
  920. this.btnCancel.Enabled = true;
  921. // 对异常进行共通处理
  922. ExceptionManager.HandleEventException(this.ToString(),
  923. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  924. }
  925. }
  926. /// <summary>
  927. /// 操作温湿度
  928. /// </summary>
  929. /// <param name="sender"></param>
  930. /// <param name="e"></param>
  931. private void dgvThermometer_SelectionChanged(object sender, EventArgs e)
  932. {
  933. try
  934. {
  935. if (this.dgvThermometer.CurrentCell != null)
  936. {
  937. this._purviewID = Convert.ToInt32(this.dgvThermometer.Rows[this.dgvThermometer.CurrentCell.RowIndex].Cells["dgThermometerID"].Value);
  938. this._purviewType = 12;
  939. DataView dv = this._dtDataGird.DefaultView;
  940. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  941. this.dgvFunctionUsers.DataSource = dv.ToTable();
  942. BindReadOnly();
  943. }
  944. }
  945. catch (Exception ex)
  946. {
  947. this.btnCancel.Enabled = true;
  948. // 对异常进行共通处理
  949. ExceptionManager.HandleEventException(this.ToString(),
  950. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  951. }
  952. }
  953. /// <summary>
  954. /// 查看温湿度
  955. /// </summary>
  956. /// <param name="sender"></param>
  957. /// <param name="e"></param>
  958. private void dgvViewThermometer_SelectionChanged(object sender, EventArgs e)
  959. {
  960. try
  961. {
  962. if (this.dgvViewThermometer.CurrentCell != null)
  963. {
  964. this._purviewID = Convert.ToInt32(this.dgvViewThermometer.Rows[this.dgvViewThermometer.CurrentCell.RowIndex].Cells["dgThermometerIDV"].Value);
  965. this._purviewType = 11;
  966. DataView dv = this._dtDataGird.DefaultView;
  967. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  968. this.dgvFunctionUsers.DataSource = dv.ToTable();
  969. BindReadOnly();
  970. }
  971. }
  972. catch (Exception ex)
  973. {
  974. this.btnCancel.Enabled = true;
  975. // 对异常进行共通处理
  976. ExceptionManager.HandleEventException(this.ToString(),
  977. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  978. }
  979. }
  980. private void dgvFunctionUsers_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
  981. {
  982. try
  983. {
  984. if (this.dgvFunctionUsers.Rows.Count <= 1)
  985. {
  986. return;
  987. }
  988. DataGridViewColumn columnItem = this.dgvFunctionUsers.Columns[e.ColumnIndex];
  989. if ("UserCode1".Equals(columnItem.Name))
  990. {
  991. _userCodeValue = this.dgvFunctionUsers.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
  992. }
  993. }
  994. catch (Exception ex)
  995. {
  996. // 对异常进行共通处理
  997. ExceptionManager.HandleEventException(this.ToString(),
  998. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  999. }
  1000. }
  1001. private void dgvFunctionUsers_CellValueChanged(object sender, DataGridViewCellEventArgs e)
  1002. {
  1003. try
  1004. {
  1005. if (this.dgvFunctionUsers.Rows.Count <= 1 || !_ShowFlag)
  1006. {
  1007. return;
  1008. }
  1009. DataGridViewRow rowItem = this.dgvFunctionUsers.Rows[e.RowIndex];
  1010. DataGridViewColumn columnItem = this.dgvFunctionUsers.Columns[e.ColumnIndex];
  1011. string OrganizationName = this.dgvFunctionUsers.Rows[e.RowIndex].Cells["OrganizationName1"].Value.ToString();
  1012. // 用编号获取产品信息
  1013. if ("UserCode1".Equals(columnItem.Name))
  1014. {
  1015. _ShowFlag = false;
  1016. DataTable dtNew = FormUtility.BindUserRowDataSource_FunctionCode(this.dgvFunctionUsers,
  1017. e.RowIndex, columnItem.Name, _userCodeValue);
  1018. if (dtNew != null && dtNew.Rows.Count > 0)
  1019. {
  1020. foreach (DataRow r in dtNew.Rows)
  1021. {
  1022. DataRow[] isR = this._dtDataGird.Select("Purviewid='" + this._purviewID + "' and UserID=" + r["UserID"] + " and PURVIEWTYPE=" + this._purviewType);
  1023. if (isR.Length == 0)
  1024. {
  1025. DataRow drNew = this._dtDataGird.NewRow();
  1026. drNew["UserID"] = r["UserID"];
  1027. drNew["UserCode"] = r["UserCode"];
  1028. drNew["UserName"] = r["UserName"];
  1029. drNew["OrganizationName"] = r["OrganizationName"];
  1030. drNew["Purviewid"] = this._purviewID;
  1031. drNew["PURVIEWTYPE"] = this._purviewType;
  1032. drNew["AddFlag"] = 1;
  1033. this._dtDataGird.Rows.Add(drNew);
  1034. dgvFunctionUsers.Rows[e.RowIndex].Cells["UserCode1"].ReadOnly = true;
  1035. // BindReadOnly();
  1036. }
  1037. }
  1038. }
  1039. //this.btnSave.Enabled = DataJudge.IsChange(this._dtDataGird);
  1040. this.btnSave.Enabled = true;
  1041. //this.dgvFunctionUsers.Rows[e.RowIndex].Cells["FunctionCode"].Value = this._functionCode;
  1042. //this._dtDataGird.AcceptChanges();
  1043. // 设置可输入单元格的颜色
  1044. this.dgvFunctionUsers.IsSetInputColumnsColor = true;
  1045. }
  1046. _ShowFlag = true;
  1047. }
  1048. catch (Exception ex)
  1049. {
  1050. //_ShowFlag = true;
  1051. // 对异常进行共通处理
  1052. ExceptionManager.HandleEventException(this.ToString(),
  1053. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1054. }
  1055. }
  1056. /// <summary>
  1057. /// 保存用户范围权限
  1058. /// </summary>
  1059. /// <returns>更新数据影响的行数</returns>
  1060. private object SaveUserRightInfo()
  1061. {
  1062. try
  1063. {
  1064. return SystemModuleProxy.Service.SaveUserRightList(this._dtDataGird);
  1065. }
  1066. catch (Exception ex)
  1067. {
  1068. throw ex;
  1069. }
  1070. }
  1071. private void dgvFunctionUsers_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
  1072. {
  1073. if (e.Row.Index != -1)
  1074. {
  1075. DataTable dt = this.dgvFunctionUsers.DataSource as DataTable;
  1076. string Purviewid = dt.Rows[e.Row.Index]["Purviewid"].ToString();
  1077. string PURVIEWTYPE = dt.Rows[e.Row.Index]["PURVIEWTYPE"].ToString();
  1078. string userID = dt.Rows[e.Row.Index]["userID"].ToString();
  1079. //DataGridViewRow rowItem = this.dgvFunctionUsers.Rows[e.Row.Index];
  1080. //string functionCode = rowItem.Cells["FunctionCode"].Value.ToString();
  1081. //string userID = this.dgvFunctionUsers.Rows[e.Row.Index].Cells["userID"].Value.ToString();
  1082. DataRow[] isR = this._dtDataGird.Select("Purviewid='" + Purviewid + "' and UserID=" + userID + " and PURVIEWTYPE=" + PURVIEWTYPE);
  1083. isR[0].Delete();
  1084. this.btnSave.Enabled = true;
  1085. }
  1086. }
  1087. /// <summary>
  1088. /// Tab页选定项索引改变后
  1089. /// </summary>
  1090. /// <param name="sender"></param>
  1091. /// <param name="e"></param>
  1092. private void tctlRight_SelectedIndexChanged(object sender, EventArgs e)
  1093. {
  1094. try
  1095. {
  1096. //查看工号
  1097. if (tctlRight.SelectedTab.Text == "查看工号范围")
  1098. {
  1099. dgvViewUser_SelectionChanged(sender, e);
  1100. tvwViewOrganization.SelectedNode = null;
  1101. tvwGroutinProductionLineCK.SelectedNode = null;
  1102. tvwGroutinProductionLine.SelectedNode = null;
  1103. tvwOrganization.SelectedNode = null;
  1104. }
  1105. else if (tctlRight.SelectedTab.Text == "操作工号范围")
  1106. {
  1107. dgvUser_SelectionChanged(sender, e);
  1108. tvwViewOrganization.SelectedNode = null;
  1109. tvwGroutinProductionLineCK.SelectedNode = null;
  1110. tvwGroutinProductionLine.SelectedNode = null;
  1111. tvwOrganization.SelectedNode = null;
  1112. }
  1113. else if (tctlRight.SelectedTab.Text == "查看成型线范围")
  1114. {
  1115. dgvViewGroutingLine_SelectionChanged(sender, e);
  1116. tvwViewOrganization.SelectedNode = null;
  1117. tvwGroutinProductionLineCK.SelectedNode = null;
  1118. tvwGroutinProductionLine.SelectedNode = null;
  1119. tvwOrganization.SelectedNode = null;
  1120. }
  1121. else if (tctlRight.SelectedTab.Text == "操作成型线范围")
  1122. {
  1123. dgvGroutingLine_SelectionChanged(sender, e);
  1124. tvwViewOrganization.SelectedNode = null;
  1125. tvwGroutinProductionLineCK.SelectedNode = null;
  1126. tvwGroutinProductionLine.SelectedNode = null;
  1127. tvwOrganization.SelectedNode = null;
  1128. }
  1129. else if (tctlRight.SelectedTab.Text == "查看温湿计范围")
  1130. {
  1131. dgvViewThermometer_SelectionChanged(sender, e);
  1132. tvwViewOrganization.SelectedNode = null;
  1133. tvwGroutinProductionLineCK.SelectedNode = null;
  1134. tvwGroutinProductionLine.SelectedNode = null;
  1135. tvwOrganization.SelectedNode = null;
  1136. }
  1137. else if (tctlRight.SelectedTab.Text == "操作温湿计范围")
  1138. {
  1139. dgvThermometer_SelectionChanged(sender, e);
  1140. tvwViewOrganization.SelectedNode = null;
  1141. tvwGroutinProductionLineCK.SelectedNode = null;
  1142. tvwGroutinProductionLine.SelectedNode = null;
  1143. tvwOrganization.SelectedNode = null;
  1144. }
  1145. else if (tctlRight.SelectedTab.Text == "操作部门范围")
  1146. {
  1147. tvwOrganization.SelectedNode = tvwOrganization.Nodes[0];
  1148. tvwViewOrganization.SelectedNode = null;
  1149. tvwGroutinProductionLineCK.SelectedNode = null;
  1150. tvwGroutinProductionLine.SelectedNode = null;
  1151. }
  1152. else if (tctlRight.SelectedTab.Text == "查看部门范围")
  1153. {
  1154. tvwViewOrganization.SelectedNode = tvwViewOrganization.Nodes[0];
  1155. tvwGroutinProductionLineCK.SelectedNode = null;
  1156. tvwGroutinProductionLine.SelectedNode = null;
  1157. tvwOrganization.SelectedNode = null;
  1158. }
  1159. else if (tctlRight.SelectedTab.Text == "操作工序范围")
  1160. {
  1161. tvwGroutinProductionLineCK.SelectedNode = tvwGroutinProductionLineCK.Nodes[0];
  1162. tvwViewOrganization.SelectedNode = null;
  1163. tvwGroutinProductionLine.SelectedNode = null;
  1164. tvwOrganization.SelectedNode = null;
  1165. }
  1166. else if (tctlRight.SelectedTab.Text == "查看工序范围")
  1167. {
  1168. tvwGroutinProductionLine.SelectedNode = tvwGroutinProductionLine.Nodes[0];
  1169. tvwViewOrganization.SelectedNode = null;
  1170. tvwGroutinProductionLineCK.SelectedNode = null;
  1171. tvwOrganization.SelectedNode = null;
  1172. }
  1173. }
  1174. catch (Exception ex)
  1175. {
  1176. throw ex;
  1177. }
  1178. }
  1179. private void dgvFunctionUsers_Sorted(object sender, EventArgs e)
  1180. {
  1181. BindReadOnly();
  1182. }
  1183. private void treeViewCancel_AfterSelect(object sender, TreeViewEventArgs e)
  1184. {
  1185. try
  1186. {
  1187. this._purviewID = Convert.ToInt32(e.Node.Tag);
  1188. if (!e.Node.Name.Contains("ProductionLine_"))
  1189. {
  1190. this._purviewType = 13;
  1191. DataView dv = this._dtDataGird.DefaultView;
  1192. dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
  1193. this.dgvFunctionUsers.DataSource = dv.ToTable();
  1194. BindReadOnly();
  1195. }
  1196. }
  1197. catch (Exception ex)
  1198. {
  1199. this.btnCancel.Enabled = true;
  1200. // 对异常进行共通处理
  1201. ExceptionManager.HandleEventException(this.ToString(),
  1202. System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
  1203. }
  1204. }
  1205. }
  1206. }