private void BindingOrganization() { IBridge_CommonService bridge = BridgeFactory.CreateCommonServiceBridge(); DataTable data = bridge.GetSystemOrganization(); DataBinder.BindingLookupEditDataSource(cmbOrg, data, "FNAME", "FNUMBER"); }
/// <summary> /// 创建保存用的临时数据 /// </summary> /// <param name="currentBusiness">业务数据(组,组的用户,组的权限,功能点的自定义名称)</param> /// <param name="lbAvailableUser"></param> /// <param name="lbSelectedUser"></param> /// <returns></returns> public DataSet CreateSaveData(DataSet currentBusiness, ListBox lbAvailableUser, ListBox lbSelectedUser) { DataSet save = new DataSet(); DataRowState state = currentBusiness.Tables[BusinessDataSetIndex.Groups].Rows[0].RowState; currentBusiness.Tables[BusinessDataSetIndex.Groups].AcceptChanges(); DataTable summary = currentBusiness.Tables[BusinessDataSetIndex.Groups].Copy(); if (state == DataRowState.Added) { summary.Rows[0].SetAdded(); _GroupID = Convert.ToInt32(BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_UserGroup.__TableName, tb_sys_UserGroup.__KeyName)); summary.Rows[0][tb_sys_UserGroup.__KeyName] = _GroupID; } else if (state == DataRowState.Modified) { _GroupID = Convert.ToInt32(summary.Rows[0][tb_sys_UserGroup.__KeyName]); summary.Rows[0].SetModified(); } DataTable auths = GetGroupAuthorityChanges(currentBusiness.Tables[BusinessDataSetIndex.GroupAuthorities]).Copy(); DataTable user = GetGroupUserChanges(currentBusiness, lbAvailableUser, lbSelectedUser); //DataTable tagNames = _FormTagCustomName.GetChanges(); save.Tables.Add(summary); //用户组 save.Tables.Add(user); //用户数据 save.Tables.Add(auths == null ? currentBusiness.Tables[BusinessDataSetIndex.GroupAuthorities].Clone() : auths); //权限数据 //save.Tables.Add(tagNames == null ? _FormTagCustomName.Clone() : tagNames); //功能点的自定义名称 return(save); }
/// <summary> /// 增加菜单权限 /// </summary> /// <param name="auths">权限表</param> /// <param name="node">当前处理的树结点</param> private void AddAuthority(DataTable auths, TreeNode node) { int actions = 0; int moduleID = 0; AuthNodeTag tag = node.Tag as AuthNodeTag; //取树结点的引用对象 //新增组权限记录 DataRow newrow = auths.NewRow(); if (_UGID == 0) { _UGID = Convert.ToInt32(BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_UG_Auth.__TableName, tb_sys_UG_Auth.__KeyName)); } newrow[tb_sys_UG_Auth.FID] = _UGID.ToString(); _UGID++; newrow[tb_sys_UG_Auth.FUGID] = _GroupID; string sFun = tag.DataRow == null?tag.FUnctionID.ToString() : tag.DataRow[tb_sys_UG_Auth.FunctionID].ToString(); newrow[tb_sys_UG_Auth.FunctionID] = sFun == "" ? "0" : sFun; //tag.DataRow == null ? tag.FUnctionID : tag.DataRow[tb_sys_UG_Auth.FunctionID]; newrow[tb_sys_UG_Auth.FMenu] = tag.AuthID; if (tag.MenuItem.Tag != null && tag.MenuItem.Tag is MenuItemTag) { //取当前处理的树结点所有权限值加总 actions = this.GetActions(node); moduleID = (tag.MenuItem.Tag as MenuItemTag).ModuleID;//模块编号 } newrow[tb_sys_UG_Auth.FModelID] = moduleID; newrow[tb_sys_UG_Auth.FAuths] = actions; //newrow[TUserRole.Authorities] = actions; //newrow[TUserRole.ModuleID] = moduleID; auths.Rows.Add(newrow); }
private void BindingDataSet(string sOrgID) { IBridge_CommonService bridge = BridgeFactory.CreateCommonServiceBridge(); DataTable data = bridge.GetSystemDataSetByOrg(sOrgID); DataBinder.BindingLookupEditDataSource(cmbDataset, data, "FNAME", "FNUMBER"); }
/// <summary> /// 更新按钮 /// </summary> /// <param name="item"></param> private void UpdateButton(BarItem item, string sFunid) { string filter = string.Format(tb_sys_Fun_MenuBar.FNumber + "='{0}' and " + tb_sys_Fun_MenuBar.FFunctionID + "={1}", item.Name, sFunid); DataRow[] exists = _AuthorityItem.Select(filter); if (exists.Length > 0) { string caption = ConvertEx.ToString(exists[0][tb_sys_Fun_MenuBar.FName]); if (caption != item.Caption) { _ButtonUpdated += 1; exists[0][tb_sys_Fun_MenuBar.FName] = item.Caption; //更新菜单标题. } } else { DataRow append = _AuthorityItem.NewRow();; append[tb_sys_Fun_MenuBar.FID] = Convert.ToInt32(BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_Fun_MenuBar.__TableName, tb_sys_Fun_MenuBar.__KeyName)) + _ButtonInserted; append[tb_sys_Fun_MenuBar.FNumber] = item.Name; append[tb_sys_Fun_MenuBar.FName] = item.Caption; append[tb_sys_Fun_MenuBar.FFunctionID] = sFunid; append[tb_sys_Fun_MenuBar.FAuthority] = _MaxAuthorID; _MaxAuthorID = _MaxAuthorID * 2; _AuthorityItem.Rows.Add(append); _ButtonInserted += 1; } }
/// <summary> /// 更新菜单标题 /// </summary> /// <param name="item"></param> private void UpdateMenu(ToolStripItem item) { MenuItemTag tag = item.Tag as MenuItemTag; string filter = string.Format("FNumber='{0}' and FModelID={1}", item.Name, tag.ModuleID); DataRow[] exists = _SummaryTable.Select(filter); if (exists.Length > 0) { string caption = ConvertEx.ToString(exists[0][tb_sys_Function.FName]); if (caption != item.Text) { _LastUpdated += 1; exists[0][tb_sys_Function.FName] = item.Text; //更新菜单标题. } } else { DataRow append = _SummaryTable.NewRow(); append[tb_sys_Function.FID] = Convert.ToInt32(BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_Function.__TableName, tb_sys_Function.__KeyName)) + _LastInserted; append[tb_sys_Function.FAuths] = tag.FormAuthorities; append[tb_sys_Function.FName] = item.Text; append[tb_sys_Function.FNumber] = item.Name; append[tb_sys_Function.FMenuType] = tag.MenuType.ToString(); append[tb_sys_Function.FModelID] = tag.ModuleID; _SummaryTable.Rows.Add(append); _LastInserted += 1; } }
/// <summary> /// 获取窗体的功能ID /// </summary> /// <param name="sMenu"></param> /// <returns></returns> public static string GetFunctionID(string sMenu) { string sRet = BridgeFactory.CreateCommonServiceBridge().GetTableFieldValue(tb_sys_Function.__TableName, tb_sys_Function.__KeyName, " And " + tb_sys_Function.FNumber + "='" + sMenu + "'"); if (sRet == string.Empty) { sRet = "0"; } return(sRet); }
private void BindingDataSet() { //DataTable data = CommonData.GetSystemDataSet(); //DataBinder.BindingLookupEditDataSource(txtDataset, data, "DataSetName", "DataSetID"); //txtDataset.EditValue = _user.DataSetID; IBridge_CommonService bridge = BridgeFactory.CreateCommonServiceBridge(); DataTable data = bridge.GetSystemDataSet(); DataBinder.BindingLookupEditDataSource(txtDataset, data, "FNAME", "FNUMBER"); txtDataset.EditValue = _user.DataSetID; }
public bool LoginByCard(LoginUser loginUser) { string userPrincipalName = DomainLdapTools.GetCurrentUserPrincipalName(); if (string.IsNullOrEmpty(userPrincipalName)) { throw new CustomException("获取本地域用户资料失败!"); } _User.Text = userPrincipalName; //显示当前Domain帐号 _User.Update(); loginUser.Account = userPrincipalName; IBridge_User bridge = BridgeFactory.CreateUserBridge(); //调用数据访问层的接口检查用户登录 DataTable dt = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.W.ToString())); if (dt.Rows.Count == 0) { throw new CustomException("域用户'" + userPrincipalName + "'没有建立权限关联!"); } DataRow row = dt.Rows[0]; Loginer user = new Loginer(); user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]); user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]); user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]); user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]); user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]); user.LoginTime = DateTime.Now; user.MachineName = GetComputerinfo.GetHostName(); user.IPAddress = GetComputerinfo.GetIP(); user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]); user.DbType = loginUser.DbType; user.DataSetName = loginUser.DataSetDBName; Loginer.CurrentUser = user;//保存当前用户 //登录日志 IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP("0", "0", "登录系统", ""); //下载用户权限 SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user); return(true); }
public bool LoginByCard(LoginUser loginUser) { string novellAccount = NovellLdapTools.NovellWhoAmI(); //获取当前Novell用户及组. 通过groups获取用户权限数据 //string[] groups = NovellLdapTools.NovellGetGroups(ref novellAccount); if (string.IsNullOrEmpty(novellAccount)) { throw new CustomException("获取Novell本地用户登录资料失败!"); } _User.Text = novellAccount; //显示当前Novell帐号 _User.Update(); loginUser.Account = novellAccount; IBridge_User bridge = BridgeFactory.CreateUserBridge(); //调用数据访问层的接口检查用户登录 DataTable dt = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.N.ToString())); if (dt.Rows.Count == 0) { throw new CustomException("Novell用户'" + novellAccount + "'没有建立权限关联!"); } DataRow row = dt.Rows[0]; Loginer user = new Loginer(); user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]); user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]); user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]); user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]); user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]); user.LoginTime = DateTime.Now; user.MachineName = GetComputerinfo.GetHostName(); user.IPAddress = GetComputerinfo.GetIP(); user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]); user.DbType = loginUser.DbType; user.DataSetName = loginUser.DataSetDBName; Loginer.CurrentUser = user;//保存当前用户 IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP("0", "0", "登录系统", ""); SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user);//下载用户权限 return(true); }
/// <summary> /// 生成用于保存的临时数据,获取已选择的用户数据, /// </summary> /// <param name="currentBusiness">权限业务数据</param> /// <param name="lbAvailableUser">所有用户选择列表</param> /// <param name="lbSelectedUser">已选择的用户列表</param> /// <returns></returns> private DataTable GetGroupUserChanges(DataSet currentBusiness, ListBox lbAvailableUser, ListBox lbSelectedUser) { DataTable AvaliableUser = currentBusiness.Tables[BusinessDataSetIndex.GroupAvailableUser].Copy(); //当前组可选用户 DataTable SelectedUser = currentBusiness.Tables[BusinessDataSetIndex.GroupUsers].Copy(); //当前组已选用户 //检查已删除的用户 foreach (ItemObject item in lbAvailableUser.Items) { DataRow row = (item as ItemObject).Value as DataRow; if (row.Table.TableName.ToUpper() != AvaliableUser.TableName.ToUpper()) { DataRow[] rows = SelectedUser.Select(string.Format("FAccount='{0}'", row[tb_sys_User.FAccount])); if (rows.Length > 0) { rows[0].Delete(); //删除组的用户 } } } //检查新增的用户 foreach (ItemObject item in lbSelectedUser.Items) { DataRow row = (item as ItemObject).Value as DataRow; if (row.Table.TableName.ToUpper() != SelectedUser.TableName.ToUpper()) { DataRow newrow = SelectedUser.NewRow(); if (_UGID == 0) { _UGID = Convert.ToInt32(BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_User_Group.__TableName, tb_sys_User_Group.__KeyName)); } newrow[tb_sys_User_Group.FID] = _UGID.ToString(); _UGID++; newrow[tb_sys_User_Group.FUserGroupID] = _GroupID; newrow[tb_sys_User_Group.FUserID] = row[tb_sys_User.FID]; SelectedUser.Rows.Add(newrow);//增加用户 } } DataTable ret = SelectedUser.GetChanges(); return(ret == null?SelectedUser.Clone() : ret); }
public override void DoSave(IButtonInfo sender) { try { UpdateLastControl(); //保存數據前如修改了原始數據,必需復製數據用于保存. _DataProxy.DataBinder.AcceptChanges(); DataTable forSave = _DataProxy.DataBinder.Copy(); if (!ValidatingData(forSave.Rows[0])) { return; } //新增用户时可设置密码,修改状态不支持改密码。 if (UpdateType.Add == _UpdateType) { forSave.Rows[0][tb_sys_User.FPassword] = CEncoder.Encode(txtPassword2.Text); //可以选择MD5加密 forSave.Rows[0][tb_sys_User.FID] = BridgeFactory.CreateCommonServiceBridge().GetTableID(tb_sys_User.__TableName, tb_sys_User.__KeyName); } bool ret = _DataProxy.Update(forSave, _UpdateType); if (ret) { UpdateSummaryRow(forSave.Rows[0]); //刷新表格内的数据. _DataProxy.SummaryTable.AcceptChanges(); string sFdes = (_UpdateType == UpdateType.Add ? "新增" : "修改") + "用户" + forSave.Rows[0][tb_sys_User.FUserName] + "(" + forSave.Rows[0][tb_sys_User.FAccount] + ")"; bllComDataBaseTool.WriteLogOp(_FunctionID, "0", sFdes); base.DoSave(sender); Msg.ShowInformation("保存成功!"); } else { Msg.Warning("保存失败!"); } } catch (Exception ex) { Msg.ShowException(ex); } }
public bool LoginByCard(LoginUser loginUser) { //调用数据访问层的接口检查用户登录 //用户登录前尚未创建Loginer对象,所有传null值 IBridge_User bridge = BridgeFactory.CreateUserBridge(); DataTable data = bridge.LoginByCard(loginUser, Char.Parse(LoginUserType.S.ToString())); if (data.Rows.Count == 0) { throw new CustomException("登录失败,请检查卡号!"); } DataRow row = data.Rows[0]; //用户实例,登录成功 Loginer user = new Loginer(); user.Account = ConvertEx.ToString(row[tb_sys_User.FAccount]); user.AccountName = ConvertEx.ToString(row[tb_sys_User.FUserName]); user.FlagAdmin = ConvertEx.ToString(row[tb_sys_User.FFlagAdmin]); user.Email = ConvertEx.ToString(row[tb_sys_User.FMail]); user.Fid = ConvertEx.ToString(row[tb_sys_User.FID]); user.LoginTime = DateTime.Now; user.MachineName = GetComputerinfo.GetHostName(); user.IPAddress = GetComputerinfo.GetIP(); user.CardNo = ConvertEx.ToString(row[tb_sys_User.FCardNo]); //参数:dataSet: 帐套编号, 从帐套字典表获取DBName,DataSetID,DataSetName三个字段的值 //给下面三个属性赋值 user.DBName = loginUser.DBName; //重要:在数据层根据DBName设置连接数据库 user.DataSetID = loginUser.DataSetID; user.DbType = loginUser.DbType; user.DataSetName = loginUser.DataSetDBName; Loginer.CurrentUser = user;//保存当前用户 IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP("0", "0", "登录系统", ""); SystemAuthentication.UserAuthorities = bridge.Getb_sys_UserAuthorities(user); //下载用户权限 return(true); }
/// <summary> /// 测试数据库连接 /// </summary> /// <param name="dbType"></param> /// <param name="Server"></param> /// <param name="database"></param> /// <param name="user"></param> /// <param name="password"></param> /// <returns></returns> public static bool TestConnection(string dbType, string Server, string database, string user, string password) { return(BridgeFactory.CreateCommonServiceBridge().TestConnection(dbType, Server, database, user, password)); }
/// <summary> /// 获取SQLServer服务器的数据库列表,用“,”分开 /// </summary> public static string GetSQLServerDbListString(string sServerName, string sUser, string sPwd) { return(BridgeFactory.CreateCommonServiceBridge().GetSQLServerDbListString(sServerName, sUser, sPwd)); }
/// <summary> /// 获取帐套 /// </summary> /// <returns></returns> public static DataTable GetSystemDataSet() { IBridge_CommonService bridge = BridgeFactory.CreateCommonServiceBridge(); return(bridge.GetSystemDataSet()); }
/// <summary> /// 返回表字段的值,根据条件SCon返回sTableName的字段sFieldID的值 /// </summary> /// <param name="sTableName"></param> /// <param name="sFieldID"></param> /// <returns></returns> public static string GetTableFieldValue(string sTableName, string sField, string SCon) { return(BridgeFactory.CreateCommonServiceBridge().GetTableFieldValue(sTableName, sField, " and " + SCon)); }
/// <summary> /// 写入操作日志,sFunID——功能ID,SubID——子功能ID,sFdesc——描述 /// </summary> public static void WriteLogOp(string sFunID, string sSubID, string sFdesc) { IBridge_CommonService comBridge = BridgeFactory.CreateCommonServiceBridge(); comBridge.WriteLogOP(sFunID, sSubID, sFdesc, ""); }
/// <summary> /// 获取表FID最大值,sTable——表名;sField——字段名 /// </summary> /// <param name="sTable"></param> /// <param name="sFiled"></param> /// <returns></returns> public static string GetTableID(string sTable, string sFiled) { return(BridgeFactory.CreateCommonServiceBridge().GetTableID(sTable, sFiled)); }
/// <summary> /// 通过SQL语句查询Datatable /// </summary> /// <param name="sql"></param> /// <returns></returns> public static DataTable GetDataTableSql(string sql) { return(BridgeFactory.CreateCommonServiceBridge().getDataTableSQL(sql)); }
/// <summary> /// 获取表的字段 /// </summary> /// <param name="stable"></param> /// <returns></returns> public static DataTable getField(string stable) { return(BridgeFactory.CreateCommonServiceBridge().getField(stable)); }
/// <summary> /// 获取系统业务表 /// </summary> /// <returns></returns> //public static DataTable GetBusinessTables() //{ // IBridge_CommonData bridge = BridgeFactory.CreateCommonDataBridge(); // return bridge.GetBusinessTables(); //} //public static string GetDataSN(string dataCode, bool asHeader) //{ // IBridge_CommonData bridge = BridgeFactory.CreateCommonDataBridge(); // return bridge.GetDataSN(dataCode, asHeader); //} /// <summary> /// 获取系统模块 /// </summary> /// <returns></returns> public static DataTable GetModules() { IBridge_CommonService bridge = BridgeFactory.CreateCommonServiceBridge(); return(bridge.GetModules()); }