-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin_master_effluent_otherunit_lst.aspx.cs
178 lines (165 loc) · 6.72 KB
/
admin_master_effluent_otherunit_lst.aspx.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
using sysExtension;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Script.Services;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class admin_master_effluent_otherunit_lst : System.Web.UI.Page
{
private void SetBodyEventOnLoad(string myFunc)
{
((_MP_Front)this.Master).SetBodyEventOnLoad(myFunc);
}
protected void Page_Load(object sender, EventArgs e)
{
if (UserAcc.UserExpired())
{
SetBodyEventOnLoad(SystemFunction.PopupLogin());
}
else
{
if (!IsPostBack)
{
SystemFunction.BindDropdownPageSize(ddlPageSize, null);
}
}
}
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public static TRetunrLoadData LoadData(CSearch itemSearch)
{
TRetunrLoadData result = new TRetunrLoadData();
if (!UserAcc.UserExpired())
{
PTTGC_EPIEntities db = new PTTGC_EPIEntities();
List<TDataTable> lstData = new List<TDataTable>();
string sCon = "";
string sSearch = itemSearch.sSearch.Trims().ToLower();
string sStatus = itemSearch.sStatus.Trims().ToLower();
if (!string.IsNullOrEmpty(sSearch))
{
sCon += @" AND sName LIKE '%" + sSearch + "%' ";
}
if (!string.IsNullOrEmpty(sStatus))
{
sCon += @" AND (LOWER(cActive) = '" + sStatus + @"') ";
}
var TB_Effluent_Product = db.TEffluent_OtherProduct_Point.ToList(); //IsUse
string _SQL = @" select nUnitID
,sName
,CASE WHEN cActive = 'Y' THEN 'Active' ELSE 'Inactive' END as sStatus
,dUpdate
from TM_Effluent_Unit
where cDel = 'N' " + sCon + @"
ORDER BY dUpdate DESC";
DataTable dt = CommonFunction.Get_Data(SystemFunction.strConnect, _SQL);
lstData = CommonFunction.ConvertDatableToList<TDataTable>(dt).ToList();
foreach (var item in lstData)
{
item.sUpdate = item.dUpdate.DateString();
item.sLink = "<a class='btn btn-warning' href='admin_master_effluent_otherunit_update.aspx?str=" + HttpContext.Current.Server.UrlEncode(STCrypt.Encrypt(item.nUnitID.ToString())) + "'><i class='fa fa-edit'></i> Edit</a>";
item.nIsUse = TB_Effluent_Product.Any(a => a.nUnitID == item.nUnitID) ? TB_Effluent_Product.Where(a => a.nUnitID == item.nUnitID).Count() : 0;
}
#region//SORT
int? nSortCol = SystemFunction.GetIntNull(itemSearch.sIndexCol);
switch ((itemSearch.sOrderBy + "").ToLower())
{
case SystemFunction.ASC:
{
switch (nSortCol)
{
case 1: lstData = lstData.OrderBy(o => o.sName).ToList(); break;
case 2: lstData = lstData.OrderBy(o => o.sStatus).ToList(); break;
case 3: lstData = lstData.OrderBy(o => o.sUpdate).ToList(); break;
}
}
break;
case SystemFunction.DESC:
{
switch (nSortCol)
{
case 1: lstData = lstData.OrderByDescending(o => o.sName).ToList(); break;
case 2: lstData = lstData.OrderByDescending(o => o.sStatus).ToList(); break;
case 3: lstData = lstData.OrderByDescending(o => o.sUpdate).ToList(); break;
}
}
break;
}
#endregion
#region//Final Action >> Skip Take Data For Javasacript
sysGlobalClass.Pagination dataPage = new sysGlobalClass.Pagination();
dataPage = SystemFunction.GetPaginationSmall(SystemFunction.GetIntNullToZero(itemSearch.sPageSize), SystemFunction.GetIntNullToZero(itemSearch.sPageIndex), lstData.Count);
lstData = lstData.Skip(dataPage.nSkipData).Take(dataPage.nTakeData).ToList();
var lstDataFac = db.mTFacility.Where(w => w.cDel == "N").ToList();
result.lstData = lstData;
result.nPageCount = dataPage.nPageCount;
result.nPageIndex = dataPage.nPageIndex;
result.sPageInfo = dataPage.sPageInfo;
result.sContentPageIndex = dataPage.sContentPageIndex;
result.nStartItemIndex = dataPage.nStartItemIndex;
#endregion
}
else
{
result.Status = SystemFunction.process_SessionExpired;
}
return result;
}
[WebMethod]
[ScriptMethod(UseHttpGet = false, ResponseFormat = ResponseFormat.Json)]
public static sysGlobalClass.CResutlWebMethod DeleteData(string[] arrValue)
{
sysGlobalClass.CResutlWebMethod result = new sysGlobalClass.CResutlWebMethod();
if (!UserAcc.UserExpired())
{
PTTGC_EPIEntities db = new PTTGC_EPIEntities();
List<int> lstDelID = new List<int>();
if (arrValue != null)
lstDelID = arrValue.Select(s => s.toIntNullToZero()).ToList();
int nUserID = UserAcc.GetObjUser().nUserID;
db.TM_Effluent_Unit.Where(w => lstDelID.Contains(w.nUnitID)).ToList().ForEach(x =>
{
x.cDel = "Y";
x.dUpdate = DateTime.Now;
x.nUpdateBy = nUserID;
});
db.SaveChanges();
result.Status = SystemFunction.process_Success;
}
else
{
result.Status = SystemFunction.process_SessionExpired;
}
return result;
}
#region class
[Serializable]
public class CSearch : sysGlobalClass.CommonLoadData
{
public string sSearch { get; set; }
public string sStatus { get; set; }
public string sFacID { get; set; }
public string sPrms { get; set; }
}
[Serializable]
public class TRetunrLoadData : sysGlobalClass.Pagination
{
public List<TDataTable> lstData { get; set; }
}
[Serializable]
public class TDataTable
{
public int nUnitID { get; set; }
public int? nIsUse { get; set; }
public string sName { get; set; }
public string sStatus { get; set; }
public DateTime? dUpdate { get; set; }
public string sUpdate { get; set; }
public string sLink { get; set; }
}
#endregion
}