/// <summary> /// 新增附加属性实例 /// </summary> /// <param name="guid">对象业务属性主键</param> /// <param name="arrayitem">附加属性实例值</param> /// <returns></returns> public bool Add_AppendPropertyInstance(string guid, string[] arrayitem) { int index = 0; string[] pkVal = arrayitem; StringBuilder[] sqls = new StringBuilder[pkVal.Length + 1]; object[] objs = new object[pkVal.Length + 1]; StringBuilder sbDelete = new StringBuilder(); sbDelete.Append("Delete From Base_AppendPropertyInstance Where PropertyInstance_Key =@PropertyInstance_Key"); SqlParam[] parm = new SqlParam[] { new SqlParam("@PropertyInstance_Key", guid) }; sqls[0] = sbDelete; objs[0] = parm; index = 1; foreach (var item in pkVal) { if (item.Length > 0) { string[] str_item = item.Split('|'); StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_AppendPropertyInstance("); sbadd.Append("PropertyInstance_ID,Property_Control_ID,PropertyInstance_Value,PropertyInstance_Key"); sbadd.Append(")Values("); sbadd.Append("@PropertyInstance_ID,@Property_Control_ID,@PropertyInstance_Value,@PropertyInstance_Key)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@PropertyInstance_ID", CommonHelper.GetGuid), new SqlParam("@Property_Control_ID", str_item[0]), new SqlParam("@PropertyInstance_Value", str_item[1]), new SqlParam("@PropertyInstance_Key", guid)}; sqls[index] = sbadd; objs[index] = parmAdd; index++; } } return DataFactory.SqlDataBase().BatchExecuteBySql(sqls, objs) >= 0 ? true : false; }
/// <summary> /// 新增用户组成员 /// </summary> /// <param name="User_ID">员工主键</param> /// <param name="UserGroup_ID">用户组主键</param> /// <returns></returns> public bool AddUserGroupMenber(string[] User_ID, string UserGroup_ID) { try { StringBuilder[] sqls = new StringBuilder[User_ID.Length]; object[] objs = new object[User_ID.Length]; int index = 0; foreach (string item in User_ID) { if (item.Length > 0) { StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_UserInfoUserGroup("); sbadd.Append("UserInfoUserGroup_ID,User_ID,UserGroup_ID,CreateUserId,CreateUserName"); sbadd.Append(")Values("); sbadd.Append("@UserInfoUserGroup_ID,@User_ID,@UserGroup_ID,@CreateUserId,@CreateUserName)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@UserInfoUserGroup_ID", CommonHelper.GetGuid), new SqlParam("@User_ID", item), new SqlParam("@UserGroup_ID", UserGroup_ID), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName)}; sqls[index] = sbadd; objs[index] = parmAdd; index++; } } return DataFactory.SqlDataBase().BatchExecuteBySql(sqls, objs) >= 0 ? true : false; } catch { return false; } }
/// <summary> /// 用户组配权限 /// </summary> /// <param name="pkVal">选择权限主键</param> /// <param name="UserGroup_ID">用户组主键</param> /// <returns></returns> public bool Add_UserGroupAllotAuthority(string[] pkVal, string UserGroup_ID) { try { StringBuilder[] sqls = new StringBuilder[pkVal.Length + 1]; object[] objs = new object[pkVal.Length + 1]; int index = 0; StringBuilder sbDelete = new StringBuilder(); sbDelete.Append("Delete From Base_UserGroupRight Where UserGroup_ID =@UserGroup_ID"); SqlParam[] parm = new SqlParam[] { new SqlParam("@UserGroup_ID", UserGroup_ID) }; sqls[0] = sbDelete; objs[0] = parm; index = 1; foreach (string item in pkVal) { if (item.Length > 0) { StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_UserGroupRight("); sbadd.Append("UserGroupRight_ID,UserGroup_ID,Menu_Id,CreateUserId,CreateUserName"); sbadd.Append(")Values("); sbadd.Append("@UserGroupRight_ID,@UserGroup_ID,@Menu_Id,@CreateUserId,@CreateUserName)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@UserGroupRight_ID", CommonHelper.GetGuid), new SqlParam("@UserGroup_ID", UserGroup_ID), new SqlParam("@Menu_Id", item), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName)}; sqls[index] = sbadd; objs[index] = parmAdd; index++; } } return DataFactory.SqlDataBase().BatchExecuteBySql(sqls, objs) >= 0 ? true : false; } catch { return false; } }
/// <summary> /// 数据放入回收站 /// </summary> /// <param name="module">业务模块</param> /// <param name="tableName">表名</param> /// <param name="pkName">字段主键</param> /// <param name="pkVal">字段值</param> /// <returns></returns> public int Virtualdelete(string module, string tableName, string pkName, string[] pkVal) { int num = 0; try { StringBuilder[] sqls = new StringBuilder[pkVal.Length * 2]; object[] objs = new object[pkVal.Length * 2]; int index = 0; foreach (string item in pkVal) { StringBuilder sbEdit = new StringBuilder(); sbEdit.Append(" Update "); sbEdit.Append(tableName); sbEdit.Append(" Set DeleteMark = 0"); sbEdit.Append(" Where ").Append(pkName).Append("=").Append("@ID"); SqlParam[] parmEdit = new SqlParam[] { new SqlParam("@ID", item) }; sqls[index] = sbEdit; objs[index] = parmEdit; index++; StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_Recyclebin("); sbadd.Append("Recyclebin_ID,"); sbadd.Append("Recyclebin_Name,"); sbadd.Append("Recyclebin_Database,"); sbadd.Append("Recyclebin_Table,CreateUserId,CreateUserName,"); sbadd.Append("Recyclebin_FieldKey,Recyclebin_EventField)Values("); sbadd.Append("@Recyclebin_ID,"); sbadd.Append("@Recyclebin_Name,"); sbadd.Append("@Recyclebin_Database,"); sbadd.Append("@Recyclebin_Table,@CreateUserId,@CreateUserName,"); sbadd.Append("@Recyclebin_FieldKey,@Recyclebin_EventField)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@Recyclebin_ID", CommonHelper.GetGuid), new SqlParam("@Recyclebin_Name", module), new SqlParam("@Recyclebin_Database", "RM_DB"), new SqlParam("@Recyclebin_Table", tableName), new SqlParam("@Recyclebin_FieldKey", pkName), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName), new SqlParam("@Recyclebin_EventField", item)}; sqls[index] = sbadd; objs[index] = parmAdd; index++; } num = DataFactory.SqlDataBase().BatchExecuteBySql(sqls, objs); } catch { return num; } return num; }
/// <summary> /// 还原回收站数据 /// </summary> /// <param name="pkVal">字段值</param> /// <returns></returns> public int Recyclebin_Restore(string[] pkVal) { int num = 0; try { string tableName; string pkName; StringBuilder[] sqls = new StringBuilder[pkVal.Length * 2]; object[] objs = new object[pkVal.Length * 2]; int index = 0; foreach (string item in pkVal) { Hashtable ht = DataFactory.SqlDataBase().GetHashtableById("Base_Recyclebin", "Recyclebin_ID", item); if (ht.Count > 0 && ht != null) { tableName = ht["RECYCLEBIN_TABLE"].ToString(); pkName = ht["RECYCLEBIN_FIELDKEY"].ToString(); StringBuilder sbEdit = new StringBuilder(); sbEdit.Append(" Update "); sbEdit.Append(tableName); sbEdit.Append(" Set DeleteMark = 1"); sbEdit.Append(" Where ").Append(pkName).Append("=").Append("@ID"); SqlParam[] parmEdit = new SqlParam[] { new SqlParam("@ID", ht["RECYCLEBIN_EVENTFIELD"].ToString()) }; sqls[index] = sbEdit; objs[index] = parmEdit; index++; StringBuilder sbDelete = new StringBuilder(); sbDelete.Append("Delete From Base_Recyclebin Where Recyclebin_ID =@Recyclebin_ID"); SqlParam[] parmDelete = new SqlParam[] { new SqlParam("@Recyclebin_ID", item) }; sqls[index] = sbDelete; objs[index] = parmDelete; } index++; } num = DataFactory.SqlDataBase().BatchExecuteBySql(sqls, objs); } catch { return num; } return num; }
/// <summary> /// 根据菜单主键获取已有按钮 /// </summary> /// <returns></returns> public DataTable GetSysMenuByButton(string Menu_Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("SELECT * FROM Base_SysMenu "); strSql.Append("WHERE ParentId =@Menu_Id "); strSql.Append("AND DELETEMARK = 1 AND Menu_Type = 3 ORDER BY SORTCODE ASC"); SqlParam[] parm = new SqlParam[] { new SqlParam("@Menu_Id", Menu_Id) }; return DataFactory.SqlDataBase().GetDataTableBySQL(strSql, parm); }
/// <summary> /// 批量新增所属,部门,角色,工作组,用户权限 /// </summary> /// <param name="item_value">对象主键</param> /// <param name="user_id">用户主键</param> /// <returns></returns> public bool add_ItemForm(string[] item_value, string user_id) { try { int index = 0; string key; string type; StringBuilder[] sqls = new StringBuilder[item_value.Length + 4]; object[] objs = new object[item_value.Length + 4]; StringBuilder sbDelete_org = new StringBuilder(); sbDelete_org.Append("Delete From Base_StaffOrganize Where User_ID =@User_ID"); SqlParam[] parm_org = new SqlParam[] { new SqlParam("@User_ID", user_id) }; sqls[0] = sbDelete_org; objs[0] = parm_org; StringBuilder sbDelete_Role = new StringBuilder(); sbDelete_Role.Append("Delete From Base_UserRole Where User_ID =@User_ID"); SqlParam[] parm_Role = new SqlParam[] { new SqlParam("@User_ID", user_id) }; sqls[1] = sbDelete_Role; objs[1] = parm_Role; StringBuilder sbDelete_UserGroup = new StringBuilder(); sbDelete_UserGroup.Append("Delete From Base_UserInfoUserGroup Where User_ID =@User_ID"); SqlParam[] parm_UserGroup = new SqlParam[] { new SqlParam("@User_ID", user_id) }; sqls[2] = sbDelete_UserGroup; objs[2] = parm_UserGroup; StringBuilder sbDelete_Right = new StringBuilder(); sbDelete_Right.Append("Delete From Base_UserRight Where User_ID =@User_ID"); SqlParam[] parm_Right = new SqlParam[] { new SqlParam("@User_ID", user_id) }; sqls[3] = sbDelete_Right; objs[3] = parm_Right; index = 4; foreach (var item in item_value) { if (item.Length > 0) { string[] str_item = item.Split('|'); key = str_item[0]; type = str_item[1]; if (type == "所属部门") { StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_StaffOrganize("); sbadd.Append("StaffOrganize_Id,Organization_ID,User_ID,CreateUserId,CreateUserName"); sbadd.Append(")Values("); sbadd.Append("@StaffOrganize_Id,@Organization_ID,@User_ID,@CreateUserId,@CreateUserName)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@StaffOrganize_Id", CommonHelper.GetGuid), new SqlParam("@Organization_ID", key), new SqlParam("@User_ID", user_id), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName)}; sqls[index] = sbadd; objs[index] = parmAdd; } else if (type == "所属角色") { StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_UserRole("); sbadd.Append("UserRole_ID,User_ID,Roles_ID,CreateUserId,CreateUserName"); sbadd.Append(")Values("); sbadd.Append("@UserRole_ID,@User_ID,@Roles_ID,@CreateUserId,@CreateUserName)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@UserRole_ID", CommonHelper.GetGuid), new SqlParam("@User_ID",user_id), new SqlParam("@Roles_ID", key), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName)}; sqls[index] = sbadd; objs[index] = parmAdd; } else if (type == "用户工作组") { StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_UserInfoUserGroup("); sbadd.Append("UserInfoUserGroup_ID,User_ID,UserGroup_ID,CreateUserId,CreateUserName"); sbadd.Append(")Values("); sbadd.Append("@UserInfoUserGroup_ID,@User_ID,@UserGroup_ID,@CreateUserId,@CreateUserName)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@UserInfoUserGroup_ID", CommonHelper.GetGuid), new SqlParam("@User_ID",user_id), new SqlParam("@UserGroup_ID", key), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName)}; sqls[index] = sbadd; objs[index] = parmAdd; } else if (type == "用户权限") { StringBuilder sbadd = new StringBuilder(); sbadd.Append("Insert into Base_UserRight("); sbadd.Append("UserRight_ID,User_ID,Menu_Id,CreateUserId,CreateUserName"); sbadd.Append(")Values("); sbadd.Append("@UserRight_ID,@User_ID,@Menu_Id,@CreateUserId,@CreateUserName)"); SqlParam[] parmAdd = new SqlParam[] { new SqlParam("@UserRight_ID", CommonHelper.GetGuid), new SqlParam("@User_ID",user_id), new SqlParam("@Menu_Id", key), new SqlParam("@CreateUserId", RequestSession.GetSessionUser().UserId), new SqlParam("@CreateUserName", RequestSession.GetSessionUser().UserName)}; sqls[index] = sbadd; objs[index] = parmAdd; } index++; } } return DataFactory.SqlDataBase().BatchExecuteBySql(sqls, objs) >= 0 ? true : false; } catch { return false; } }