private void btnConfirm_Click(object sender, EventArgs e) { if (this.CheckInput()) { // 当前选择的部门 //this.SelectedId = {this.tvModule.SelectedNode.Tag as DataRow)[BaseModuleEntity.FieldId].ToString()}; this.SelectedId = ((DataRow)this.tvModule.SelectedNode.Tag)[BaseModuleEntity.FieldId].ToString(); this.SelectedCode = BaseBusinessLogic.GetProperty(this.DTModule, this.SelectedId, BaseModuleEntity.FieldCode); this.SelectedFullName = this.tvModule.SelectedNode.Text; // 检查移动的有效性 if (this.CheckMove) { if (!this.CheckInputMove()) { return; } } if (this.OnButtonConfirmClick != null) { if (!this.OnButtonConfirmClick()) { return; } } this.DialogResult = DialogResult.OK; this.Close(); } }
private void mItmAddStaff_Click(object sender, EventArgs e) { string returnValue = string.Empty; string companyId = string.Empty; string subCompanyId = string.Empty; string departmentId = string.Empty; string workgroupId = string.Empty; TreeNode treeNode = this.tvOrganize.SelectedNode; while (treeNode != null) { string id = string.Empty; if (treeNode.Tag is DataRow) { id = (treeNode.Tag as DataRow)[BaseOrganizeEntity.FieldId].ToString(); } else { id = treeNode.Tag.ToString(); } if (BaseBusinessLogic.GetProperty(this.DTOrganize, id, BaseOrganizeEntity.FieldCategory).ToUpper() == "Company".ToUpper()) { if (string.IsNullOrEmpty(companyId)) { companyId = id; } } else if (BaseBusinessLogic.GetProperty(this.DTOrganize, id, BaseOrganizeEntity.FieldCategory).ToUpper() == "SubCompany".ToUpper()) { if (string.IsNullOrEmpty(subCompanyId)) { subCompanyId = id; } } else if (BaseBusinessLogic.GetProperty(this.DTOrganize, id, BaseOrganizeEntity.FieldCategory).ToUpper() == "Department".ToUpper()) { if (string.IsNullOrEmpty(departmentId)) { departmentId = id; } } else if (BaseBusinessLogic.GetProperty(this.DTOrganize, id, BaseOrganizeEntity.FieldCategory).ToUpper() == "WorkGroup".ToUpper()) { if (string.IsNullOrEmpty(workgroupId)) { workgroupId = id; } } treeNode = treeNode.Parent; } throw new InvalidOperationException("FrmStaffAdd"); //FrmStaffAdd frmStaffAdd = new FrmStaffAdd(companyId, subCompanyId, departmentId, workgroupId); //if (frmStaffAdd.ShowDialog(this) == DialogResult.OK) //{ // returnValue = frmStaffAdd.EntityId; //} }
private void GetTableRealName() { if (!string.IsNullOrEmpty(this.TableName)) { DataTable dt = DotNetService.Instance.ItemDetailsService.GetDataTable(UserInfo, "ItemsTablePermissionScope"); this.TableRealName = BaseBusinessLogic.GetProperty(dt, BaseItemDetailsEntity.FieldItemCode, this.TableName, BaseItemDetailsEntity.FieldItemName); this.Text = this.Text + " " + TableRealName; } }
/// <summary> /// 获取用户列表 /// 当用户非常多时,不需要显示角色 /// </summary> /// <param name="userInfo">用户</param> /// <param name="showRole">显示角色</param> /// <returns>数据表</returns> public DataTable GetDataTable(BaseUserInfo userInfo, bool showRole = true) { var result = new DataTable(BaseUserEntity.TableName); var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) => { // 这里是获取用户列表 var userManager = new BaseUserManager(dbHelper, userInfo); // 获取允许登录列表 List <KeyValuePair <string, object> > parameters = new List <KeyValuePair <string, object> >(); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldDeletionStateCode, 0)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldEnabled, 1)); parameters.Add(new KeyValuePair <string, object>(BaseUserEntity.FieldIsVisible, 1)); result = userManager.GetDataTable(parameters, BaseUserEntity.FieldSortCode); // 是否显示角色信息 if (showRole) { // 这里是获取角色列表 string tableName = userInfo.SystemCode + "Role"; var roleManager = new BaseRoleManager(dbHelper, userInfo, tableName); DataTable dataTableRole = roleManager.GetDataTable(); if (!result.Columns.Contains("RoleName")) { result.Columns.Add("RoleName"); } // 友善的显示属于多个角色的功能 string roleName = string.Empty; foreach (DataRow dr in result.Rows) { roleName = string.Empty; // 获取所在角色 string[] roleIds = userManager.GetRoleIds(dr[BaseUserEntity.FieldId].ToString()); if (roleIds != null) { for (int i = 0; i < roleIds.Length; i++) { roleName = roleName + BaseBusinessLogic.GetProperty(dataTableRole, roleIds[i], BaseRoleEntity.FieldRealName) + " "; } } // 设置角色的名称 if (!string.IsNullOrEmpty(roleName)) { dr["RoleName"] = roleName; } } result.AcceptChanges(); } result.TableName = BaseUserEntity.TableName; }); return(result); }
/// <summary> /// 按组织机构获取角色列表 /// </summary> /// <param name="userInfo">用户</param> /// <param name="organizeId">组织机构主键</param> /// <param name="showUser">显示用户</param> /// <returns>数据表</returns> public DataTable GetDataTableByOrganize(BaseUserInfo userInfo, string organizeId, bool showUser = true) { var dt = new DataTable(BaseRoleEntity.TableName); var parameter = ServiceInfo.Create(userInfo, MethodBase.GetCurrentMethod()); ServiceUtil.ProcessUserCenterReadDb(userInfo, parameter, (dbHelper) => { string tableName = userInfo.SystemCode + "Role"; // 获得角色列表 var manager = new BaseRoleManager(dbHelper, userInfo, tableName); dt = manager.GetDataTableByOrganize(organizeId); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo, tableName); if (showUser) { DataTable dataTableUser = userManager.GetDataTable(); if (!dt.Columns.Contains("Users")) { dt.Columns.Add("Users"); } // 友善的显示属于多个角色的功能 string userName = string.Empty; foreach (DataRow dr in dt.Rows) { userName = string.Empty; // 获取所在用户 string[] userIds = userManager.GetUserIdsInRoleId(userInfo.SystemCode, dr[BaseRoleEntity.FieldId].ToString()); if (userIds != null) { for (int i = 0; i < userIds.Length; i++) { userName = userName + BaseBusinessLogic.GetProperty(dataTableUser, userIds[i], BaseUserEntity.FieldRealName) + ", "; } } if (!string.IsNullOrEmpty(userName)) { userName = userName.Substring(0, userName.Length - 2); // 设置用户的名称 dr["Users"] = userName; } } dt.AcceptChanges(); } dt.TableName = BaseRoleEntity.TableName; }); return(dt); }
private void AddApplictionsMenuItem(ToolStripMenuItem mitmAppliction) { // 判断是否已经加载过菜单了 if (mitmAppliction.Tag != null) { return; } ToolStripMenuItem mitm = null; string moduleCode = string.Empty; string id = BaseBusinessLogic.GetProperty(ClientCache.Instance.DTMoule, BaseModuleEntity.FieldCode, "Appliction", BaseModuleEntity.FieldId); if (string.IsNullOrEmpty(id)) { return; } // 从所有的系统菜单里进行循环 foreach (DataRow dataRow in ClientCache.Instance.DTMoule.Select(BaseModuleEntity.FieldParentId + "=" + id.ToString(), BaseModuleEntity.FieldSortCode)) { // 判断有些特殊的处理,跳过 moduleCode = dataRow[BaseModuleEntity.FieldCode].ToString(); if (string.IsNullOrEmpty(moduleCode) || moduleCode.Equals("FrmBusinessCardAdmin") || moduleCode.Equals("FrmCodeGenerator")) { continue; } // 是否显示的,是否有权限的,才可以访问菜单 if (this.ModuleIsVisible(moduleCode) && this.IsModuleAuthorized(moduleCode)) { id = dataRow[BaseModuleEntity.FieldId].ToString(); mitm = new ToolStripMenuItem(dataRow[BaseModuleEntity.FieldFullName].ToString()); mitm.Name = "mitmUrl" + id; mitm.Tag = dataRow[BaseModuleEntity.FieldAssemblyName].ToString(); mitm.Click += mitm_Click; mitmAppliction.DropDownItems.Add(mitm); } } // 打上已经加载菜单的标志,提高程序效率不反复执行程序 mitmAppliction.Tag = "Url"; }
private void ColumnSelected(ComboBox cmbColumn, string selectedValue) { string columnCode = string.Empty; if (cmbColumn.SelectedValue != null) { columnCode = cmbColumn.SelectedValue.ToString(); } if (string.IsNullOrEmpty(columnCode)) { return; } string targetTable = BaseBusinessLogic.GetProperty(DTColumns, BaseTableColumnsEntity.FieldColumnCode, columnCode, BaseTableColumnsEntity.FieldTargetTable); // 2: 若是有目标表是空的。 // 2: 若是有目标表,那就需要把文本隐藏、下拉选项显示出来。 if (string.IsNullOrEmpty(targetTable)) { if (cmbColumn == this.cmbColumn0) { this.txtValue0.Visible = true; this.cmbValue0.Visible = false; } else if (cmbColumn == this.cmbColumn1) { this.txtValue1.Visible = true; this.cmbValue1.Visible = false; } else if (cmbColumn == this.cmbColumn2) { this.txtValue2.Visible = true; this.cmbValue2.Visible = false; } else if (cmbColumn == this.cmbColumn3) { this.txtValue3.Visible = true; this.cmbValue3.Visible = false; } else if (cmbColumn == this.cmbColumn4) { this.txtValue4.Visible = true; this.cmbValue4.Visible = false; } } else { // 这里获取绑定的数据,并且把控件的属性设置好 ComboBox targetColumn = null; if (cmbColumn == this.cmbColumn0) { this.txtValue0.Visible = false; this.cmbValue0.Visible = true; targetColumn = this.cmbValue0; } else if (cmbColumn == this.cmbColumn1) { this.txtValue1.Visible = false; this.cmbValue1.Visible = true; targetColumn = this.cmbValue1; } else if (cmbColumn == this.cmbColumn2) { this.txtValue2.Visible = false; this.cmbValue2.Visible = true; targetColumn = this.cmbValue2; } else if (cmbColumn == this.cmbColumn3) { this.txtValue3.Visible = false; this.cmbValue3.Visible = true; targetColumn = this.cmbValue3; } else if (cmbColumn == this.cmbColumn4) { this.txtValue4.Visible = false; this.cmbValue4.Visible = true; targetColumn = this.cmbValue4; } // 3: 需要读取数据,绑定到下拉框上。 // 绑定条件数据,这里先按简单的处理,直接指向下拉框选项表 DataTable dataTable = DotNetService.Instance.ItemDetailsService.GetDataTable(UserInfo, targetTable); DataRow dataRow = dataTable.NewRow(); dataTable.Rows.InsertAt(dataRow, 0); targetColumn.DisplayMember = BaseItemDetailsEntity.FieldItemName; targetColumn.ValueMember = BaseItemDetailsEntity.FieldItemValue; targetColumn.DataSource = dataTable.DefaultView; if (!string.IsNullOrEmpty(selectedValue)) { // 这里是设定默认值 SetColumValue(targetColumn, selectedValue); } } }
/// <summary> /// 获取子条件表达式 /// </summary> /// <param name="cmbColumn">字段</param> /// <param name="cmbCondition">条件</param> /// <param name="txtValue">值</param> /// <returns>条件限制</returns> private string GetSubConstraint(ComboBox cmbLeftBrackets, ComboBox cmbColumn, ComboBox cmbCondition, TextBox txtValue, ComboBox cmbValue, ComboBox cmbRightBrackets, ComboBox cmbAnd = null) { string subConstraint = string.Empty; if (cmbColumn.SelectedValue == null) { return(subConstraint); } string columnCode = cmbColumn.SelectedValue.ToString(); if (string.IsNullOrEmpty(columnCode)) { return(subConstraint); } string constraintValue = string.Empty; string dataType = BaseBusinessLogic.GetProperty(DTColumns, BaseTableColumnsEntity.FieldColumnCode, columnCode, BaseTableColumnsEntity.FieldDataType); if (string.IsNullOrEmpty(dataType)) { dataType = "string"; } if (txtValue.Visible) { if (cmbColumn.SelectedValue != null && (!string.IsNullOrEmpty(cmbColumn.SelectedValue.ToString())) && cmbCondition.SelectedValue != null && (!string.IsNullOrEmpty(cmbCondition.SelectedValue.ToString())) && (!string.IsNullOrEmpty(txtValue.Text))) { if (dataType.ToUpper() == "INT" || dataType.ToUpper() == "DOUBLE" || dataType.ToUpper() == "INTEGER") { constraintValue = txtValue.Text; } else { constraintValue = "\'" + txtValue.Text + "\'"; } } } if (cmbValue.Visible) { if (cmbColumn.SelectedValue != null && (!string.IsNullOrEmpty(cmbColumn.SelectedValue.ToString())) && cmbCondition.SelectedValue != null && (!string.IsNullOrEmpty(cmbCondition.SelectedValue.ToString())) && (!string.IsNullOrEmpty(cmbValue.SelectedValue.ToString()))) { // 如果是数值的、真假类型的?(将来有时间了改进) // subConstraint = cmbColumn.SelectedValue.ToString() + " " + cmbCondition.SelectedValue.ToString() + " " + cmbValue.SelectedValue.ToString(); // 如果是字符类型的,需要补充加单引号的 if (dataType.ToUpper() == "INT" || dataType.ToUpper() == "DOUBLE" || dataType.ToUpper() == "INTEGER") { constraintValue = cmbValue.SelectedValue.ToString(); } else { constraintValue = "\'" + cmbValue.SelectedValue.ToString() + "\'"; } } } string leftBrackets = ""; if (cmbLeftBrackets.SelectedItem != null) { leftBrackets = cmbLeftBrackets.SelectedItem.ToString(); } string rightBrackets = ""; if (cmbRightBrackets.SelectedItem != null) { rightBrackets = cmbRightBrackets.SelectedItem.ToString(); } string and = " and "; if (cmbAnd != null) { if (cmbAnd.SelectedItem != null) { and = " " + cmbAnd.SelectedItem.ToString() + " "; } } subConstraint = leftBrackets + cmbColumn.SelectedValue.ToString() + " " + cmbCondition.SelectedValue.ToString() + " " + constraintValue + rightBrackets + and; return(subConstraint); }