-
Notifications
You must be signed in to change notification settings - Fork 0
/
ImportManager.cs
688 lines (614 loc) · 32.5 KB
/
ImportManager.cs
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
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
using Denial_Coding.BAL.Generics;
using Denial_Coding.BAL.ViewModels;
using DC.DAL;
using Microsoft.Win32.SafeHandles;
using System;
using System.Collections.Generic;
using System.Data;
//using System.Data.Entity;
using System.Data.Entity.Validation;
using System.Data.SqlClient;
using System.Globalization;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
//using System.Threading.Tasks;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using System.Data.Entity;
using System.Data.Entity.SqlServer;
namespace Denial_Coding.BAL.Managers
{
public class ImportManager : IImportService
{
#region GetFullUploadData
public DataTable GetFullUploadData(int Practice_Id)
{
DataSet dsCommon = new DataSet();
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
try
{
var access_id = (from use in _context.tbl_USER_ACCESS where use.USER_NTLG == userName select new { use.ACCESS_ID }).Single();
int acc_id = Convert.ToInt32(access_id.ACCESS_ID.ToString());
HttpContext.Current.Session[Constants.AccessID] = acc_id;
if (acc_id == 1)
{
dsCommon.Clear();
SqlConnection conObj = new SqlConnection(Constants.ConnectionString);
conObj.Open();
SqlCommand cmdObj = new SqlCommand(Constants.SpUnsuccessImportDataAccess, conObj);
cmdObj.CommandType = CommandType.StoredProcedure;
cmdObj.Parameters.AddWithValue("@Project_Id", projectId);
cmdObj.Parameters.AddWithValue("@Practice_Id", Practice_Id);
cmdObj.Parameters.AddWithValue("@CODED_TO", userName);
SqlDataAdapter adapter1 = new SqlDataAdapter(cmdObj);
adapter1.Fill(dsCommon);
conObj.Close();
var tt = dsCommon;
}
else
{
dsCommon.Clear();
SqlConnection conObj = new SqlConnection(Constants.ConnectionString);
conObj.Open();
SqlCommand cmdObj = new SqlCommand(Constants.SpUnsuccessImportData, conObj);
cmdObj.CommandType = CommandType.StoredProcedure;
cmdObj.Parameters.AddWithValue("@Project_Id", projectId);
cmdObj.Parameters.AddWithValue("@Practice_Id", Practice_Id);
cmdObj.Parameters.AddWithValue("@USER_NTLG", userName);
cmdObj.Parameters.AddWithValue("@access_id", acc_id);
SqlDataAdapter adapter1 = new SqlDataAdapter(cmdObj);
adapter1.Fill(dsCommon);
conObj.Close();
var tt = dsCommon;
}
}
catch (Exception e)
{
throw e;
}
return dsCommon.Tables[0];
}
}
#endregion
#region Get Practice Names
public List<SelectListItem> GetPracticeList()
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
//ImportModel model = new ImportModel();
string userName = System.Environment.UserName.ToString();
int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
var list = (from practice in _context.tbl_PRACTICE_MASTER
join project in _context.tbl_PROJECT_MASTER on practice.PROJECT_ID equals project.PROJECT_ID
where project.PROJECT_ID == Project_id
select new SelectListItem
{
Text = practice.PRACTICE,
Value = SqlFunctions.StringConvert((double)practice.PRACTICE_ID).Trim()
}).ToList();
return list;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region InsertExcelData
public ImportModel InsertExcelData(DataSet ds, string practiceId)
{
ImportModel model = new ImportModel();
try
{
if (ds.Tables[0].Rows.Count > 0)
{
model = uploadExcel(ds, practiceId);
ds.Clear();
ds = null;
}
}
catch (DbEntityValidationException ex)
{
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
var fullErrorMessage = string.Join(Constants.CommaSpace, errorMessages);
var exceptionMessage = string.Concat(ex.Message, Constants.ValidationError, fullErrorMessage);
throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
}
return model;
}
#endregion
#region uploadExcel
public ImportModel uploadExcel(DataSet ds,string practiceId)
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
int locationId = Convert.ToInt32(HttpContext.Current.Session[Constants.LocationId]);
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
int practiceid = Convert.ToInt32(practiceId);
ImportModel model = new ImportModel();
model.TotalExcelCount = ds.Tables[0].Rows.Count;
model.UnsuccessfullCount = 0;
model.SuccessfullCount = 0;
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
foreach (DataRow dr in ds.Tables[0].Rows)
{
StringBuilder builder = new StringBuilder();
string clientid = Convert.ToString(dr[Constants.CLIENTID]);
string accountname = Convert.ToString(dr[Constants.ACCOUNTNAME]);
DateTime? dos = null;
if (!string.IsNullOrEmpty(Convert.ToString(dr[Constants.DOS])))
{
//string dtofservice = Convert.ToString(dr[Constants.DOS]);
//dos = Convert.ToDateTime(dtofservice, System.Globalization.CultureInfo.GetCultureInfo("ur-PK").DateTimeFormat);
string dtofservice = Convert.ToString(dr[Constants.DOS]);
string[] parts = dtofservice.Split('/');
if (parts[0].Length < 2)
{
parts[0] = "0" + parts[0];
}
if (parts[1].Length < 2)
{
parts[1] = "0" + parts[1];
}
dtofservice = parts[1] + "/" + parts[0] + "/" + parts[2];
//string[] formats = {"MM/dd/yyyy" };
//string converted = DateTime.ParseExact(, formats, CultureInfo.InvariantCulture, DateTimeStyles.None).ToString("dd/MM/yyyy");
dos = Convert.ToDateTime(dtofservice, System.Globalization.CultureInfo.GetCultureInfo("ur-PK").DateTimeFormat);
}
string accountno = Convert.ToString(dr[Constants.ACCOUNTNO]);
DateTime ?denialworkeddate = null;
if (!string.IsNullOrEmpty(Convert.ToString(dr[Constants.DENIALWORKEDDT])))
{
//string denialdt = Convert.ToString(dr[Constants.DENIALWORKEDDT]);
//denialworkeddate = Convert.ToDateTime(denialdt, System.Globalization.CultureInfo.GetCultureInfo("ur-PK").DateTimeFormat);
string denialdt = Convert.ToString(dr[Constants.DENIALWORKEDDT]);
string[] parts = denialdt.Split('/');
if (parts[0].Length < 2)
{
parts[0] = "0" + parts[0];
}
if (parts[1].Length < 2)
{
parts[1] = "0" + parts[1];
}
denialdt = parts[1] + "/" + parts[0] + "/" + parts[2];
denialworkeddate = Convert.ToDateTime(denialdt, System.Globalization.CultureInfo.GetCultureInfo("ur-PK").DateTimeFormat);
}
string errorcategory = Convert.ToString(dr[Constants.ERRORCATEGORY]);
string subcategory = Convert.ToString(dr[Constants.SUBCATEGORY]);
string coderloginid = Convert.ToString(dr[Constants.CODERLOGINID]);
string qcloginid = Convert.ToString(dr[Constants.QCLOGINID]);
string denialtype = Convert.ToString(dr[Constants.DENIALTYPE]);
string comments = Convert.ToString(dr[Constants.COMMENTS]);
string auditorname = Convert.ToString(dr[Constants.AUDITOR_NAME]);
int empid = 0;
if (!string.IsNullOrEmpty(Convert.ToString(dr[Constants.EMPID])))
{
empid = Convert.ToInt32(dr[Constants.EMPID]);
}
string empname = Convert.ToString(dr[Constants.EMPNAME]);
//tbl_IMPORT_TABLE record = new tbl_IMPORT_TABLE();
//record.CLIENT_ID =Convert.ToInt32(clientid);
//record.ACCOUNT_NAME = accountname;
//record.DOS = Convert.ToDateTime(dos);
//record.ACCOUNT_NO = accountno;
//record.DENIAL_WORKED_DT = Convert.ToDateTime(denialworkeddate);
//record.ERROR_CATEGORY = errorcategory;
//record.SUB_CATEGORY_Error_Type = subcategory;
//record.CODER_LOGIN_ID = coderloginid;
//record.QC_LOGIN_ID = qcloginid;
//record.DENIAL_TYPE = denialtype;
//record.COMMENTS = comments;
//record.AUDITOR_NAME = auditorname;
//record.LOCATION_ID = locationId;
//record.PROJECT_ID = projectId;
//record.PRACTICE_ID = practiceid;
//if (!string.IsNullOrEmpty(empid.ToString()))
//{
// record.EMP_ID = Convert.ToInt32(empid);
//}
//else
//{
// record.EMP_ID = 0;
//}
//record.EMP_NAME = empname;
//record.ENTER_BY = userName;
//record.ENTER_DATE = Convert.ToDateTime(DateTime.Now.ToShortDateString());
//_context.tbl_IMPORT_TABLE.Add(record);
_context.USP_Enter_Import_Data_List(Convert.ToInt32(clientid), accountname, dos, accountno, denialworkeddate, errorcategory, subcategory, coderloginid, qcloginid, denialtype, comments, auditorname, empid, empname, locationId, projectId, practiceid, userName);
model.SuccessfullCount = model.SuccessfullCount + 1;
}
_context.SaveChanges();
}
return model;
}
#endregion
#region Get Client Names
public List<SelectListItem> GetClientList()
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
//ImportModel model = new ImportModel();
string userName = System.Environment.UserName.ToString();
int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
var list = (from client in _context.tbl_CLIENT_TABLE
//join project in _context.tbl_PROJECT_MASTER on practice.PROJECT_ID equals project.PROJECT_ID
//where project.PROJECT_ID == Project_id
select new SelectListItem
{
Text = SqlFunctions.StringConvert((double)client.Client_ID).Trim(),
Value = SqlFunctions.StringConvert((double)client.Client_ID).Trim()
}).Distinct().ToList();
return list;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
//#region Get Account Names
//public List<SelectListItem> GetAccountList()
//{
// try
// {
// using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
// {
// //ImportModel model = new ImportModel();
// string userName = System.Environment.UserName.ToString();
// int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
// var list = (from account in _context.tbl_ACCOUNT_TABLE
// //join project in _context.tbl_PROJECT_MASTER on practice.PROJECT_ID equals project.PROJECT_ID
// //where project.PROJECT_ID == Project_id
// select new SelectListItem
// {
// Text = account.Account_No.ToString(),
// Value = account.Account_No.ToString()
// }).Distinct().ToList();
// return list;
// }
// }
// catch (Exception ex)
// {
// throw ex;
// }
//}
//#endregion
#region Get ErrorCategory Names
public List<SelectListItem> GetErrorCategoryList(string denialtype)
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
//ImportModel model = new ImportModel();
string userName = System.Environment.UserName.ToString();
int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
var list = (from error in _context.tbl_ERROR_CAT_TABLE
//join project in _context.tbl_PROJECT_MASTER on practice.PROJECT_ID equals project.PROJECT_ID
where error.Error_Type == denialtype
select new SelectListItem
{
Text = error.Error_Category.ToString(),
Value = error.Error_Category.ToString()
}).Distinct().ToList();
return list;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region Get SubCategory Names
public List<SelectListItem> GetSubCategoryList(string errorId)
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
//ImportModel model = new ImportModel();
string userName = System.Environment.UserName.ToString();
int Project_id = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId].ToString());
var list = (from sub in _context.tbl_ERROR_CAT_TABLE
where sub.Error_Category == errorId
select new SelectListItem
{
Text = sub.Sub_Category.ToString(),
Value = sub.Sub_Category.ToString()
}).Distinct().ToList();
return list;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region ImportData
public ImportModel ImportData(ImportModel model)
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
int locationId = Convert.ToInt32(HttpContext.Current.Session[Constants.LocationId]);
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
int practiceid = Convert.ToInt32(model.SelectedPractice);
//model.TotalExcelCount = ds.Tables[0].Rows.Count;
//model.UnsuccessfullCount = 0;
//model.SuccessfullCount = 0;
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
string clientid = Convert.ToString(model.CLIENT_ID);
string accountname = Convert.ToString(model.ACCOUNT_NAME);
DateTime? dos = null;
if (!string.IsNullOrEmpty(Convert.ToString(model.DOS)))
{
string dtofservice = Convert.ToString(model.DOS);
string[] parts = dtofservice.Split('/');
if(parts[0].Length<2)
{
parts[0] = "0" + parts[0];
}
if(parts[1].Length<2)
{
parts[1] = "0" + parts[1];
}
dtofservice = parts[1] + "/" + parts[0] + "/" + parts[2];
//string[] formats = {"MM/dd/yyyy" };
//string converted = DateTime.ParseExact(, formats, CultureInfo.InvariantCulture, DateTimeStyles.None).ToString("dd/MM/yyyy");
dos = Convert.ToDateTime(dtofservice, System.Globalization.CultureInfo.GetCultureInfo("ur-PK").DateTimeFormat);
}
string accountno = Convert.ToString(model.ACCOUNT_NO);
DateTime? denialworkeddate = null;
if (!string.IsNullOrEmpty(Convert.ToString(model.DENIAL_WORKED_DT)))
{
string denialdt = Convert.ToString(model.DENIAL_WORKED_DT);
string[] parts = denialdt.Split('/');
if (parts[0].Length < 2)
{
parts[0] = "0" + parts[0];
}
if (parts[1].Length < 2)
{
parts[1] = "0" + parts[1];
}
denialdt = parts[1] + "/" + parts[0] + "/" + parts[2];
denialworkeddate = Convert.ToDateTime(denialdt, System.Globalization.CultureInfo.GetCultureInfo("ur-PK").DateTimeFormat);
}
string errorcategory = Convert.ToString(model.ERROR_CATEGORY);
string subcategory = Convert.ToString(model.SUB_CATEGORY_Error_Type);
string coderloginid = Convert.ToString(model.CODER_LOGIN_ID);
string qcloginid = Convert.ToString(model.QC_LOGIN_ID);
string denialtype = Convert.ToString(model.DENIAL_TYPE);
string comments = Convert.ToString(model.COMMENTS);
string auditorname = Convert.ToString(model.AUDITOR_NAME);
int empid = 0;
if (!string.IsNullOrEmpty(Convert.ToString(model.EMP_ID)))
{
empid = Convert.ToInt32(model.EMP_ID);
}
string empname = Convert.ToString(model.EMP_NAME);
_context.USP_Enter_Import_Data_List(Convert.ToInt32(clientid), accountname, dos, accountno, denialworkeddate, errorcategory, subcategory, coderloginid, qcloginid, denialtype, comments, auditorname, empid, empname, locationId, projectId, practiceid, userName);
var access_id = (from use in _context.tbl_USER_ACCESS where use.USER_NTLG == userName select new { use.ACCESS_ID }).Single();
int acc_id = Convert.ToInt32(access_id.ACCESS_ID.ToString());
if (acc_id == 1)
{
int imp_id = _context.tbl_IMPORT_TABLE.Max(p => p.IMPORT_ID);
_context.USP_Enter_Transaction_List(Convert.ToInt32(practiceid), Convert.ToInt32(imp_id), userName, userName);
int trans_id = _context.tbl_TRANSACTION.Max(p => p.TRANS_ID);
var _tr_details = _context.tbl_TRANSACTION_DETAILS.Where(x => x.TRANS_ID == trans_id).SingleOrDefault();
if (_tr_details != null)
{
_tr_details.CODED_STATUS = "Coding Completed";
_tr_details.CODING_COMPLETE_DATE = DateTime.Now;
}
}
_context.SaveChanges();
}
return model;
}
#endregion
#region ManageImportAccounts
public void ManageImportAccounts(List<ImportModel> model, string status)
{
if (status == Constants.Upload)
{
ReUploadAccounts(model);
}
else if (status == Constants.Delete)
{
DeleteUnsuccessfullRecords(model);
}
}
#endregion
#region ReUploadAccounts
public void ReUploadAccounts(List<ImportModel> model)
{
try
{
if (model.Count > 0)
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
foreach (var item in model)
{
int import_id = item.IMPORT_ID;
//var import = _context.tbl_IMPORT_TABLE.Where(x => x.IMPORT_ID == import_id && x.PROJECT_ID == projectId).FirstOrDefault();
var batch = _context.tbl_IMPORT_TABLE.Where(x => x.IMPORT_ID == item.IMPORT_ID).FirstOrDefault();
if (batch != null)
{
//batch.RECORD_STATUS = item.RECORD_STATUS;
string abc = model[0].SelectedHeader.ToString();
string header = abc.Replace(" ", "_");
header = header.Replace("#", "ID");
_context.USP_Update_Import_Data_List(header, model[0].SearchText, HttpContext.Current.Session[Constants.UserName].ToString(), import_id);
}
}
_context.SaveChanges();
}
}
}
catch (DbEntityValidationException ex)
{
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors)
.Select(x => x.ErrorMessage);
var fullErrorMessage = string.Join(Constants.CommaSpace, errorMessages);
var exceptionMessage = string.Concat(ex.Message, Constants.ValidationError, fullErrorMessage);
throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
}
}
#endregion
#region DeleteUnsuccessfullRecords
public void DeleteUnsuccessfullRecords(List<ImportModel> model)
{
try
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
foreach (var item in model)
{
if (item.IMPORT_ID != 0)
{
var batch = _context.tbl_IMPORT_TABLE.Where(x => x.IMPORT_ID == item.IMPORT_ID).FirstOrDefault();
_context.tbl_IMPORT_TABLE.Remove(batch);
// _context.SaveChanges();
}
}
_context.SaveChanges();
}
}
catch (DbEntityValidationException ex)
{
var errorMessages = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors)
.Select(x => x.ErrorMessage);
var fullErrorMessage = string.Join(Constants.CommaSpace, errorMessages);
var exceptionMessage = string.Concat(ex.Message, Constants.ValidationError, fullErrorMessage);
throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors);
}
}
#endregion
#region GetAccountName
public string GetAccountName(int CID)
{
DataSet dsCommon = new DataSet();
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
string account_name = "";
try
{
var acc_n = (from acc in _context.tbl_CLIENT_TABLE where acc.Client_ID == CID select new { acc.Clinet_Name }).Single();
account_name = acc_n.Clinet_Name.ToString();
}
catch (Exception e)
{
throw e;
}
return account_name;
}
}
#endregion
#region LoadEMPName
public string LoadEMPName(string CODER_LOGIN_ID)
{
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
int coder_emp_id = 0;
string coder_ntlg = "";
try
{
var acc_coder = (from coder in _context.tbl_CODER_EXCODE where coder.ExCode == CODER_LOGIN_ID.ToString().Trim() select new {coder.EmpID,coder.NTLG}).Single();
coder_emp_id = Convert.ToInt32(acc_coder.EmpID);
coder_ntlg = acc_coder.NTLG.ToString();
}
catch (Exception e)
{
//throw e;
}
return coder_emp_id.ToString() + " " + coder_ntlg;
}
}
#endregion
#region GetHeaderCount
public void GetHeaderCount()
{
DataSet dsCommon = new DataSet();
using (McKesson_GVLEntities _context = new McKesson_GVLEntities())
{
int projectId = Convert.ToInt32(HttpContext.Current.Session[Constants.ProjectId]);
int locationid = Convert.ToInt32(HttpContext.Current.Session[Constants.LocationId]);
string userName = HttpContext.Current.Session[Constants.UserName].ToString();
dsCommon.Clear();
SqlConnection conObj = new SqlConnection(Constants.ConnectionString);
//string[] coderlist = (from coder in _context.tbl_USER_ACCESS
// where coder.PROJECT_ID == projectId && (coder.ACCESS_ID == 2 || coder.ACCESS_ID == 1) && coder.LOCATION_ID == locationid && (coder.TL_NTLG == userName || coder.USER_NTLG == userName)
// && coder.LOCATION_ID == locationid
// select coder.USER_NTLG).ToArray();
//string idString = String.Join(",", coderlist);
var access_id = (from use in _context.tbl_USER_ACCESS where use.USER_NTLG == userName select new { use.ACCESS_ID }).Single();
int acc_id = Convert.ToInt32(access_id.ACCESS_ID.ToString());
HttpContext.Current.Session[Constants.AccessID] = acc_id;
conObj.Open();
SqlCommand cmdObj = new SqlCommand(Constants.HeadCount, conObj);
cmdObj.CommandType = CommandType.StoredProcedure;
cmdObj.Parameters.AddWithValue("@Project_Id", projectId);
cmdObj.Parameters.AddWithValue("@USER_NTLG", userName);
cmdObj.Parameters.AddWithValue("@access_id", acc_id);
SqlDataAdapter adapter1 = new SqlDataAdapter(cmdObj);
adapter1.Fill(dsCommon);
conObj.Close();
var tt = dsCommon;
}
if (dsCommon.Tables[0].Rows.Count>0)
{
if (Convert.ToInt32(HttpContext.Current.Session[Constants.AccessID]) == 2)
{
HttpContext.Current.Session["Fresh"] = null ;
HttpContext.Current.Session["Allotted"] = null;
HttpContext.Current.Session["Coded"] = null ;
HttpContext.Current.Session["Completed"] = null;
HttpContext.Current.Session["Fresh_Today"] = dsCommon.Tables[0].Rows[4][0].ToString();
HttpContext.Current.Session["Allotted_Today"] = dsCommon.Tables[0].Rows[5][0].ToString();
HttpContext.Current.Session["Coded_Today"] = dsCommon.Tables[0].Rows[6][0].ToString();
HttpContext.Current.Session["Completed_Today"] = dsCommon.Tables[0].Rows[7][0].ToString();
}
else if (Convert.ToInt32(HttpContext.Current.Session[Constants.AccessID]) == 3)
{
HttpContext.Current.Session["Fresh"] = dsCommon.Tables[0].Rows[0][0].ToString();
HttpContext.Current.Session["Allotted"] = dsCommon.Tables[0].Rows[1][0].ToString();
HttpContext.Current.Session["Coded"] = dsCommon.Tables[0].Rows[2][0].ToString();
HttpContext.Current.Session["Completed"] = dsCommon.Tables[0].Rows[3][0].ToString();
HttpContext.Current.Session["Fresh_Today"] = dsCommon.Tables[0].Rows[4][0].ToString();
HttpContext.Current.Session["Allotted_Today"] = dsCommon.Tables[0].Rows[5][0].ToString();
HttpContext.Current.Session["Coded_Today"] = dsCommon.Tables[0].Rows[6][0].ToString();
HttpContext.Current.Session["Completed_Today"] = dsCommon.Tables[0].Rows[7][0].ToString();
}
}
else
{
HttpContext.Current.Session["Fresh"] = null;
HttpContext.Current.Session["Allotted"] = null;
HttpContext.Current.Session["Coded"] = null;
HttpContext.Current.Session["Completed"] = null;
HttpContext.Current.Session["Fresh_Today"] = null;
HttpContext.Current.Session["Allotted_Today"] = null;
HttpContext.Current.Session["Coded_Today"] = null;
HttpContext.Current.Session["Completed_Today"] = null;
}
return;
}
#endregion
}
}