示例#1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(batteryTraceModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update batteryTrace set ");
            strSql.Append("batteryID=@batteryID,");
            strSql.Append("eventCata=@eventCata,");
            strSql.Append("eventDesc=@eventDesc,");
            strSql.Append("eventTime=@eventTime,");
            strSql.Append("tag1=@tag1,");
            strSql.Append("tag2=@tag2,");
            strSql.Append("tag3=@tag3,");
            strSql.Append("tag4=@tag4,");
            strSql.Append("tag5=@tag5");
            strSql.Append(" where batteryTraceID=@batteryTraceID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@batteryID",      SqlDbType.NVarChar,   50),
                new SqlParameter("@eventCata",      SqlDbType.NVarChar,   50),
                new SqlParameter("@eventDesc",      SqlDbType.NVarChar,  255),
                new SqlParameter("@eventTime",      SqlDbType.DateTime),
                new SqlParameter("@tag1",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag2",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag3",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag4",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag5",           SqlDbType.NVarChar,   50),
                new SqlParameter("@batteryTraceID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.batteryID;
            parameters[1].Value = model.eventCata;
            parameters[2].Value = model.eventDesc;
            parameters[3].Value = model.eventTime;
            parameters[4].Value = model.tag1;
            parameters[5].Value = model.tag2;
            parameters[6].Value = model.tag3;
            parameters[7].Value = model.tag4;
            parameters[8].Value = model.tag5;
            parameters[9].Value = model.batteryTraceID;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public batteryTraceModel DataRowToModel(DataRow row)
        {
            batteryTraceModel model = new batteryTraceModel();

            if (row != null)
            {
                if (row["batteryTraceID"] != null)
                {
                    model.batteryTraceID = row["batteryTraceID"].ToString();
                }
                if (row["batteryID"] != null)
                {
                    model.batteryID = row["batteryID"].ToString();
                }
                if (row["eventCata"] != null)
                {
                    model.eventCata = row["eventCata"].ToString();
                }
                if (row["eventDesc"] != null)
                {
                    model.eventDesc = row["eventDesc"].ToString();
                }
                if (row["eventTime"] != null && row["eventTime"].ToString() != "")
                {
                    model.eventTime = DateTime.Parse(row["eventTime"].ToString());
                }
                if (row["tag1"] != null)
                {
                    model.tag1 = row["tag1"].ToString();
                }
                if (row["tag2"] != null)
                {
                    model.tag2 = row["tag2"].ToString();
                }
                if (row["tag3"] != null)
                {
                    model.tag3 = row["tag3"].ToString();
                }
                if (row["tag4"] != null)
                {
                    model.tag4 = row["tag4"].ToString();
                }
                if (row["tag5"] != null)
                {
                    model.tag5 = row["tag5"].ToString();
                }
            }
            return(model);
        }
示例#3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(batteryTraceModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into batteryTrace(");
            strSql.Append("batteryTraceID,batteryID,eventCata,eventDesc,eventTime,tag1,tag2,tag3,tag4,tag5)");
            strSql.Append(" values (");
            strSql.Append("@batteryTraceID,@batteryID,@eventCata,@eventDesc,@eventTime,@tag1,@tag2,@tag3,@tag4,@tag5)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@batteryTraceID", SqlDbType.NVarChar,   50),
                new SqlParameter("@batteryID",      SqlDbType.NVarChar,   50),
                new SqlParameter("@eventCata",      SqlDbType.NVarChar,   50),
                new SqlParameter("@eventDesc",      SqlDbType.NVarChar,  255),
                new SqlParameter("@eventTime",      SqlDbType.DateTime),
                new SqlParameter("@tag1",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag2",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag3",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag4",           SqlDbType.NVarChar,   50),
                new SqlParameter("@tag5",           SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = model.batteryTraceID;
            parameters[1].Value = model.batteryID;
            parameters[2].Value = model.eventCata;
            parameters[3].Value = model.eventDesc;
            parameters[4].Value = model.eventTime;
            parameters[5].Value = model.tag1;
            parameters[6].Value = model.tag2;
            parameters[7].Value = model.tag3;
            parameters[8].Value = model.tag4;
            parameters[9].Value = model.tag5;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public batteryTraceModel GetModel(string batteryTraceID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 batteryTraceID,batteryID,eventCata,eventDesc,eventTime,tag1,tag2,tag3,tag4,tag5 from batteryTrace ");
            strSql.Append(" where batteryTraceID=@batteryTraceID ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@batteryTraceID", SqlDbType.NVarChar, 50)
            };
            parameters[0].Value = batteryTraceID;

            batteryTraceModel model = new batteryTraceModel();
            DataSet           ds    = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
示例#5
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(batteryTraceModel model)
 {
     return(dal.Update(model));
 }
示例#6
0
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public bool Add(batteryTraceModel model)
 {
     return(dal.Add(model));
 }