/// <summary> /// 更新一条数据 /// </summary> public bool Update(KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ReaderTimeAccess set "); strSql.Append("ReaderTimeAccessName=@ReaderTimeAccessName,"); strSql.Append("Mon=@Mon,"); strSql.Append("Tue=@Tue,"); strSql.Append("Wed=@Wed,"); strSql.Append("Thu=@Thu,"); strSql.Append("Fri=@Fri,"); strSql.Append("Sat=@Sat,"); strSql.Append("Sun=@Sun"); strSql.Append(" where ReaderTimeAccessID=@ReaderTimeAccessID "); SqlParameter[] parameters = { new SqlParameter("@ReaderTimeAccessName", SqlDbType.NVarChar, 50), new SqlParameter("@Mon", SqlDbType.Int, 4), new SqlParameter("@Tue", SqlDbType.Int, 4), new SqlParameter("@Wed", SqlDbType.Int, 4), new SqlParameter("@Thu", SqlDbType.Int, 4), new SqlParameter("@Fri", SqlDbType.Int, 4), new SqlParameter("@Sat", SqlDbType.Int, 4), new SqlParameter("@Sun", SqlDbType.Int, 4), new SqlParameter("@ReaderTimeAccessID", SqlDbType.Int, 4) }; parameters[0].Value = model.ReaderTimeAccessName; parameters[1].Value = model.Mon; parameters[2].Value = model.Tue; parameters[3].Value = model.Wed; parameters[4].Value = model.Thu; parameters[5].Value = model.Fri; parameters[6].Value = model.Sat; parameters[7].Value = model.Sun; parameters[8].Value = model.ReaderTimeAccessID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess model = new KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess(); if (row != null) { if (row["ReaderTimeAccessID"] != null && row["ReaderTimeAccessID"].ToString() != "") { model.ReaderTimeAccessID = int.Parse(row["ReaderTimeAccessID"].ToString()); } if (row["ReaderTimeAccessName"] != null) { model.ReaderTimeAccessName = row["ReaderTimeAccessName"].ToString(); } if (row["Mon"] != null && row["Mon"].ToString() != "") { model.Mon = int.Parse(row["Mon"].ToString()); } if (row["Tue"] != null && row["Tue"].ToString() != "") { model.Tue = int.Parse(row["Tue"].ToString()); } if (row["Wed"] != null && row["Wed"].ToString() != "") { model.Wed = int.Parse(row["Wed"].ToString()); } if (row["Thu"] != null && row["Thu"].ToString() != "") { model.Thu = int.Parse(row["Thu"].ToString()); } if (row["Fri"] != null && row["Fri"].ToString() != "") { model.Fri = int.Parse(row["Fri"].ToString()); } if (row["Sat"] != null && row["Sat"].ToString() != "") { model.Sat = int.Parse(row["Sat"].ToString()); } if (row["Sun"] != null && row["Sun"].ToString() != "") { model.Sun = int.Parse(row["Sun"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ReaderTimeAccess("); strSql.Append("ReaderTimeAccessID,ReaderTimeAccessName,Mon,Tue,Wed,Thu,Fri,Sat,Sun)"); strSql.Append(" values ("); strSql.Append("@ReaderTimeAccessID,@ReaderTimeAccessName,@Mon,@Tue,@Wed,@Thu,@Fri,@Sat,@Sun)"); SqlParameter[] parameters = { new SqlParameter("@ReaderTimeAccessID", SqlDbType.Int, 4), new SqlParameter("@ReaderTimeAccessName", SqlDbType.NVarChar, 50), new SqlParameter("@Mon", SqlDbType.Int, 4), new SqlParameter("@Tue", SqlDbType.Int, 4), new SqlParameter("@Wed", SqlDbType.Int, 4), new SqlParameter("@Thu", SqlDbType.Int, 4), new SqlParameter("@Fri", SqlDbType.Int, 4), new SqlParameter("@Sat", SqlDbType.Int, 4), new SqlParameter("@Sun", SqlDbType.Int, 4) }; parameters[0].Value = model.ReaderTimeAccessID; parameters[1].Value = model.ReaderTimeAccessName; parameters[2].Value = model.Mon; parameters[3].Value = model.Tue; parameters[4].Value = model.Wed; parameters[5].Value = model.Thu; parameters[6].Value = model.Fri; parameters[7].Value = model.Sat; parameters[8].Value = model.Sun; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess GetModel(int ReaderTimeAccessID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 ReaderTimeAccessID,ReaderTimeAccessName,Mon,Tue,Wed,Thu,Fri,Sat,Sun from ReaderTimeAccess "); strSql.Append(" where ReaderTimeAccessID=@ReaderTimeAccessID "); SqlParameter[] parameters = { new SqlParameter("@ReaderTimeAccessID", SqlDbType.Int, 4) }; parameters[0].Value = ReaderTimeAccessID; KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess model = new KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess DataRowToModel(DataRow row) { KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess model=new KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess(); if (row != null) { if(row["ReaderTimeAccessID"]!=null && row["ReaderTimeAccessID"].ToString()!="") { model.ReaderTimeAccessID=int.Parse(row["ReaderTimeAccessID"].ToString()); } if(row["ReaderTimeAccessName"]!=null) { model.ReaderTimeAccessName=row["ReaderTimeAccessName"].ToString(); } if(row["Mon"]!=null && row["Mon"].ToString()!="") { model.Mon=int.Parse(row["Mon"].ToString()); } if(row["Tue"]!=null && row["Tue"].ToString()!="") { model.Tue=int.Parse(row["Tue"].ToString()); } if(row["Wed"]!=null && row["Wed"].ToString()!="") { model.Wed=int.Parse(row["Wed"].ToString()); } if(row["Thu"]!=null && row["Thu"].ToString()!="") { model.Thu=int.Parse(row["Thu"].ToString()); } if(row["Fri"]!=null && row["Fri"].ToString()!="") { model.Fri=int.Parse(row["Fri"].ToString()); } if(row["Sat"]!=null && row["Sat"].ToString()!="") { model.Sat=int.Parse(row["Sat"].ToString()); } if(row["Sun"]!=null && row["Sun"].ToString()!="") { model.Sun=int.Parse(row["Sun"].ToString()); } } return model; }
/// <summary> /// 得到一个对象实体 /// </summary> public KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess GetModel(int ReaderTimeAccessID) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 ReaderTimeAccessID,ReaderTimeAccessName,Mon,Tue,Wed,Thu,Fri,Sat,Sun from ReaderTimeAccess "); strSql.Append(" where ReaderTimeAccessID=@ReaderTimeAccessID "); SqlParameter[] parameters = { new SqlParameter("@ReaderTimeAccessID", SqlDbType.Int,4) }; parameters[0].Value = ReaderTimeAccessID; KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess model=new KryptonAccessController.AccessDataBase.Model.ReaderTimeAccess(); DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters); if(ds.Tables[0].Rows.Count>0) { return DataRowToModel(ds.Tables[0].Rows[0]); } else { return null; } }