/// <summary> /// 获取一个范围内的数量总和 /// </summary> /// <returns></returns> public int GetRangeItemCount(string tagName) { try { object ret = null; string strSql = "select StartCount from acq_count_list where tagName=" + tagName; //ret = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql, null); ret = SQLiteDBHelper.ExecuteScalar(strSql); if (ret != null) { int itemCount = -1; Int32.TryParse(ret.ToString(), out itemCount); if (itemCount < 0) { itemCount = 0; } return(itemCount); } else { return(0); } } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(0); } }
public string GetTIDByDataTime(string planid, DateTime startTime, DateTime endTime) { try { object nvalue = null; string ret = string.Empty; string strSql = "select tid from production_plan where plan_id='{0}' and start_time = '{1}' and end_time ='{2}'"; string sDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", startTime); //4-10-2010 17:16:50\ string eDate = String.Format("{0:yyyy-MM-dd HH:mm:ss}", endTime); strSql = string.Format(strSql, planid, sDate, eDate); // nvalue = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql); nvalue = SQLiteDBHelper.ExecuteScalar(strSql); if (nvalue == null) { return(string.Empty); } ret = Convert.ToInt32(nvalue).ToString(); return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(string.Empty); } }
/// <summary> /// 获取采集记录列表的当前采集时间 /// </summary> /// <returns></returns> public DateTime GetCurrentTime() { try { DateTime curTime; object ret = null; string strSql = "select StartTime from acq_count_list where tagName=0"; //ret = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql, null); ret = SQLiteDBHelper.ExecuteScalar(strSql); DateTime.TryParse(ret.ToString(), out curTime); if (curTime != null) { return(curTime); } else { return(DateTime.Now); } } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(DateTime.Now); } }
/// <summary> /// /// 获取广报版信息 /// </summary> /// <returns></returns> public string GetNoticeInfo() { string ret = string.Empty; object obj = null; try { string strSql = "select content from notice order by update_time"; //obj = MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql); obj = SQLiteDBHelper.ExecuteScalar(strSql); if (obj != null) { ret = Convert.ToString(obj); } return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(string.Empty); } }
/// <summary> /// 获取产品个数 /// </summary> /// <returns></returns> public int GetRowCount() { int ret = 0; string strSql = string.Empty; try { strSql = "select count(tid) from acq_count_list;"; //ret = Convert.ToInt32(MySqlDBHelper.ExecuteScalar(MySqlDBHelper.Conn, CommandType.Text, strSql, null)); ret = Convert.ToInt32(SQLiteDBHelper.ExecuteScalar(strSql)); //return Convert.ToInt32(MySqlDBHelper.ExecuteNonQuery(MySqlDBHelper.Conn, CommandType.Text, strSql, null)); return(ret); } catch (Exception ex) { CLog.WriteErrLogInTrace(ex.Message); return(0); } }