Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.BadReaction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BadReaction set ");
            strSql.Append("PID=@PID,");
            strSql.Append("Peroid=@Peroid,");
            strSql.Append("ReactionName=@ReactionName,");
            strSql.Append("OccurDate=@OccurDate,");
            strSql.Append("Severity=@Severity,");
            strSql.Append("TreatMethod=@TreatMethod,");
            strSql.Append("TreatResult=@TreatResult");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@PID",          OleDbType.Integer,  4),
                new OleDbParameter("@Peroid",       OleDbType.Integer,  4),
                new OleDbParameter("@ReactionName", OleDbType.VarChar, 50),
                new OleDbParameter("@OccurDate",    OleDbType.Date),
                new OleDbParameter("@Severity",     OleDbType.VarChar, 50),
                new OleDbParameter("@TreatMethod",  OleDbType.VarChar, 50),
                new OleDbParameter("@TreatResult",  OleDbType.VarChar, 50),
                new OleDbParameter("@ID",           OleDbType.Integer, 4)
            };
            parameters[0].Value = model.PID;
            parameters[1].Value = model.Peroid;
            parameters[2].Value = model.ReactionName;
            parameters[3].Value = model.OccurDate;
            parameters[4].Value = model.Severity;
            parameters[5].Value = model.TreatMethod;
            parameters[6].Value = model.TreatResult;
            parameters[7].Value = model.ID;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.BadReaction DataRowToModel(DataRow row)
 {
     Maticsoft.Model.BadReaction model = new Maticsoft.Model.BadReaction();
     if (row != null)
     {
         if (row["ID"] != null && row["ID"].ToString() != "")
         {
             model.ID = int.Parse(row["ID"].ToString());
         }
         if (row["PID"] != null && row["PID"].ToString() != "")
         {
             model.PID = int.Parse(row["PID"].ToString());
         }
         if (row["Peroid"] != null && row["Peroid"].ToString() != "")
         {
             model.Peroid = int.Parse(row["Peroid"].ToString());
         }
         if (row["ReactionName"] != null)
         {
             model.ReactionName = row["ReactionName"].ToString();
         }
         if (row["OccurDate"] != null && row["OccurDate"].ToString() != "")
         {
             model.OccurDate = DateTime.Parse(row["OccurDate"].ToString());
         }
         if (row["Severity"] != null)
         {
             model.Severity = row["Severity"].ToString();
         }
         if (row["TreatMethod"] != null)
         {
             model.TreatMethod = row["TreatMethod"].ToString();
         }
         if (row["TreatResult"] != null)
         {
             model.TreatResult = row["TreatResult"].ToString();
         }
     }
     return(model);
 }
Beispiel #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(Maticsoft.Model.BadReaction model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into BadReaction(");
            strSql.Append("PID,Peroid,ReactionName,OccurDate,Severity,TreatMethod,TreatResult)");
            strSql.Append(" values (");
            strSql.Append("@PID,@Peroid,@ReactionName,@OccurDate,@Severity,@TreatMethod,@TreatResult)");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@PID",          OleDbType.Integer,  4),
                new OleDbParameter("@Peroid",       OleDbType.Integer,  4),
                new OleDbParameter("@ReactionName", OleDbType.VarChar, 50),
                new OleDbParameter("@OccurDate",    OleDbType.Date),
                new OleDbParameter("@Severity",     OleDbType.VarChar, 50),
                new OleDbParameter("@TreatMethod",  OleDbType.VarChar, 50),
                new OleDbParameter("@TreatResult",  OleDbType.VarChar, 50)
            };
            parameters[0].Value = model.PID;
            parameters[1].Value = model.Peroid;
            parameters[2].Value = model.ReactionName;
            parameters[3].Value = model.OccurDate;
            parameters[4].Value = model.Severity;
            parameters[5].Value = model.TreatMethod;
            parameters[6].Value = model.TreatResult;

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

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.BadReaction GetModel(int ID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select ID,PID,Peroid,ReactionName,OccurDate,Severity,TreatMethod,TreatResult from BadReaction ");
            strSql.Append(" where ID=@ID");
            OleDbParameter[] parameters =
            {
                new OleDbParameter("@ID", OleDbType.Integer, 4)
            };
            parameters[0].Value = ID;

            Maticsoft.Model.BadReaction model = new Maticsoft.Model.BadReaction();
            DataSet ds = DbHelperOleDb.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }