/// <summary> /// 增加一条数据 /// </summary> public bool Add(AutoIrrigateConfigEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Auto_Irrigate_Config("); strSql.Append("Trigger_Facility_ID,Auto_Irrigate_Facility_ID,StartOrStop_MSC_ID,State_MSC_ID,Irrigate_Duration,Auto_Irrigate_Enabled)"); strSql.Append(" values ("); strSql.Append("@Trigger_Facility_ID,@Auto_Irrigate_Facility_ID,@StartOrStop_MSC_ID,@State_MSC_ID,@Irrigate_Duration,@Auto_Irrigate_Enabled)"); SqlParameter[] parameters = { new SqlParameter("@Trigger_Facility_ID", SqlDbType.Int, 4), new SqlParameter("@Auto_Irrigate_Facility_ID", SqlDbType.Int, 4), new SqlParameter("@StartOrStop_MSC_ID", SqlDbType.Int, 4), new SqlParameter("@State_MSC_ID", SqlDbType.Int, 4), new SqlParameter("@Irrigate_Duration", SqlDbType.Int, 4), new SqlParameter("@Auto_Irrigate_Enabled", SqlDbType.Bit, 1) }; parameters[0].Value = model.Trigger_Facility_ID; parameters[1].Value = model.Auto_Irrigate_Facility_ID; parameters[2].Value = model.StartOrStop_MSC_ID; parameters[3].Value = model.State_MSC_ID; parameters[4].Value = model.Irrigate_Duration; parameters[5].Value = model.Auto_Irrigate_Enabled; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public AutoIrrigateConfigEntity DataRowToModel(DataRow row) { AutoIrrigateConfigEntity model = new AutoIrrigateConfigEntity(); if (row != null) { if (row["Trigger_Facility_ID"] != null && row["Trigger_Facility_ID"].ToString() != "") { model.Trigger_Facility_ID = int.Parse(row["Trigger_Facility_ID"].ToString()); } if (row["Auto_Irrigate_Facility_ID"] != null && row["Auto_Irrigate_Facility_ID"].ToString() != "") { model.Auto_Irrigate_Facility_ID = int.Parse(row["Auto_Irrigate_Facility_ID"].ToString()); } if (row["StartOrStop_MSC_ID"] != null && row["StartOrStop_MSC_ID"].ToString() != "") { model.StartOrStop_MSC_ID = int.Parse(row["StartOrStop_MSC_ID"].ToString()); } if (row["State_MSC_ID"] != null && row["State_MSC_ID"].ToString() != "") { model.State_MSC_ID = int.Parse(row["State_MSC_ID"].ToString()); } if (row["Irrigate_Duration"] != null && row["Irrigate_Duration"].ToString() != "") { model.Irrigate_Duration = int.Parse(row["Irrigate_Duration"].ToString()); } if (row["Auto_Irrigate_Enabled"] != null && row["Auto_Irrigate_Enabled"].ToString() != "") { if ((row["Auto_Irrigate_Enabled"].ToString() == "1") || (row["Auto_Irrigate_Enabled"].ToString().ToLower() == "true")) { model.Auto_Irrigate_Enabled = true; } else { model.Auto_Irrigate_Enabled = false; } } } return(model); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(AutoIrrigateConfigEntity model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Auto_Irrigate_Config set "); strSql.Append("Trigger_Facility_ID=@Trigger_Facility_ID,"); strSql.Append("StartOrStop_MSC_ID=@StartOrStop_MSC_ID,"); strSql.Append("State_MSC_ID=@State_MSC_ID,"); strSql.Append("Irrigate_Duration=@Irrigate_Duration,"); strSql.Append("Auto_Irrigate_Enabled=@Auto_Irrigate_Enabled"); strSql.Append(" where Auto_Irrigate_Facility_ID=@Auto_Irrigate_Facility_ID "); SqlParameter[] parameters = { new SqlParameter("@Trigger_Facility_ID", SqlDbType.Int, 4), new SqlParameter("@StartOrStop_MSC_ID", SqlDbType.Int, 4), new SqlParameter("@State_MSC_ID", SqlDbType.Int, 4), new SqlParameter("@Irrigate_Duration", SqlDbType.Int, 4), new SqlParameter("@Auto_Irrigate_Enabled", SqlDbType.Bit, 1), new SqlParameter("@Auto_Irrigate_Facility_ID", SqlDbType.Int, 4) }; parameters[0].Value = model.Trigger_Facility_ID; parameters[1].Value = model.StartOrStop_MSC_ID; parameters[2].Value = model.State_MSC_ID; parameters[3].Value = model.Irrigate_Duration; parameters[4].Value = model.Auto_Irrigate_Enabled; parameters[5].Value = model.Auto_Irrigate_Facility_ID; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public AutoIrrigateConfigEntity GetModel(int Auto_Irrigate_Facility_ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 Trigger_Facility_ID,Auto_Irrigate_Facility_ID,StartOrStop_MSC_ID,State_MSC_ID,Irrigate_Duration,Auto_Irrigate_Enabled from Auto_Irrigate_Config "); strSql.Append(" where Auto_Irrigate_Facility_ID=@Auto_Irrigate_Facility_ID "); SqlParameter[] parameters = { new SqlParameter("@Auto_Irrigate_Facility_ID", SqlDbType.Int, 4) }; parameters[0].Value = Auto_Irrigate_Facility_ID; AutoIrrigateConfigEntity model = new AutoIrrigateConfigEntity(); 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 bool Update(AutoIrrigateConfigEntity model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(AutoIrrigateConfigEntity model) { return(dal.Add(model)); }