コード例 #1
0
        public void DeleteSYS_User(SYS_User sys_user)
        {
            DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            try
            {
                SYS_RoleOfUserDataAccess sysRoleOfUserDA = new SYS_RoleOfUserDataAccess();
                SYS_RoleOfUser           sysRoleOfUser   = new SYS_RoleOfUser();
                sysRoleOfUser.UserId = sys_user.ID;
                sysRoleOfUserDA.DeleteSYS_RoleOfUserByIDUser(sysRoleOfUser);

                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_ID, sys_user.ID, false));
                _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_User_Delete]", para.ToArray());
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #2
0
        public void UpdateSYS_UserAll(SYS_User sys_user)
        {
            DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();

                para.Add(_DbHelper.CreateParameter(FIELD_ID, sys_user.ID, false));
                para.Add(_DbHelper.CreateParameter(FIELD_USERNAME, sys_user.UserName, false));
                para.Add(_DbHelper.CreateParameter(FIELD_PASSWORD, sys_user.Password, false));
                para.Add(_DbHelper.CreateParameter(FIELD_FIRSTNAME, sys_user.FirstName, false));
                para.Add(_DbHelper.CreateParameter(FIELD_MIDNAME, sys_user.MidName, false));
                para.Add(_DbHelper.CreateParameter(FIELD_LASTNAME, sys_user.LastName, false));
                para.Add(_DbHelper.CreateParameter(FIELD_EMAIL, sys_user.Email, false));
                para.Add(_DbHelper.CreateParameter(FIELD_ISACTIVE, sys_user.IsActive, false));
                para.Add(_DbHelper.CreateParameter(FIELD_NUMBERPHONE, sys_user.NumberPhone, false));
                para.Add(_DbHelper.CreateParameter(FIELD_IDORGANIZATION, sys_user.IDOrganization, false));
                _DbHelper.ExecuteReader(conn, Common.DatabaseSchema + "[SYS_User_Update]", para.ToArray());
                SYS_RoleOfUserDataAccess sysRoleOfUserDataAccess = new SYS_RoleOfUserDataAccess();
                SYS_RoleOfUser           sysRoleOfUser           = new SYS_RoleOfUser();
                //SYS_RightOfUserDataAccess sysRightOfUserDataAccess = new SYS_RightOfUserDataAccess();
                SYS_RightOfUser sysRightOfUserID = new SYS_RightOfUser();
                sysRightOfUserID.UserId = sys_user.ID;
                sysRoleOfUser.UserId    = sys_user.ID;
                //sysRightOfUserDataAccess.DeleteSYS_RightOfUser; Xóa toàn bộ quyền của User đó
                //sysRightOfUserDataAccess.DeleteSYS_RightOfUserByIDUser(sysRightOfUserID);
                sysRoleOfUserDataAccess.DeleteSYS_RoleOfUserByIDUser(sysRoleOfUser);

                sysRoleOfUser.RoleId = sys_user.Roles.ID;
                sysRoleOfUserDataAccess.InsertSYS_RoleOfUser(sysRoleOfUser);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("SYS_UserDataAccess.UpdateAll: {0}", ex.Message));
            }
            finally
            {
                conn.Close();
            }
        }
コード例 #3
0
        public void UpdateSYS_UserAll(DM_USER dm_user)
        {
            DbConnection conn = _DbHelper.CreateConnection(Common.ConnectionString);

            conn.Open();
            try
            {
                List <DbParameter> para = new List <DbParameter>();
                para.Add(_DbHelper.CreateParameter(FIELD_IDUSER, dm_user.IDUSER, false));
                para.Add(_DbHelper.CreateParameter(FIELD_IDMA_DVIQLY, dm_user.IDMA_DVIQLY, false));
                para.Add(_DbHelper.CreateParameter(FIELD_XACNHAN, dm_user.XACNHAN, false));
                para.Add(_DbHelper.CreateParameter(FIELD_USERNAME, dm_user.USERNAME, false));
                para.Add(_DbHelper.CreateParameter(FIELD_HOTEN, dm_user.HOTEN, false));
                para.Add(_DbHelper.CreateParameter(FIELD_DIACHI, dm_user.DIACHI, false));
                para.Add(_DbHelper.CreateParameter(FIELD_SODT, dm_user.SODT, false));
                para.Add(_DbHelper.CreateParameter(FIELD_EMAIL, dm_user.EMAIL, false));
                para.Add(_DbHelper.CreateParameter(FIELD_NGAYSINH, dm_user.NGAYSINH, false));
                para.Add(_DbHelper.CreateParameter(FIELD_IS_ADMIN, dm_user.IS_ADMIN, false));
                para.Add(_DbHelper.CreateParameter(FIELD_CHUCDANH, dm_user.CHUCDANH, false));
                _DbHelper.ExecuteNonQuery(conn, Common.DatabaseSchema + "[DM_USER_Update]", para.ToArray());
                SYS_RoleOfUserDataAccess sysRoleOfUserDataAccess = new SYS_RoleOfUserDataAccess();
                SYS_RoleOfUser           sysRoleOfUser           = new SYS_RoleOfUser();
                SYS_RightOfUser          sysRightOfUserID        = new SYS_RightOfUser();
                sysRightOfUserID.UserId = dm_user.IDUSER;
                sysRoleOfUser.UserId    = dm_user.IDUSER;
                sysRoleOfUserDataAccess.DeleteSYS_RoleOfUserByIDUser(sysRoleOfUser);

                sysRoleOfUser.RoleId = dm_user.Roles.ID;
                sysRoleOfUserDataAccess.InsertSYS_RoleOfUser(sysRoleOfUser);
            }
            catch (Exception ex)
            {
                throw new Exception(String.Format("dm_user_Update.UpdateAll: {0}", ex.Message));
            }
            finally
            {
                conn.Close();
            }
        }