private void Count_Total() { try { AccesscounterInfo icounter = DAL.Getinfototal(); if (icounter == null) icounter = new AccesscounterInfo(); icounter.Counter_Total += CConstants.ACCESS_TOTAL; List<AccesscounterInfo> list = new List<AccesscounterInfo>(); list.Add(icounter); (new GenericList<AccesscounterInfo>()).Bind_DataList(rptList, null, list, 0); return; } catch (Exception ex) { throw ex; } }
private void Count_Total() { try { currentaccess.Text = ((int)Application["CurrentAccess"]).ToString(); CAccesscounter DAL = new CAccesscounter(); AccesscounterInfo icounter = DAL.Getinfototal(); if (icounter == null) icounter = new AccesscounterInfo(); List<AccesscounterInfo> list = new List<AccesscounterInfo>(); list.Add(icounter); (new GenericList<AccesscounterInfo>()).Bind_DataList(rptList, null, list, 0); return; } catch (Exception ex) { throw ex; } }
public AccesscounterInfo Getinfototal() { try { AccesscounterInfo info = new AccesscounterInfo(); using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { string SQL = SQL_GETIFO; SQL += " AND id=1"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) info.Counter_Total = dar.IsDBNull(1) ? 0 : dar.GetInt32(1); dar.Close(); } SQL = SQL_GETIFO + " AND name='" + DateTime.Today.AddDays(-1).ToString("MM/dd/yyyy") + "'"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) info.Counter_Yesterday = dar.IsDBNull(1) ? 0 : dar.GetInt32(1); dar.Close(); } SQL = SQL_GETIFO + " AND name='" + DateTime.Today.ToString("MM/dd/yyyy") + "'"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) info.Counter_ThisDate = dar.IsDBNull(1) ? 0 : dar.GetInt32(1); dar.Close(); } SQL = SQL_GETIFO + " AND name='" + CFunctions.FirstDayOfWeek(DateTime.Today) + " - " + CFunctions.LastDayOfWeek(DateTime.Today) + "'"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) info.Counter_ThisWeek = dar.IsDBNull(1) ? 0 : dar.GetInt32(1); dar.Close(); } SQL = SQL_GETIFO + " AND name='" + DateTime.Today.ToString("MM/yyyy") + "'"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) info.Counter_ThisMonth = dar.IsDBNull(1) ? 0 : dar.GetInt32(1); dar.Close(); } iConn.Close(); } return info; } catch (Exception ex) { throw ex; } }
private void setParameter(iSqlParameter[] parms, AccesscounterInfo info) { try { int i = -1; parms[++i].Value = CFunctions.SetDBString(info.Name); parms[++i].Value = info.Counter; parms[++i].Value = info.Id; return; } catch (Exception ex) { throw ex; } }
private bool Saveitem(iSqlTransaction trans, AccesscounterInfo info) { try { if (trans == null || info == null) return false; string SQL = string.Empty; if (info.Id == 0) { SQL = SQL_INSERT; info.Id = (int)HELPER.getNewID(trans, TABLENAME); iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } else if (HELPER.isExist(trans, TABLENAME, info.Id)) { SQL = SQL_UPDATE; iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } else { SQL = SQL_INSERT; info.Id = (int)HELPER.getNewID(trans, TABLENAME); iSqlParameter[] parms = this.getParameter(SQL); this.setParameter(parms, info); HELPER.executeNonQuery(trans, iCommandType.Text, SQL, parms); } return true; } catch (Exception ex) { throw ex; } }
private AccesscounterInfo getDataReader(iSqlDataReader dar) { try { int i = -1; AccesscounterInfo info = new AccesscounterInfo(); info.Name = dar.IsDBNull(++i) ? "" : dar.GetString(i); info.Counter = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); info.Id = dar.IsDBNull(++i) ? 0 : dar.GetInt32(i); return info; } catch (Exception ex) { throw ex; } }
public void Updatetotal_detail(iSqlConnection iConn, string name) { try { string SQL = SQL_GETIFO; SQL += " AND name='" + name + "'"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) { dar.Close(); SQL = "UPDATE " + TABLENAME + " SET counter=counter+1 WHERE name='" + name + "'"; HELPER.executeNonQuery(iConn, SQL); } else { AccesscounterInfo info = new AccesscounterInfo(); info.Name = name; info.Counter = 1; this.Save(info); } } } catch (Exception ex) { throw ex; } }
public int Updatecouter(string name) { try { int counter = 0; using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { string SQL = SQL_GETIFO; SQL += " AND name='" + name + "'"; using (iSqlDataReader dar = HELPER.executeReader(iConn, SQL)) { if (dar.Read()) { AccesscounterInfo info = this.getDataReader(dar); counter = info.Counter + 1; dar.Close(); SQL = "UPDATE " + TABLENAME + " SET counter=counter+1 WHERE name='" + name + "'"; HELPER.executeNonQuery(iConn, SQL); } else { AccesscounterInfo info = new AccesscounterInfo(); info.Name = name; info.Counter = 1; this.Save(info); counter = 1; } } iConn.Close(); } return counter; } catch (Exception ex) { throw ex; } }
public bool Save(AccesscounterInfo info) { try { using (iSqlConnection iConn = HELPER.getConnect(HELPER.SQL_SYSTEM)) { using (iSqlTransaction trans = iConn.BeginTransaction()) { try { this.Saveitem(trans, info); trans.Commit(); } catch (Exception ex) { trans.Rollback(); throw ex; } } iConn.Close(); } return true; } catch (Exception ex) { throw ex; } }