프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / ConvertService / ServiceBase / Markus.Service.StationController / ViewModel / ConvertAddDialogViewModel.cs @ 95e7bd84

이력 | 보기 | 이력해설 | 다운로드 (5.74 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using Telerik.Windows.Controls;
7
using System.IO;
8
using Microsoft.Win32;
9
using Markus.Service.Extensions;
10
using System.Windows;
11
using System.Windows.Controls;
12
using System.ComponentModel;
13

    
14
namespace Markus.Service.StationController.ViewModel
15
{
16
    class ConvertAddDialogViewModel : Mvvm.ToolKit.ViewModelBase, IDataErrorInfo
17
    {
18
        #region Construrtor
19

    
20
        public ConvertAddDialogViewModel()
21
        {
22
            ConverAdd_OKCommand = new DelegateCommand(ConverAdd_OK);
23
        }
24

    
25
        #endregion
26

    
27
        #region IDataErrorInfo Members
28

    
29
        public string Error
30
        {
31
            get { throw new NotImplementedException(); }
32
        }
33

    
34
        public string this[string columnName]
35
        {
36
            get
37
            {
38
                string result = null;
39
                if (string.IsNullOrEmpty(ConverAdd_Project_NO))
40
                {
41
                    if (string.IsNullOrEmpty(ConverAdd_Project_NO))
42
                        result = "Please enter a Project NO";
43
                }
44
                if (columnName == "ConverAdd_DOCUMENT_ID")
45
                {
46
                    if (string.IsNullOrEmpty(ConverAdd_DOCUMENT_ID))
47
                        result = "Please enter a DOCUMENT ID";
48
                }
49
                if (columnName == "ConverAdd_DOCUMENT_URL")
50
                {
51
                    if (string.IsNullOrEmpty(ConverAdd_DOCUMENT_URL))
52
                        result = "Please enter a DOCUMENT URL";
53
                }
54
                return result;
55
            }
56
        }
57

    
58
        #endregion
59

    
60
        #region Propertise
61

    
62
        DataService.DataServiceClient WcfClient = new DataService.DataServiceClient();
63

    
64
        private string _ConverAdd_Project_NO;
65
        public string ConverAdd_Project_NO
66
        {
67
            get { return _ConverAdd_Project_NO; }
68
            set
69
            {
70
                if (_ConverAdd_Project_NO != value)
71
                {
72
                    _ConverAdd_Project_NO = value;
73
                    OnPropertyChanged(() => ConverAdd_Project_NO);
74
                }
75
            }
76
        }
77

    
78
        private string _ConverAdd_DOCUMENT_ID;
79
        public string ConverAdd_DOCUMENT_ID
80
        {
81
            get { return _ConverAdd_DOCUMENT_ID; }
82
            set
83
            {
84
                if (_ConverAdd_DOCUMENT_ID != value)
85
                {
86
                    _ConverAdd_DOCUMENT_ID = value;
87
                    OnPropertyChanged(() => ConverAdd_DOCUMENT_ID);
88
                }
89
            }
90
        }
91

    
92
        private string _ConverAdd_DOCUMENT_URL;
93
        public string ConverAdd_DOCUMENT_URL
94
        {
95
            get { return _ConverAdd_DOCUMENT_URL; }
96
            set
97
            {
98
                if (_ConverAdd_DOCUMENT_URL != value)
99
                {
100
                    _ConverAdd_DOCUMENT_URL = value;
101
                    OnPropertyChanged(() => ConverAdd_DOCUMENT_URL);
102
                }
103
            }
104
        }
105

    
106
        private bool _Bool_Project_NO;
107
        public bool Bool_Project_NO
108
        {
109
            get { return _Bool_Project_NO; }
110
            set
111
            {
112
                _Bool_Project_NO = value;
113
                OnPropertyChanged(() => Bool_Project_NO);
114

    
115
            }
116
        }
117

    
118
        private bool _Bool_DOCUMENT_ID;
119
        public bool Bool_DOCUMENT_ID
120
        {
121
            get { return _Bool_DOCUMENT_ID; }
122
            set
123
            {
124
                _Bool_DOCUMENT_ID = value;
125
                OnPropertyChanged(() => Bool_DOCUMENT_ID);
126
            }
127
        }
128

    
129
        #endregion
130

    
131
        #region Command
132

    
133
        public DelegateCommand ConverAdd_OKCommand { get; private set; }
134

    
135
        #endregion
136

    
137
        #region Fuction
138

    
139
        #region ConverAdd_OK
140
        /// <summary>
141
        /// 그리드 상단 Conver 추가 버튼
142
        /// ProjectNo, DocumentURL, DocumentID, 입력해서 저장 프로시저에서 추가 
143
        /// </summary>
144
        public async void ConverAdd_OK(object obj)
145
        {
146
            if (String.IsNullOrEmpty(ConverAdd_Project_NO) || String.IsNullOrEmpty(ConverAdd_DOCUMENT_URL)|| String.IsNullOrEmpty(ConverAdd_DOCUMENT_ID) )
147
            {
148
                if (String.IsNullOrEmpty(ConverAdd_Project_NO))
149
                {
150
                    ConverAdd_Project_NO = "Project_NOisEmpty";
151
                }
152
                if (String.IsNullOrEmpty(ConverAdd_DOCUMENT_URL))
153
                {
154
                    ConverAdd_DOCUMENT_URL = "DOCUMENT_URLisEmpty";
155
                }
156
                if (String.IsNullOrEmpty(ConverAdd_DOCUMENT_ID))
157
                {
158
                    ConverAdd_DOCUMENT_ID = "DOCUMENT_IDisEmpty";
159
                }
160
            }
161
            else
162
            {
163
                try
164
                {
165
                    string ConverAdd_ID = GuidExtension.shortGuid();
166
                    var items = await WcfClient.GET_SELECT_CONVERT_INSERTAsync(ConverAdd_ID, ConverAdd_Project_NO, ConverAdd_DOCUMENT_URL, ConverAdd_DOCUMENT_ID);
167
                    System.Diagnostics.Debug.WriteLine(items);
168

    
169
                    MessageBox.Show("데이터베이스에 추가 완료! ");
170
                }
171
                catch (Exception ex)
172
                {
173
                    MessageBox.Show(ex.ToString());
174
                }
175

    
176
                ConverAdd_Project_NO = null;
177
                ConverAdd_DOCUMENT_ID = null;
178
                ConverAdd_DOCUMENT_URL = null;
179
            }
180
        }
181

    
182
        #endregion
183

    
184
        #endregion
185
    }
186
    public class NameValidator : ValidationRule
187
    {
188
        public override ValidationResult Validate(object value, System.Globalization.CultureInfo cultureInfo)
189
        {
190
            if (value == null)
191
                return new ValidationResult(false, "value cannot be empty.");
192

    
193
            return ValidationResult.ValidResult;
194
        }
195
    }
196
}
클립보드 이미지 추가 (최대 크기: 500 MB)