CB2-20200827ONU\Administrator
2021-09-22 4d584101e46ff34b2694e88af706b9b2e92364bc
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL;
using CY.Model;
using CY.Infrastructure.Query;
using CY.Infrastructure.Common;
using CY.BLL.Sys;
using CY.Model.Inquiry;
using CY.SQLDAL;
using System.Data.SqlClient;
using CY.Infrastructure.Logging;
 
namespace CY.WebForm.Pages.business
{
    public partial class CorporateClientsVisit : BasePage
    {
        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = null;
        Sys_DictionaryBLL bll_Sys_DictionaryBLL = null;//字典业务逻辑操作类对象
        SysInquiry_PrintingTypeBLL bll_SysInquiry_PrintingTypeBLL = null;//印刷业务类型业务逻辑操作类对象
        /// <summary>
        /// 是否需要节假日维护
        /// </summary>
        public bool IsNeedJiejiaRi { get; set; }
        /// <summary>
        /// 是否需要维护
        /// </summary>
        public bool NeedWeihu { get; set; }
 
        /// <summary>
        /// 合作客户例子
        /// </summary>
        public OA_CorporateClients client { get; set; }
        //初始化
        public CorporateClientsVisit()
        {
            bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
            bll_Sys_DictionaryBLL = new Sys_DictionaryBLL();
            bll_SysInquiry_PrintingTypeBLL = new SysInquiry_PrintingTypeBLL();
        }
        /// <summary>
        /// 是否时维护提醒传过来的
        /// </summary>
        public bool IsWeihuTixingUrl { get; set; } = false;
        //页面加载
        protected void Page_Load(object sender, EventArgs e)
        {
 
            if (Request["Keyid"] != null || Request["MemberId"] != null)
            {
                OA_CorporateClients m_OA_CorporateClients = bll_OA_CorporateClientsBLL.GetModelDetail(Request["Keyid"].ToGuid2());
                this.spanCompanyName.InnerText = m_OA_CorporateClients.CompanyName;
                this.spanBusinessManagerId.InnerText = m_OA_CorporateClients.BusinessmanagerName;
                this.spanprintdate.InnerText = DateTime.Now.ToString("yyyy-MM-dd");
                client = bll_OA_CorporateClientsBLL.GetModel(Request["Keyid"].ToGuid2());
                IsNeedJiejiaRi = client.JieJiaRiWiHu==true;
                NeedWeihu = client.NeedWiHu == true;
                this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Request["Keyid"].ToGuid2());
 
                this.RepClientList.DataBind();
                if (IsNeedJiejiaRi)
                    this.btn_Submit.Enabled = true;
                else
                    this.btn_Submit.Enabled = false;
 
 
                //判决是否是节假日维护弹窗 这个弹窗添加维护记录后会关闭窗口
                var x = Request["JIeriCount"];
                if (x != "undefined"&&x!=null)
                {
                    this.Button1.Enabled = false;
                    this.txtvisitRemark.Value = x;
                }
 
                this.txtVisitTime.Value = DateTime.Now.ToString("yyyy-MM-dd");
                //判决是否是提醒弹窗  这个弹窗添加维护记录后会关闭窗口
                var y = Request["tixingweihu"];
                if ( y != null&& y=="1")
                {
                    IsWeihuTixingUrl = true;
                }
 
 
            }
 
 
        }
        //完结事件
        protected void btn_Submit_Visit(object sender, EventArgs e)
        {
            OA_CorporateClientsVisit m_OA_CorporateClientsVisit = new OA_CorporateClientsVisit();
 
          
            try
            {
                Guid Keyid = Request["Keyid"].ToGuid2();
 
 
 
 
                if (Request["Keyid"] != null)
                {
 
 
                }
                else
                {
                    JavaScript.MessageBox("请先保存客户", this);
                }
 
                if (this.txtVisitTime.Value == "")
                {
                    JavaScript.MessageBox("请选择日期", this);
 
                }
                if (this.txtVisitTime.Value == "")
                {
                    JavaScript.MessageBox("请填写维护记录", this);
 
                }
 
                m_OA_CorporateClientsVisit.Keyid = Guid.NewGuid();
 
 
                m_OA_CorporateClientsVisit.CorporateClientsid = Keyid;
 
                m_OA_CorporateClientsVisit.VisitTime = this.txtVisitTime.Value.ToDateTime2();
 
                m_OA_CorporateClientsVisit.Remark = this.txtvisitRemark.Value.ToString2();
                m_OA_CorporateClientsVisit.Creater = CurrentUser.TrueMemberId;
                m_OA_CorporateClientsVisit.CreateTime = DateTime.Now;
                m_OA_CorporateClientsVisit.Updater = CurrentUser.TrueMemberId;
                m_OA_CorporateClientsVisit.LastUpdateTime = DateTime.Now;
 
 
                #region 添加或编辑
 
 
                bool result = bll_OA_CorporateClientsBLL.InsertModelVisit(m_OA_CorporateClientsVisit);//更新信息
 
                if (result)
                {
                    //this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Keyid);
                    //this.RepClientList.DataBind();
                    this.txtVisitTime.Value = "";
                    this.txtvisitRemark.Value = "";
                    JavaScript.MessageBox("维护保存成功", this, false, false);
                    if (NeedWeihu)
                    {
 
                        Database DC = new Database();
                        string sqlStr = string.Format("USE [ECTEST]  UPDATE[dbo].[OA_CorporateClients] SET [NeedWiHu] = 'false' where Keyid='{0}'", Request["Keyid"]);
 
                        try
                        {
                            SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection);
                            //SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
                            int a = myCmd.ExecuteNonQuery();
                            //myDa.Dispose();                  
 
 
                        }
                        catch (Exception ee)
                        {
                            new Log4NetAdapter().Log("中秋节提醒错误 错误:" + ee.Message);
                            this.txtVisitTime.Value = "";
                            this.txtvisitRemark.Value = "";
                            JavaScript.MessageBox("清除维护标志失败", this, false, false);
 
                        }
                        finally
                        {
                            if (DC.Connection.State != System.Data.ConnectionState.Closed)
                                DC.Connection.Close();
                        }
 
 
                       
                    }
 
 
 
                }
 
                else
                    JavaScript.MessageBox("维护保存失败", this);
                this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Request["Keyid"].ToGuid2());
                this.RepClientList.DataBind();
                //Province = CurrentUser.Province;
                //City = CurrentUser.City;
                //County = CurrentUser.County;
                //BindData();
                if (IsWeihuTixingUrl)
                    JavaScript.RefreshDIVOpener(this);
                #endregion
 
 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
                if (IsWeihuTixingUrl)
                    JavaScript.RefreshDIVOpener(this);
            }
        }
 
        protected void btn_Submit_Visit_jiari(object sender, EventArgs e)
        {
 
           
            OA_CorporateClientsVisit m_OA_CorporateClientsVisit = new OA_CorporateClientsVisit();
 
 
            try
            {
                Guid Keyid = Request["Keyid"].ToGuid2();
 
 
 
 
                if (Request["Keyid"] != null)
                {
 
 
                }
                else
                {
                    JavaScript.MessageBox("请先保存客户", this);
                }
 
                if (this.txtVisitTime.Value == "")
                {
                    JavaScript.MessageBox("请选择日期", this);
 
                }
                if (this.txtVisitTime.Value == "")
                {
                    JavaScript.MessageBox("请填写维护记录", this);
 
                }
 
                m_OA_CorporateClientsVisit.Keyid = Guid.NewGuid();
 
 
                m_OA_CorporateClientsVisit.CorporateClientsid = Keyid;
 
                m_OA_CorporateClientsVisit.VisitTime = this.txtVisitTime.Value.ToDateTime2();
 
                m_OA_CorporateClientsVisit.Remark = this.txtvisitRemark.Value.ToString2();
                m_OA_CorporateClientsVisit.Creater = CurrentUser.TrueMemberId;
                m_OA_CorporateClientsVisit.CreateTime = DateTime.Now;
                m_OA_CorporateClientsVisit.Updater = CurrentUser.TrueMemberId;
                m_OA_CorporateClientsVisit.LastUpdateTime = DateTime.Now;
 
 
                #region 添加或编辑
 
 
                bool result = bll_OA_CorporateClientsBLL.InsertModelVisit(m_OA_CorporateClientsVisit);//更新信息
 
                if (result)
                {
                    //this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Keyid);
                    //this.RepClientList.DataBind();
                    this.txtVisitTime.Value = "";
                    this.txtvisitRemark.Value = "";
                    JavaScript.MessageBox("维护保存成功", this, false, false);
                    if (IsNeedJiejiaRi)
                    {
 
                        Database DC = new Database();
                      
                        string sqlStr = string.Format("USE [ECTEST]  UPDATE[dbo].[OA_CorporateClients] SET [JieJiaRiWiHu] = 'false' where Keyid='{0}'", Request["Keyid"]);
 
                        try
                        {
                            SqlCommand myCmd = new SqlCommand(sqlStr, DC.Connection);
                            //SqlDataAdapter myDa = new SqlDataAdapter(myCmd);
                            int a = myCmd.ExecuteNonQuery();
                            //myDa.Dispose();                  
 
 
                        }
                        catch (Exception ee)
                        {
                            new Log4NetAdapter().Log("节假日清除标志 错误:" + ee.Message);
                            this.txtVisitTime.Value = "";
                            this.txtvisitRemark.Value = "";
                            JavaScript.MessageBox("清除维护标志失败", this, false, false);
 
                        }
                        finally
                        {
                            if (DC.Connection.State != System.Data.ConnectionState.Closed)
                                DC.Connection.Close();
                        }
 
 
 
                    }
 
 
 
                }
 
                else
                    JavaScript.MessageBox("维护保存失败", this);
                this.RepClientList.DataSource = bll_OA_CorporateClientsBLL.SelectVisitListByCorId(Request["Keyid"].ToGuid2());
                this.RepClientList.DataBind();
                JavaScript.MessageBox("维护完成", this);
                //Province = CurrentUser.Province;
                //City = CurrentUser.City;
                //County = CurrentUser.County;
                //BindData();
                
              if(IsWeihuTixingUrl)
                JavaScript.RefreshDIVOpener(this);
                #endregion
 
 
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                JavaScript.MessageBox("操作失败", this);
                if (IsWeihuTixingUrl)
                    JavaScript.RefreshDIVOpener(this);
            }
        }
    }
}