private DataTable GetDataRangeEndDT(TargetTable lottoType) { if (ViewState["DataRangeEnd" + lottoType.ToString()] == null) { string strlngTotalSN; #region get the first 0 in ingL1 as th last ingTotalSN using SqlCommand sqlCommand = new SqlCommand { Connection = new SqlConnection(new CglDBData().SetDataBase(lottoType, DatabaseType.Data)), CommandText = "SELECT [lngTotalSN] , [lngDateSN] FROM [tblData] WHERE [lngL1] = 0 ORDER BY [lngTotalSN] ASC ;" }; using SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand); using DataTable dtImport = new DataTable { Locale = InvariantCulture }; sqlDataAdapter.Fill(dtImport); strlngTotalSN = dtImport.Rows[0]["lngTotalSN"].ToString(); #endregion using SqlCommand sqlCommand01 = new SqlCommand { Connection = new SqlConnection(new CglData().SetDataBase(lottoType, DatabaseType.Data)), CommandText = "SELECT [lngTotalSN] , [lngDateSN] FROM [tblData] WHERE [lngTotalSN] <= @lngTotalSN ORDER BY [lngTotalSN] DESC ;" }; sqlCommand01.Parameters.AddWithValue("lngTotalSN", strlngTotalSN); using SqlDataAdapter sqlDataAdapter01 = new SqlDataAdapter(sqlCommand01); using DataTable dtImport01 = new DataTable { Locale = InvariantCulture }; sqlDataAdapter01.Fill(dtImport01); ViewState["DataRangeEnd" + lottoType.ToString()] = dtImport01; return(dtImport01); } else { return((DataTable)ViewState["DataRangeEnd" + lottoType.ToString()]); } }
public static bool DeleteExtensionObject(int targetId, TargetTable table, string name) { bool retVal = false; using (VpnManagerEntities entities = new VpnManagerEntities()) { ExtensionObjects eobj = (from extObj in entities.ExtensionObjects where extObj.TargetTableName == table.ToString() && extObj.IdTargetElement == targetId && extObj.Name == name select extObj).FirstOrDefault(); if (eobj != null) { entities.ExtensionObjects.Remove(eobj); retVal = entities.SaveChanges() > 0; } } return(retVal); }
public static ExtensionObjectDTO GetExtensionObject(int targetId, TargetTable table, string name) { ExtensionObjectDTO retVal = null; string tabName = table.ToString(); using (VpnManagerEntities entities = new VpnManagerEntities()) { retVal = (from eobj in entities.ExtensionObjects where eobj.IdTargetElement == targetId && eobj.Name == name && eobj.TargetTableName == tabName select new ExtensionObjectDTO { Id = eobj.Id, Name = eobj.Name, Value = eobj.Value, TargetTable = (int)table, }).FirstOrDefault(); } return(retVal); }