| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 | 
							- BemsWebApplication.Building = function(params, viewInfo) {
 
-     "use strict";
 
-     var BuildingInfo = ko.observableArray();
 
-     var isEmptyData = true;;
 
-     var CmBuilidngDataSource = BemsWebApplication.db.createDataSource('CmBuilding');
 
-     var RowName;
 
-     var viewModel = BWA.DataGrid.createViewWithDataGrid(params, viewInfo, 'CmBuilding', {
 
-         columns: [
 
-             { dataField: 'BuildingId', caption: $G('number'), width: '20%', alignment: 'center' , sortOrder: 'desc' },
 
-             { dataField: 'Name', caption: $G('buildingName'), width: '80%', alignment: 'center' },
 
-             //utils.datagrid.columnIsUse( '20%' )
 
-         ],
 
-         popupWidth: 480,
 
-         searchViewItems: [{ id: 'Name' }],
 
-         handleViewShown: function() {
 
-         },
 
-         handleDataGridRowClick: function (id, dataGrid, clickRow, popupVisible) {
 
-             var data = clickRow.data;
 
-             RowName = data.Name;
 
-             popupVisible(true);
 
-         },
 
-         handleViewShowing: function () {
 
-             CmBuilidngDataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()]
 
-             ]);
 
-             CmBuilidngDataSource.load().done(function (CmBuilidng) {
 
-                 if (CmBuilidng.length == 0) {
 
-                     isEmptyData = true;
 
-                     $("#popupInsertButton").dxCommand("instance").option('disabled', false);
 
-                 }
 
-                 else {
 
-                     isEmptyData = false;
 
-                     $("#popupInsertButton").dxCommand("instance").option('disabled', true);
 
-                 }
 
-             });
 
-         },
 
-         // 이름 중복 방지
 
-         handlePopupShowing: function () {
 
-             CmBuilidngDataSource.filter([
 
-                 ["SiteId", "=", BWA.UserInfo.SiteId()]
 
-             ]);
 
-             CmBuilidngDataSource.load().done(function (result) {
 
-                 BuildingInfo(result);
 
-             });
 
-         },
 
-         beforeInsertingDataViewModel: function (dataModel, dbModelId) {
 
-             var dfd = $.Deferred();
 
-             var isDuplicated = false;
 
-             for (var i = 0; i < BuildingInfo().length; i++) {
 
-                 if (dataModel.Name() == BuildingInfo()[i].Name()) {
 
-                     isDuplicated = true;
 
-                 }
 
-             }
 
-             if (!BWA.DataUtil.isValidInputValue(dataModel.Name()))
 
-                 return dfd.resolve(false, '저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)');
 
-             else {
 
-                 if (isDuplicated)
 
-                     return dfd.resolve(false, '이미 동일 이름이 존재합니다.');
 
-                 else
 
-                     return dfd.resolve(true);
 
-             }
 
-         },
 
-         beforeUpdateDataViewModel: function () {
 
-             var isDuplicated = false;
 
-             for (var i = 0; i < BuildingInfo().length; i++) {
 
-                 if (viewModel.dataModel.Name() == BuildingInfo()[i].Name() && RowName() != BuildingInfo()[i].Name()) {
 
-                     isDuplicated = true;
 
-                 }
 
-             }
 
-             if (!BWA.DataUtil.isValidInputValue(viewModel.dataModel.Name())) {
 
-                 utils.toast.show('저장 혹은 수정 반드시 필수 입력 정보를 모두 입력하셔야 합니다 (앞뒤공백 허용안함)', 'error');
 
-                 return 0;
 
-             }
 
-             else {
 
-                 if (isDuplicated) {
 
-                     utils.toast.show('이미 동일 이름이 존재합니다.', 'error');
 
-                     return 0;
 
-                 }
 
-                 else
 
-                     return 2;
 
-             }
 
-         }
 
-     });
 
-     function InsertButtonClickAction() {
 
-         if (!isEmptyData) {
 
-             utils.toast.show('빌딩 명칭은 하나만 생성할 수 있습니다.', 'error');
 
-         }
 
-         else {
 
-             viewModel.popupInsertView();
 
-         }
 
-     }
 
-     viewModel.popupInsertButtonOptions = {
 
-         icon: 'add',
 
-         id: 'create',
 
-         title: '등록',
 
-         action: InsertButtonClickAction,
 
-         disabled: !isEmptyData
 
-     };
 
-     return viewModel;
 
- };
 
 
  |