users.component.ts
3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import { Component, OnInit, AfterViewInit,ViewChild } from '@angular/core';
import { UserService } from './user.service';
import { Router } from '@angular/router';
import { FormBuilder, FormGroup, Validators, FormControl } from '@angular/forms';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { User } from '../UserEntity/datamodel';
import { Http, Response } from '@angular/http';
//import { Global } from '../../Shared/global';
//import { DBOperation } from 'S';
import { Observable } from 'rxjs/Observable';
import { ConfirmService } from '../../Shared/Confirm/confirm.service';
import 'rxjs/Rx';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/filter';
@Component({
templateUrl:'./users.component.html' // '../../../../../wwwroot/html/UpdateProfile/updateuserprofile.component.html'
})
export class UsersList implements OnInit {
modalTitle: string;
Users: FormGroup;
alerts: string;
public UserTypeList: any;
public AccountTypeList: any;
public UserList: any;
error;
//@ViewChild("profileModal")
//profileModal: ModalComponent;
//errorMessage: any;
constructor(private userservice: UserService, private router: Router, private fb: FormBuilder, private http: Http,
private _confirmService: ConfirmService
) { }
ngOnInit(): void {
this.alerts = '';
//this.userservice.GetUserById(this.UserId);
this.Users = this.fb.group({
FirstName:[''],
LastName: [''],
EmailId: [''],
AccountNumber: [''],
UserTypeId: [''],
AccountTypeId:['']
// Gender: ['', Validators.required],
// Email: ['']
});
this.GetUserType();
this.GetAccountType();
//this.GetUserList();
}
redirect() {
this.router.navigate(['/']);
}
GetUserType() {
this.userservice.GetUserType().subscribe(x => { this.UserTypeList = x; }, error => this.error = <any>error);
}
GetAccountType() {
this.userservice.GetAccountType().subscribe(x => { this.AccountTypeList = x; }, error => this.error = <any>error);
}
GetUserList() {
//this.userservice.GetUserList().subscribe(x => { this.UserList = x; }, error => this.error = <any>error);
}
SearchUserList(this)
{
var UserFilterControl = this.Users.value;
this.userservice.GetUserList(
{
FirstName: this.Users.controls['FirstName'].value,
LastName: this.Users.controls['LastName'].value,
EmailId: this.Users.controls['EmailId'].value,
AccountNumber: this.Users.controls['AccountNumber'].value,
UserTypeId: (this.Users.controls['UserTypeId'].value != null && this.Users.controls['UserTypeId'].value !='' ? this.Users.controls['UserTypeId'].value:0),
AccountTypeId: (this.Users.controls['AccountTypeId'].value != null && this.Users.controls['AccountTypeId'].value != ''? this.Users.controls['AccountTypeId'].value : 0),
})
.subscribe(x => { this.UserList = x; }, error => this.error = <any>error);
}
AfterInsertData(data) {
if (data == "success") {
this._confirmService.activate("Userid Updated Successfully.", "alertMsg");
} else {
this.alerts += '<span>' + data+'</span>';
return false;
}
//if (this.closeflag) {
// this.close.emit(null);
//}
//else {
//}
}
ResetFormFields() {
//this.ChangeUserIdFrm.reset()
//this.ChangeUserIdFrm.controls['id'].setValue(this.user.Id)
//this.ChangeUserIdFrm.controls['loginid'].setValue(this.user.LoginId)
//this.ChangeUserIdFrm.controls['newloginid'].setValue('')
//this.ChangeUserIdFrm.controls['confirmloginid'].setValue('')
this.alerts = '';
}
}