Example #1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Model.errlog model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.LOG_MSG != null)
            {
                strSql1.Append("LOG_MSG,");
                strSql2.Append("" + model.LOG_MSG + ",");
            }
            if (model.CXMC != null)
            {
                strSql1.Append("CXMC,");
                strSql2.Append("'" + model.CXMC + "',");
            }
            if (model.RLZBH != null)
            {
                strSql1.Append("RLZBH,");
                strSql2.Append("'" + model.RLZBH + "',");
            }
            if (model.RLR != null)
            {
                strSql1.Append("RLR,");
                strSql2.Append("'" + model.RLR + "',");
            }
            if (model.RLSJ != null)
            {
                strSql1.Append("RLSJ,");
                strSql2.Append("'" + model.RLSJ + "',");
            }
            if (model.RLDMM != null)
            {
                strSql1.Append("RLDMM,");
                strSql2.Append("'" + model.RLDMM + "',");
            }
            strSql.Append("insert into errlog(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            int rows = DbHelperMySql.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.errlog GetModel(long ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  ");
            strSql.Append(" ID,LOG_MSG,CXMC,RLZBH,RLR,RLSJ,RLDMM ");
            strSql.Append(" from errlog ");
            strSql.Append(" where ID=" + ID + "");
            Model.errlog model = new Model.errlog();
            DataSet      ds    = DbHelperMySql.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Example #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.errlog DataRowToModel(DataRow row)
 {
     Model.errlog model = new Model.errlog();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = long.Parse(row["ID"].ToString());
         }
         if (row["LOG_MSG"] != null)
         {
             model.LOG_MSG = row["LOG_MSG"].ToString();
         }
         if (row["CXMC"] != null)
         {
             model.CXMC = row["CXMC"].ToString();
         }
         if (row["RLZBH"] != null)
         {
             model.RLZBH = row["RLZBH"].ToString();
         }
         if (row["RLR"] != null)
         {
             model.RLR = row["RLR"].ToString();
         }
         if (row["RLSJ"] != null)
         {
             model.RLSJ = row["RLSJ"].ToString();
         }
         if (row["RLDMM"] != null)
         {
             model.RLDMM = row["RLDMM"].ToString();
         }
     }
     return(model);
 }
Example #4
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.errlog model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update errlog set ");
            if (model.LOG_MSG != null)
            {
                strSql.Append("LOG_MSG=" + model.LOG_MSG + ",");
            }
            else
            {
                strSql.Append("LOG_MSG= null ,");
            }
            if (model.CXMC != null)
            {
                strSql.Append("CXMC='" + model.CXMC + "',");
            }
            else
            {
                strSql.Append("CXMC= null ,");
            }
            if (model.RLZBH != null)
            {
                strSql.Append("RLZBH='" + model.RLZBH + "',");
            }
            else
            {
                strSql.Append("RLZBH= null ,");
            }
            if (model.RLR != null)
            {
                strSql.Append("RLR='" + model.RLR + "',");
            }
            else
            {
                strSql.Append("RLR= null ,");
            }
            if (model.RLSJ != null)
            {
                strSql.Append("RLSJ='" + model.RLSJ + "',");
            }
            else
            {
                strSql.Append("RLSJ= null ,");
            }
            if (model.RLDMM != null)
            {
                strSql.Append("RLDMM='" + model.RLDMM + "',");
            }
            else
            {
                strSql.Append("RLDMM= null ,");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where ID=" + model.ID + "");
            int rowsAffected = DbHelperMySql.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #5
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.errlog GetModel(long ID)
 {
     StringBuilder strSql=new StringBuilder();
     strSql.Append("select  ");
     strSql.Append(" ID,LOG_MSG,CXMC,RLZBH,RLR,RLSJ,RLDMM ");
     strSql.Append(" from errlog ");
     strSql.Append(" where ID="+ID+"" );
     Model.errlog model=new Model.errlog();
     DataSet ds=DbHelperMySql.Query(strSql.ToString());
     if(ds.Tables[0].Rows.Count>0)
     {
         return DataRowToModel(ds.Tables[0].Rows[0]);
     }
     else
     {
         return null;
     }
 }
Example #6
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Model.errlog DataRowToModel(DataRow row)
 {
     Model.errlog model=new Model.errlog();
     if (row != null)
     {
         if(row["ID"]!=null && row["ID"].ToString()!="")
         {
             model.ID=long.Parse(row["ID"].ToString());
         }
         if(row["LOG_MSG"]!=null)
         {
             model.LOG_MSG=row["LOG_MSG"].ToString();
         }
         if(row["CXMC"]!=null)
         {
             model.CXMC=row["CXMC"].ToString();
         }
         if(row["RLZBH"]!=null)
         {
             model.RLZBH=row["RLZBH"].ToString();
         }
         if(row["RLR"]!=null)
         {
             model.RLR=row["RLR"].ToString();
         }
         if(row["RLSJ"]!=null)
         {
             model.RLSJ=row["RLSJ"].ToString();
         }
         if(row["RLDMM"]!=null)
         {
             model.RLDMM=row["RLDMM"].ToString();
         }
     }
     return model;
 }