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

            if (model.floorNum != null)
            {
                strSql1.Append("floorNum,");
                strSql2.Append("'" + model.floorNum + "',");
            }
            if (model.roomID != null)
            {
                strSql1.Append("roomID,");
                strSql2.Append("'" + model.roomID + "',");
            }
            if (model.liveState == 0 || model.liveState == 1)
            {
                strSql1.Append("liveState,");
                strSql2.Append("" + model.liveState + ",");
            }
            if (model.cleanState == 0 || model.cleanState == 1)
            {
                strSql1.Append("cleanState,");
                strSql2.Append("" + model.cleanState + ",");
            }
            if (model.damageState == 0 || model.damageState == 1)
            {
                strSql1.Append("damageState,");
                strSql2.Append("" + model.damageState + ",");
            }
            if (model.roomTypeID != null)
            {
                strSql1.Append("roomTypeID,");
                strSql2.Append("'" + model.roomTypeID + "',");
            }
            if (model.roomAbandoned == 0 || model.roomAbandoned == 1)
            {
                strSql1.Append("roomAbandoned,");
                strSql2.Append("'" + model.roomAbandoned + "',");
            }

            strSql.Append("insert into Room(");
            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 = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Maticsoft.Model.Room GetModel(string floorNum, string roomID)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" floorNum,roomID,liveState,cleanState,damageState,roomTypeID,roomAbandoned ");
            strSql.Append(" from Room ");
            strSql.Append(" where floorNum='" + floorNum + "' and roomID='" + roomID + "' ");
            Maticsoft.Model.Room model = new Maticsoft.Model.Room();
            DataSet ds = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Maticsoft.Model.Room model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Room set ");
            if (model.liveState == 0 || model.liveState == 1)
            {
                strSql.Append("liveState=" + model.liveState + ",");
            }
            if (model.cleanState == 0 || model.cleanState == 1)
            {
                strSql.Append("cleanState=" + model.cleanState + ",");
            }
            if (model.damageState == 0 || model.damageState == 1)
            {
                strSql.Append("damageState=" + model.damageState + ",");
            }
            if (model.roomTypeID != null)
            {
                strSql.Append("roomTypeID='" + model.roomTypeID + "',");
            }
            if (model.roomAbandoned == 0 || model.roomAbandoned == 1)
            {
                strSql.Append("roomAbandoned='" + model.roomAbandoned + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where floorNum='" + model.floorNum + "' and roomID='" + model.roomID + "' ");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public Maticsoft.Model.Room DataRowToModel(DataRow row)
 {
     Maticsoft.Model.Room model = new Maticsoft.Model.Room();
     if (row != null)
     {
         if (row["floorNum"] != null)
         {
             model.floorNum = row["floorNum"].ToString();
         }
         if (row["roomID"] != null)
         {
             model.roomID = row["roomID"].ToString();
         }
         if (row["liveState"] != null && row["liveState"].ToString() != "")
         {
             model.liveState = int.Parse(row["liveState"].ToString());
         }
         if (row["cleanState"] != null && row["cleanState"].ToString() != "")
         {
             model.cleanState = int.Parse(row["cleanState"].ToString());
         }
         if (row["damageState"] != null && row["damageState"].ToString() != "")
         {
             model.damageState = int.Parse(row["damageState"].ToString());
         }
         if (row["roomTypeID"] != null)
         {
             model.roomTypeID = row["roomTypeID"].ToString();
         }
         if (row["roomAbandoned"] != null && row["roomAbandoned"].ToString() != "")
         {
             model.roomAbandoned = int.Parse(row["roomAbandoned"].ToString());
         }
     }
     return(model);
 }