| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296 |
- /*******************************************************************************
- * Copyright(c) 2014 DongkeSoft All rights reserved. / Confidential
- * 类的信息:
- * 1.程序名称:F_MST_0204.cs
- * 2.功能描述:范围权限
- * 编辑履历:
- * 作者 日期 版本 修改内容
- * 王鑫 2014/09/17 1.00 新建
- *******************************************************************************/
- using System;
- using System.Data;
- using System.Windows.Forms;
- using Dongke.IBOSS.PRD.Basics.BaseControls;
- using Dongke.IBOSS.PRD.Basics.BaseResources;
- using Dongke.IBOSS.PRD.Basics.Library;
- using Dongke.IBOSS.PRD.Client.CommonModule;
- using Dongke.IBOSS.PRD.Client.Controls;
- using Dongke.IBOSS.PRD.WCF.Proxys;
- namespace Dongke.IBOSS.PRD.Client.SystemModule
- {
- public partial class F_MST_0207 : FormBase
- {
- #region 成员变量
- // 传过来的用户ID
- private int _userID;
- // 页面的数据源
- DataSet _userRightData;
- // 是否是第一次加载页面
- bool _isFirstLoad = true;
- //查看工号权限
- bool _viewUser = false; //默认是否选中
- // 工号权限
- bool _user = false; //默认是否选中
- // 查看成型线
- bool _viewGroutingLine = false;
- // 操作成型线
- bool _groutingLine = false;//
- // 操作温湿度
- bool _thermometer = false;
- // 查看温湿度
- bool _viewThermometer = false;
- // 操作部门
- bool _organization = false;
- // 查看部门
- bool _viewOrganization = false;
- // 操作工序
- bool _proceduce = false;
- // 查看工序
- bool _viewProceduce = false;
- // 数据表的数据源
- private DataTable _dtDataGird = null;
- private string _userCodeValue;
- private bool _ShowFlag = true;
- private int? _purviewID = null;
- private int? _purviewType = null;
- #endregion
- #region 构造函数
- public F_MST_0207()
- {
- InitializeComponent();
- }
- public F_MST_0207(int userID)
- {
- InitializeComponent();
- this._userID = userID;
- // 设置标题
- this.Text = FormTitles.F_MST_0204;
- // 工具栏按钮文本赋值
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- public F_MST_0207(int userID, string userCode)
- {
- InitializeComponent();
- this._userID = userID;
- // 设置标题
- this.Text = FormTitles.F_MST_0204;
- // 工具栏按钮文本赋值
- this.btnSave.Text = ButtonText.BTN_SAVE;
- this.btnCancel.Text = ButtonText.BTN_CLOSE;
- }
- #endregion
- #region 事件
- /// <summary>
- /// 窗体加载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_0204_Load(object sender, EventArgs e)
- {
- try
- {
- // 保存按钮不可用
- //this.btnSave.Enabled = false;
- this._userRightData = (DataSet)DoAsync(new BaseAsyncMethod(this.GetUserRightData));
- if (this._userRightData != null && this._userRightData.Tables.Count >= Constant.INT_IS_ZERO)
- {
- //加载用户列表
- DataSet functionUsers = (DataSet)DoAsync(new BaseAsyncMethod(GetFunctionUsers));
- //this.btnSave.Enabled = DataJudge.IsChange(this._userFunctionRightData);
- //this.btnCancel.Enabled = true;
- if (functionUsers != null)
- {
- this.dgvFunctionUsers.AutoGenerateColumns = false;
- this.dgvFunctionUsers.DataSource = functionUsers.Tables[0];
- //this.dgvFunctionUsers.Columns["UserCode"].ReadOnly = true;
- this.dgvFunctionUsers.Columns["UserName1"].ReadOnly = true;
- this.dgvFunctionUsers.Columns["OrganizationName1"].ReadOnly = true;
- this._dtDataGird = functionUsers.Tables[0];
- //
- ////DataView dv = functionUsers.Tables[0].DefaultView;
- ////dv.RowFilter = "FunctionCode='-100'";
- ////this.dgvFunctionUsers.DataSource = dv.ToTable();
- }
- //查看业务部门树的生成
- this.InitOrganizationTreeView(this._userRightData.Tables[0], true);
- this.tvwViewOrganization.ExpandAll();
- // 操作业务部门树的生成
- this.InitOrganizationTreeView(this._userRightData.Tables[1], false);
- this.tvwOrganization.ExpandAll();
- // 设置DataGridView属性
- this.dgvViewUser.AutoGenerateColumns = false;
- this.dgvViewUser.Columns[5].ReadOnly = true;
- // 工号权限的绑定
- this.dgvViewUser.DataSource = this._userRightData.Tables[2];
- // 设置DataGridView属性
- this.dgvUser.AutoGenerateColumns = false;
- this.dgvUser.Columns[5].ReadOnly = true;
- // 工号权限的绑定
- this.dgvUser.DataSource = this._userRightData.Tables[3];
- // 设置DataGridView属性
- this.dgvViewGroutingLine.AutoGenerateColumns = false;
- this.dgvViewGroutingLine.Columns[3].ReadOnly = true;
- // 查看成型线权限的绑定
- this.dgvViewGroutingLine.DataSource = this._userRightData.Tables[4];
- // 设置DataGridView属性
- this.dgvGroutingLine.AutoGenerateColumns = false;
- this.dgvGroutingLine.Columns[3].ReadOnly = true;
- // 操作成型线权限的绑定
- this.dgvGroutingLine.DataSource = this._userRightData.Tables[5];
- // 生成查看生产线及工序树
- InitGroutingLineTreeView(this._userRightData.Tables[6], this._userRightData.Tables[8]);
- this.tvwGroutinProductionLine.ExpandAll();
- InitGroutingLineTreeCKView(this._userRightData.Tables[7], this._userRightData.Tables[9]);
- this.tvwGroutinProductionLineCK.ExpandAll();
- // 撤销工序范围 InitCancelTreeCKView
- DataTable dtCopy = this._userRightData.Tables[6].Copy();
- dtCopy.TableName = "newtable";
- foreach (DataRow dr in dtCopy.Rows)
- {
- dr["purviewtype"] = -99;
- }
- dtCopy.AcceptChanges();
- this._userRightData.Tables.Add(dtCopy);
- InitCancelTreeCKView(dtCopy, this._userRightData.Tables[12]);
- this.treeViewCancel.ExpandAll();
- // 设置DataGridView属性
- this.dgvViewThermometer.AutoGenerateColumns = false;
- this.dgvViewThermometer.Columns[3].ReadOnly = true;
- // 查看温湿计权限的绑定
- this.dgvViewThermometer.DataSource = this._userRightData.Tables[10];
- // 设置DataGridView属性
- this.dgvThermometer.AutoGenerateColumns = false;
- this.dgvThermometer.Columns[3].ReadOnly = true;
- // 操作温湿计权限的绑定
- this.dgvThermometer.DataSource = this._userRightData.Tables[11];
- //
- DataView dv = functionUsers.Tables[0].DefaultView;
- dv.RowFilter = "Purviewid='-100'";
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- }
- this._isFirstLoad = false;
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 根据系统功能ID取得使用该功能的用户列表
- /// </summary>
- /// <returns></returns>
- private DataSet GetFunctionUsers()
- {
- try
- {
- return SystemModuleProxy.Service.GetFunctionUserPurviewList();
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 窗体关闭时事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void F_MST_0204_FormClosing(object sender, FormClosingEventArgs e)
- {
- try
- {
- // 判断数据是否被修改过,修改过需要提示保存消息
- //if (DataJudge.IsChange(this._userRightData))
- //if (this.btnSave.Enabled)
- if (DataJudge.IsChange(this._dtDataGird))
- {
- DialogResult result = MessageBox.Show(Messages.MSG_CMN_Q001, this.Text,
- MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
- if (result == DialogResult.Yes)
- {
- // 保存数据
- btnSave_Click(sender, e);
- }
- else if (result == DialogResult.Cancel)
- {
- e.Cancel = true;
- }
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 组织机构范围权限的子节点选择后,父节点自动选择
- /// 父节点选择之后,子节点自动选择
- /// 选择之后修改后台数据源
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwViewOrganization_AfterCheck(object sender, TreeViewEventArgs e)
- {
- try
- {
- //int purviewID = Convert.ToInt32(e.Node.Tag);
- //foreach (DataRow dataRow in _userRightData.Tables[0].Rows)
- //{
- // if (purviewID == Convert.ToInt32(dataRow["PurviewID"]))
- // {
- // dataRow["RightFlag"] = e.Node.Checked;
- // break;
- // }
- //}
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 窗体关闭
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCancel_Click(object sender, EventArgs e)
- {
- this.Close();
- }
- //保存按钮事件
- private void btnSave_Click(object sender, EventArgs e)
- {
- try
- {
- this.btnSave.Enabled = false;
- this.btnCancel.Enabled = false;
- int returnAffectRows = (int)DoAsync(new BaseAsyncMethod(SaveUserRightInfo));
- this.btnSave.Enabled = true;
- this.btnCancel.Enabled = true;
- if (returnAffectRows > Constant.INT_IS_ZERO)
- {
- this._dtDataGird.AcceptChanges();
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_I001, "修改用户范围权限", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
- this.Close();
- }
- else
- {
- // 提示信息
- MessageBox.Show(string.Format(Messages.MSG_CMN_W001, "修改用户范围权限", "保存"),
- this.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
- }
- }
- catch (Exception ex)
- {
- this.btnSave.Enabled = true;
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 操作部门树结点改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwOrganization_AfterCheck(object sender, TreeViewEventArgs e)
- {
- try
- {
- //int purviewID = Convert.ToInt32(e.Node.Tag);
- //foreach (DataRow dataRow in _userRightData.Tables[1].Rows)
- //{
- // if (purviewID == Convert.ToInt32(dataRow["PurviewID"]))
- // {
- // dataRow["RightFlag"] = e.Node.Checked;
- // break;
- // }
- //}
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 操作业务部门树形全部收缩
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnOrganizationCollapse_Click(object sender, EventArgs e)
- {
- this.tvwOrganization.CollapseAll();
- }
- /// <summary>
- /// 操作员范围选择发生改变,保存按钮状态
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- // <summary>
- /// 操作员范围选择发生改变,保存按钮状态
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_CellValueChanged_1(object sender, DataGridViewCellEventArgs e)
- {
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- /// <summary>
- /// 生产线单元格值改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvViewGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- /// <summary>
- /// 操作成型生产线单元格值改变
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGroutingLine_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- /// <summary>
- /// 查看生产线及工序范围权限选中改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwGroutinProductionLine_AfterCheck(object sender, TreeViewEventArgs e)
- {
- try
- {
- //int purviewID = Convert.ToInt32(e.Node.Tag);
- ////起始为ProductionLine_为成型生产线,否则为工序
- //foreach (DataRow dataRow in (e.Node.Name.StartsWith("ProductionLine_") ? _userRightData.Tables[6].Rows : _userRightData.Tables[8].Rows))
- //{
- // if (purviewID == Convert.ToInt32(dataRow["PurviewID"]))
- // {
- // dataRow["RightFlag"] = e.Node.Checked;
- // break;
- // }
- // if (e.Node.Parent != null)
- // {
- // if (e.Node.Checked)
- // e.Node.Parent.Checked = true;
- // }
- //}
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 温湿计范围权限改变后
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvThermometer_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- //if (!this._isFirstLoad)
- //{
- // // 保存按钮状态改变
- // this.btnSave.Enabled = DataJudge.IsChange(this._userRightData);
- //}
- }
- /// <summary>
- /// 操作工序范围选定值改变后
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwGroutinProductionLineCK_AfterCheck(object sender, TreeViewEventArgs e)
- {
- }
- /// <summary>
- /// 操作工序展开所有节点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCKOpen_Click(object sender, EventArgs e)
- {
- this.tvwGroutinProductionLineCK.ExpandAll();
- }
- /// <summary>
- /// 操作工序折叠所有节点
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnCKClose_Click(object sender, EventArgs e)
- {
- this.tvwGroutinProductionLineCK.CollapseAll();
- }
- #endregion
- #region 私有方法
- /// <summary>
- /// 加载查看工序树结点
- /// </summary>
- /// <param name="GroutingLineTable"></param>
- /// <param name="ProductionLineTable"></param>
- private void InitCancelTreeCKView(DataTable GroutingLineTable, DataTable ProductionLineTable)
- {
- foreach (DataRow row in GroutingLineTable.Rows)
- {
- TreeNode sNode;
- sNode = new TreeNode();
- sNode.Text = '[' + row["ProductionLineCode"].ToString() + ']' + row["ProductionLinename"].ToString();
- sNode.Name = "ProductionLine_" + row["ProductionLineCode"].ToString();
- sNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- sNode.Checked = true;
- }
- // this.tvwGroutinProductionLineCK.Nodes.Add(sNode);
- this.treeViewCancel.Nodes.Add(sNode);
- InitCancelProcedureTreeView(sNode, ProductionLineTable);
- }
- }
- /// <summary>
- /// 生成查看成工序树
- /// </summary>
- /// <param name="GroutingLineTable"></param>
- /// <param name="ProductionLineTable"></param>
- private void InitCancelProcedureTreeView(TreeNode sNode, DataTable ProductionLineTable)
- {
- DataRow[] rows = ProductionLineTable.Select
- ("ProductionLineid=" + sNode.Tag.ToString());
- foreach (DataRow row in rows)
- {
- TreeNode childNode;
- childNode = sNode.Nodes.Add('[' + row["ProcedureCode"].ToString() + ']' + row["Procedurename"].ToString());
- childNode.Name = "Procedure_" + row["ProcedureCode"].ToString();
- childNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- childNode.Checked = true;
- }
- }
- }
- /// 获取员工档案数据集
- /// </summary>
- /// <returns></returns>
- private DataSet GetUserRightData()
- {
- return SystemModuleProxy.Service.GetUserRightData(-2);
- }
- /// <summary>
- /// 根据取得的数据,生成部门树
- /// </summary>
- /// <param name="treeTable"></param>
- /// <param name="isViewOrganization">是否是查看部门</param>
- private void InitOrganizationTreeView(DataTable treeTable, bool isViewOrganization)
- {
- try
- {
- TreeNode node = null;
- DataRow[] organizationRows = treeTable.Select
- ("OrganizationCode LIKE '0%' AND LEN(OrganizationCode) = 3");
- // 递归生成功能权限树
- this.InitTreeView(treeTable, organizationRows, node, isViewOrganization);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- /// <summary>
- /// 递归创建部门树
- /// </summary>
- /// <param name="treeTable"></param>
- /// <param name="rows"></param>
- /// <param name="node"></param>
- private void InitTreeView(DataTable treeTable, DataRow[] rows, TreeNode node, bool isViewOrganization)
- {
- foreach (DataRow row in rows)
- {
- TreeNode sNode;
- if (node == null)
- {
- sNode = new TreeNode();
- sNode.Text = '[' + row["OrganizationCode"].ToString() + ']' + row["OrganizationName"].ToString();
- sNode.Name = row["OrganizationCode"].ToString();
- sNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- sNode.Checked = true;
- }
- if (isViewOrganization)
- {
- this.tvwViewOrganization.Nodes.Add(sNode);
- }
- else
- {
- this.tvwOrganization.Nodes.Add(sNode);
- }
- }
- else
- {
- sNode = node.Nodes.Add('[' + row["OrganizationCode"].ToString() + ']' + row["OrganizationName"].ToString());
- sNode.Name = row["OrganizationCode"].ToString();
- sNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- sNode.Checked = true;
- }
- }
- string filterExpression = "OrganizationCode LIKE '" + row["OrganizationCode"].ToString()
- + "%' AND LEN(OrganizationCode) = " + (row["OrganizationCode"].ToString().Length + 3);
- DataRow[] subRows = treeTable.Select(filterExpression);
- // 递归方法
- InitTreeView(treeTable, subRows, sNode, isViewOrganization);
- }
- }
- /// <summary>
- /// 将全部节点选择或者取消选中
- /// </summary>
- /// <param name="treeView"></param>
- /// <param name="flag"></param>
- private void CheckTreeview(TreeView treeView, bool flag)
- {
- TreeNodeCollection nodes = treeView.Nodes;
- foreach (TreeNode node in nodes)
- {
- CheckSubNodes(node, flag);
- }
- }
- /// <summary>
- /// 递归选中节点或者取消选中节点
- /// </summary>
- /// <param name="treeNode"></param>
- /// <param name="flag"></param>
- private void CheckSubNodes(TreeNode treeNode, bool flag)
- {
- treeNode.Checked = flag;
- foreach (TreeNode node in treeNode.Nodes)
- {
- CheckSubNodes(node, flag);
- }
- }
- /// <summary>
- /// 生成查看成型线树
- /// </summary>
- /// <param name="GroutingLineTable"></param>
- /// <param name="ProductionLineTable"></param>
- private void InitGroutingLineTreeView(DataTable GroutingLineTable, DataTable ProductionLineTable)
- {
- foreach (DataRow row in GroutingLineTable.Rows)
- {
- TreeNode sNode;
- sNode = new TreeNode();
- sNode.Text = '[' + row["ProductionLineCode"].ToString() + ']' + row["ProductionLinename"].ToString();
- sNode.Name = "ProductionLine_" + row["ProductionLineCode"].ToString();
- sNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- sNode.Checked = true;
- }
- this.tvwGroutinProductionLine.Nodes.Add(sNode);
- InitGroutingProductionTreeView(sNode, ProductionLineTable);
- }
- }
- /// <summary>
- /// 加载查看工序树结点
- /// </summary>
- /// <param name="GroutingLineTable"></param>
- /// <param name="ProductionLineTable"></param>
- private void InitGroutingLineTreeCKView(DataTable GroutingLineTable, DataTable ProductionLineTable)
- {
- foreach (DataRow row in GroutingLineTable.Rows)
- {
- TreeNode sNode;
- sNode = new TreeNode();
- sNode.Text = '[' + row["ProductionLineCode"].ToString() + ']' + row["ProductionLinename"].ToString();
- sNode.Name = "ProductionLine_" + row["ProductionLineCode"].ToString();
- sNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- sNode.Checked = true;
- }
- this.tvwGroutinProductionLineCK.Nodes.Add(sNode);
- InitGroutingProductionTreeView(sNode, ProductionLineTable);
- }
- }
- /// <summary>
- /// 生成查看成工序树
- /// </summary>
- /// <param name="GroutingLineTable"></param>
- /// <param name="ProductionLineTable"></param>
- private void InitGroutingProductionTreeView(TreeNode sNode, DataTable ProductionLineTable)
- {
- DataRow[] rows = ProductionLineTable.Select
- ("ProductionLineid=" + sNode.Tag.ToString());
- foreach (DataRow row in rows)
- {
- TreeNode childNode;
- childNode = sNode.Nodes.Add('[' + row["ProcedureCode"].ToString() + ']' + row["Procedurename"].ToString());
- childNode.Name = "Procedure_" + row["ProcedureCode"].ToString();
- childNode.Tag = row["PurviewID"];
- if (Convert.ToBoolean(row["RightFlag"]))
- {
- childNode.Checked = true;
- }
- }
- }
- #endregion
- /// <summary>
- /// 绑定原来数据只能删除不能编辑
- /// </summary>
- private void BindReadOnly()
- {
- foreach (DataGridViewRow row in this.dgvFunctionUsers.Rows)
- {
- if (row.Cells["AddFlag"].Value != null)
- {
- row.Cells["UserCode1"].ReadOnly = true;
- }
- }
- this.dgvFunctionUsers.IsSetInputColumnsColor = true;
- }
- /// <summary>
- /// 操作部门
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwOrganization_AfterSelect(object sender, TreeViewEventArgs e)
- {
- try
- {
- //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
- //{
- this._purviewID = Convert.ToInt32(e.Node.Tag);
- this._purviewType = 2;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- //}
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- // 查看部门
- private void tvwViewOrganization_AfterSelect(object sender, TreeViewEventArgs e)
- {
- try
- {
- //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
- //{
- this._purviewID = Convert.ToInt32(e.Node.Tag);
- this._purviewType = 1;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- //}
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 操作工序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwGroutinProductionLineCK_AfterSelect(object sender, TreeViewEventArgs e)
- {
- try
- {
- //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
- //{
- this._purviewID = Convert.ToInt32(e.Node.Tag);
- if (e.Node.Name.Contains("ProductionLine_"))
- {
- this._purviewType = 8;
- }
- else
- {
- this._purviewType = 10;
- }
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- //}
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 查看工序
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tvwGroutinProductionLine_AfterSelect(object sender, TreeViewEventArgs e)
- {
- try
- {
- //if (e.Node.Name == Constant.INT_IS_ONE.ToString() || e.Node.Name == Constant.INT_IS_ZERO.ToString())
- //{
- this._purviewID = Convert.ToInt32(e.Node.Tag);
- if (e.Node.Name.Contains("ProductionLine_"))
- {
- this._purviewType = 7;
- }
- else
- {
- this._purviewType = 9;
- }
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- //}
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 操作工号
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvUser_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvUser.CurrentCell != null)
- {
- this._purviewID = Convert.ToInt32(this.dgvUser.Rows[this.dgvUser.CurrentCell.RowIndex].Cells["dgUserID"].Value);
- this._purviewType = 4;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 查看工号
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvViewUser_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvViewUser.CurrentCell != null)
- {
- this._purviewID = Convert.ToInt32(this.dgvViewUser.Rows[this.dgvViewUser.CurrentCell.RowIndex].Cells["dgvViewUserID"].Value);
- this._purviewType = 3;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 操作成型线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvGroutingLine_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvGroutingLine.CurrentCell != null)
- {
- this._purviewID = Convert.ToInt32(this.dgvGroutingLine.Rows[this.dgvGroutingLine.CurrentCell.RowIndex].Cells["dgGroutingLineID"].Value);
- this._purviewType = 6;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 查看成型线
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvViewGroutingLine_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvViewGroutingLine.CurrentCell != null)
- {
- this._purviewID = Convert.ToInt32(this.dgvViewGroutingLine.Rows[this.dgvViewGroutingLine.CurrentCell.RowIndex].Cells["dgViewGroutingLineID"].Value);
- this._purviewType = 5;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 操作温湿度
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvThermometer_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvThermometer.CurrentCell != null)
- {
- this._purviewID = Convert.ToInt32(this.dgvThermometer.Rows[this.dgvThermometer.CurrentCell.RowIndex].Cells["dgThermometerID"].Value);
- this._purviewType = 12;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 查看温湿度
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void dgvViewThermometer_SelectionChanged(object sender, EventArgs e)
- {
- try
- {
- if (this.dgvViewThermometer.CurrentCell != null)
- {
- this._purviewID = Convert.ToInt32(this.dgvViewThermometer.Rows[this.dgvViewThermometer.CurrentCell.RowIndex].Cells["dgThermometerIDV"].Value);
- this._purviewType = 11;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void dgvFunctionUsers_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e)
- {
- try
- {
- if (this.dgvFunctionUsers.Rows.Count <= 1)
- {
- return;
- }
- DataGridViewColumn columnItem = this.dgvFunctionUsers.Columns[e.ColumnIndex];
- if ("UserCode1".Equals(columnItem.Name))
- {
- _userCodeValue = this.dgvFunctionUsers.Rows[e.RowIndex].Cells[columnItem.Name].Value + "";
- }
- }
- catch (Exception ex)
- {
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- private void dgvFunctionUsers_CellValueChanged(object sender, DataGridViewCellEventArgs e)
- {
- try
- {
- if (this.dgvFunctionUsers.Rows.Count <= 1 || !_ShowFlag)
- {
- return;
- }
- DataGridViewRow rowItem = this.dgvFunctionUsers.Rows[e.RowIndex];
- DataGridViewColumn columnItem = this.dgvFunctionUsers.Columns[e.ColumnIndex];
- string OrganizationName = this.dgvFunctionUsers.Rows[e.RowIndex].Cells["OrganizationName1"].Value.ToString();
- // 用编号获取产品信息
- if ("UserCode1".Equals(columnItem.Name))
- {
- _ShowFlag = false;
- DataTable dtNew = FormUtility.BindUserRowDataSource_FunctionCode(this.dgvFunctionUsers,
- e.RowIndex, columnItem.Name, _userCodeValue);
- if (dtNew != null && dtNew.Rows.Count > 0)
- {
- foreach (DataRow r in dtNew.Rows)
- {
- DataRow[] isR = this._dtDataGird.Select("Purviewid='" + this._purviewID + "' and UserID=" + r["UserID"] + " and PURVIEWTYPE=" + this._purviewType);
- if (isR.Length == 0)
- {
- DataRow drNew = this._dtDataGird.NewRow();
- drNew["UserID"] = r["UserID"];
- drNew["UserCode"] = r["UserCode"];
- drNew["UserName"] = r["UserName"];
- drNew["OrganizationName"] = r["OrganizationName"];
- drNew["Purviewid"] = this._purviewID;
- drNew["PURVIEWTYPE"] = this._purviewType;
- drNew["AddFlag"] = 1;
- this._dtDataGird.Rows.Add(drNew);
- dgvFunctionUsers.Rows[e.RowIndex].Cells["UserCode1"].ReadOnly = true;
- // BindReadOnly();
- }
- }
- }
- //this.btnSave.Enabled = DataJudge.IsChange(this._dtDataGird);
- this.btnSave.Enabled = true;
- //this.dgvFunctionUsers.Rows[e.RowIndex].Cells["FunctionCode"].Value = this._functionCode;
- //this._dtDataGird.AcceptChanges();
- // 设置可输入单元格的颜色
- this.dgvFunctionUsers.IsSetInputColumnsColor = true;
- }
- _ShowFlag = true;
- }
- catch (Exception ex)
- {
- //_ShowFlag = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- /// <summary>
- /// 保存用户范围权限
- /// </summary>
- /// <returns>更新数据影响的行数</returns>
- private object SaveUserRightInfo()
- {
- try
- {
- return SystemModuleProxy.Service.SaveUserRightList(this._dtDataGird);
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- private void dgvFunctionUsers_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
- {
- if (e.Row.Index != -1)
- {
- DataTable dt = this.dgvFunctionUsers.DataSource as DataTable;
- string Purviewid = dt.Rows[e.Row.Index]["Purviewid"].ToString();
- string PURVIEWTYPE = dt.Rows[e.Row.Index]["PURVIEWTYPE"].ToString();
- string userID = dt.Rows[e.Row.Index]["userID"].ToString();
- //DataGridViewRow rowItem = this.dgvFunctionUsers.Rows[e.Row.Index];
- //string functionCode = rowItem.Cells["FunctionCode"].Value.ToString();
- //string userID = this.dgvFunctionUsers.Rows[e.Row.Index].Cells["userID"].Value.ToString();
- DataRow[] isR = this._dtDataGird.Select("Purviewid='" + Purviewid + "' and UserID=" + userID + " and PURVIEWTYPE=" + PURVIEWTYPE);
- isR[0].Delete();
- this.btnSave.Enabled = true;
- }
- }
- /// <summary>
- /// Tab页选定项索引改变后
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void tctlRight_SelectedIndexChanged(object sender, EventArgs e)
- {
- try
- {
- //查看工号
- if (tctlRight.SelectedTab.Text == "查看工号范围")
- {
- dgvViewUser_SelectionChanged(sender, e);
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "操作工号范围")
- {
- dgvUser_SelectionChanged(sender, e);
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "查看成型线范围")
- {
- dgvViewGroutingLine_SelectionChanged(sender, e);
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "操作成型线范围")
- {
- dgvGroutingLine_SelectionChanged(sender, e);
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "查看温湿计范围")
- {
- dgvViewThermometer_SelectionChanged(sender, e);
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "操作温湿计范围")
- {
- dgvThermometer_SelectionChanged(sender, e);
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "操作部门范围")
- {
- tvwOrganization.SelectedNode = tvwOrganization.Nodes[0];
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "查看部门范围")
- {
- tvwViewOrganization.SelectedNode = tvwViewOrganization.Nodes[0];
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "操作工序范围")
- {
- tvwGroutinProductionLineCK.SelectedNode = tvwGroutinProductionLineCK.Nodes[0];
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLine.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- else if (tctlRight.SelectedTab.Text == "查看工序范围")
- {
- tvwGroutinProductionLine.SelectedNode = tvwGroutinProductionLine.Nodes[0];
- tvwViewOrganization.SelectedNode = null;
- tvwGroutinProductionLineCK.SelectedNode = null;
- tvwOrganization.SelectedNode = null;
- }
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- private void dgvFunctionUsers_Sorted(object sender, EventArgs e)
- {
- BindReadOnly();
- }
- private void treeViewCancel_AfterSelect(object sender, TreeViewEventArgs e)
- {
- try
- {
- this._purviewID = Convert.ToInt32(e.Node.Tag);
- if (!e.Node.Name.Contains("ProductionLine_"))
- {
- this._purviewType = 13;
- DataView dv = this._dtDataGird.DefaultView;
- dv.RowFilter = "purviewID=" + this._purviewID + " and purviewType=" + this._purviewType;
- this.dgvFunctionUsers.DataSource = dv.ToTable();
- BindReadOnly();
- }
- }
- catch (Exception ex)
- {
- this.btnCancel.Enabled = true;
- // 对异常进行共通处理
- ExceptionManager.HandleEventException(this.ToString(),
- System.Reflection.MethodBase.GetCurrentMethod().Name, this.Text, ex);
- }
- }
- }
- }
|