/// <summary> /// 更新一条数据 /// </summary> public bool Update(Maticsoft.Model.CustomerLive model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update CustomerLive set "); if (model.proEndLiveTime != null) { strSql.Append("proEndLiveTime='" + model.proEndLiveTime + "',"); } if (model.endLiveTime != null) { strSql.Append("endLiveTime='" + model.endLiveTime + "',"); } if (model.isAccount == 0 || model.isAccount == 1) { strSql.Append("isAccount='" + model.isAccount + "',"); } int n = strSql.ToString().LastIndexOf(","); strSql.Remove(n, 1); strSql.Append(" where startLiveTime='" + model.startLiveTime + "' and cusID='" + model.cusID + "' and floorNum='" + model.floorNum + "' and roomID='" + model.roomID + "' "); int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString()); if (rowsAffected > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(Maticsoft.Model.CustomerLive model) { StringBuilder strSql = new StringBuilder(); StringBuilder strSql1 = new StringBuilder(); StringBuilder strSql2 = new StringBuilder(); if (model.startLiveTime != null) { strSql1.Append("startLiveTime,"); strSql2.Append("'" + model.startLiveTime + "',"); } if (model.proEndLiveTime != null) { strSql1.Append("proEndLiveTime,"); strSql2.Append("'" + model.proEndLiveTime + "',"); } if (model.endLiveTime != null) { strSql1.Append("endLiveTime,"); strSql2.Append("'" + model.endLiveTime + "',"); } if (model.cusID != null) { strSql1.Append("cusID,"); strSql2.Append("'" + model.cusID + "',"); } if (model.floorNum != null) { strSql1.Append("floorNum,"); strSql2.Append("'" + model.floorNum + "',"); } if (model.roomID != null) { strSql1.Append("roomID,"); strSql2.Append("'" + model.roomID + "',"); } if (model.isAccount == 0 || model.isAccount == 1) { strSql1.Append("isAccount"); strSql2.Append("'" + model.isAccount + "',"); } strSql.Append("insert into CustomerLive("); 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); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.CustomerLive GetModel(DateTime startLiveTime, string cusID, string floorNum, string roomID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 "); strSql.Append(" startLiveTime,proEndLiveTime,endLiveTime,cusID,floorNum,roomID,isAccount "); strSql.Append(" from CustomerLive "); strSql.Append(" where startLiveTime='" + startLiveTime + "' and cusID='" + cusID + "' and floorNum='" + floorNum + "' and roomID='" + roomID + "' "); Maticsoft.Model.CustomerLive model = new Maticsoft.Model.CustomerLive(); DataSet ds = DbHelperSQL.Query(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public Maticsoft.Model.CustomerLive DataRowToModel(DataRow row) { Maticsoft.Model.CustomerLive model = new Maticsoft.Model.CustomerLive(); if (row != null) { if (row["startLiveTime"] != null && row["startLiveTime"].ToString() != "") { model.startLiveTime = DateTime.Parse(row["startLiveTime"].ToString()); } if (row["proEndLiveTime"] != null && row["proEndLiveTime"].ToString() != "") { model.proEndLiveTime = DateTime.Parse(row["proEndLiveTime"].ToString()); } if (row["endLiveTime"] != null && row["endLiveTime"].ToString() != "") { model.endLiveTime = DateTime.Parse(row["endLiveTime"].ToString()); } if (row["cusID"] != null) { model.cusID = row["cusID"].ToString(); } if (row["floorNum"] != null) { model.floorNum = row["floorNum"].ToString(); } if (row["roomID"] != null) { model.roomID = row["roomID"].ToString(); } if (row["isAccount"] != null && row["isAccount"].ToString() != "") { model.isAccount = int.Parse(row["isAccount"].ToString()); } } return(model); }