managediscountcode.component.js
5.58 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
112
113
114
115
116
"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata = (this && this.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
Object.defineProperty(exports, "__esModule", { value: true });
var core_1 = require("@angular/core");
var managediscountcode_service_1 = require("./managediscountcode.service");
var router_1 = require("@angular/router");
var forms_1 = require("@angular/forms");
var datamodel_1 = require("../UserEntity/datamodel");
//import { Global } from '../../Shared/global';
//import { DBOperation } from 'S';
//import { Observable } from 'rxjs/Observable';
var ManageDiscountCode = /** @class */ (function () {
function ManageDiscountCode(manageDiscountCodeService, router, fb) {
this.manageDiscountCodeService = manageDiscountCodeService;
this.router = router;
this.fb = fb;
this.Mode = 'Manage';
this.divClass = '';
this.topPos = '2000px';
this.bsValue = new Date();
}
ManageDiscountCode.prototype.ngOnInit = function () {
this.divClass = 'col-sm-12';
this.discountCode = new datamodel_1.DiscountCode();
this.alerts = '';
this.manageDiscountCodeFrm = this.fb.group({
searchDiscountCode: [''],
searchStartDate: [''],
searchEndDate: [''],
discountCodes: this.fb.array([])
});
this.insertUpdateDiscountCodeFrm = this.fb.group({
discountId: [''],
discountCode: ['', forms_1.Validators.required],
startDate: ['', forms_1.Validators.required],
endDate: ['', forms_1.Validators.required],
percentage: ['', forms_1.Validators.required],
isActive: ['']
});
this.SearchDiscountCodes();
};
ManageDiscountCode.prototype.SearchDiscountCodes = function () {
var _this = this;
console.log(this.manageDiscountCodeFrm.controls['searchDiscountCode'].value + ', ' +
this.manageDiscountCodeFrm.controls['searchStartDate'].value + ', ' +
this.manageDiscountCodeFrm.controls['searchEndDate'].value);
this.manageDiscountCodeService.GetDiscountCodes({
discountCode: this.manageDiscountCodeFrm.controls['searchDiscountCode'].value,
startDate: this.manageDiscountCodeFrm.controls['searchStartDate'].value,
endDate: this.manageDiscountCodeFrm.controls['searchEndDate'].value
})
.subscribe(function (x) { _this.BindFormFields(x); }, function (error) { return _this.error = error; });
};
ManageDiscountCode.prototype.InsertUpdateDiscountCode = function () {
var _this = this;
console.log('InsertUpdateDiscountCode');
this.alerts = '';
if (this.alerts == '') {
var obj = this.insertUpdateDiscountCodeFrm.value;
return this.manageDiscountCodeService.InsertDiscountCode(obj)
.subscribe(function (n) { return (_this.AfterInsertData(n)); }, function (error) { return _this.error = error; });
}
};
ManageDiscountCode.prototype.AfterInsertData = function (data) {
if (data.Status == "false") {
this.alerts = "<span>Password change unsuccessfully</span>";
}
else {
this.alerts = "<span>Password changed successfully</span>";
}
};
ManageDiscountCode.prototype.BindFormFields = function (data) {
this.discountCodes = data;
this.manageDiscountCodeFrm.setControl('discountCodes', this.fb.array(this.discountCodes));
};
ManageDiscountCode.prototype.ResetFormFields = function () {
this.manageDiscountCodeFrm.reset();
//this.manageDiscountCodeFrm.controls['loginId'].setValue(this.user.LoginId);
//this.manageDiscountCodeFrm.controls['oldPassword'].setValue('');
//this.manageDiscountCodeFrm.controls['newPassword'].setValue('');
//this.manageDiscountCodeFrm.controls['confirmPassword'].setValue('');
this.alerts = '';
};
ManageDiscountCode.prototype.AddDiscountCode = function () {
this.Mode = 'Add';
this.topPos = '100px';
this.divClass = 'col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3';
};
ManageDiscountCode.prototype.EditDiscountCode = function () {
this.Mode = 'Edit';
this.topPos = '100px';
this.divClass = 'col-sm-10 col-sm-offset-1 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3';
};
ManageDiscountCode.prototype.CancelAddEdit = function () {
this.Mode = 'Manage';
this.topPos = '2000px';
this.divClass = 'col-sm-12';
};
ManageDiscountCode = __decorate([
core_1.Component({
templateUrl: './managediscountcode.component.html'
}),
__metadata("design:paramtypes", [managediscountcode_service_1.ManageDiscountCodeService, router_1.Router, forms_1.FormBuilder])
], ManageDiscountCode);
return ManageDiscountCode;
}());
exports.ManageDiscountCode = ManageDiscountCode;
//# sourceMappingURL=managediscountcode.component.js.map