using System; using System.Data; using System.Text; using System.Data.SqlClient; namespace Mtxfw.DAL { /// /// 数据访问类:city /// public partial class timer_control : Mtxfw.Utility.Myabstract { public timer_control() : base("timer_control") { } /// /// /// 更新一条数据 /// public bool UpdateZXflag(string ZXSel, int ZXflag, DateTime ZXflagTime, int gtype) { StringBuilder strSql = new StringBuilder(); strSql.Append("update timer_control set "); strSql.Append(ZXSel + "=@ZXflag,"); strSql.Append(ZXSel + "_Time" + "=@ZXflagTime"); strSql.Append(" where gtype=@gtype"); SqlParameter[] parameters = { new SqlParameter("@ZXflag", SqlDbType.Int), new SqlParameter("@ZXflagTime", SqlDbType.DateTime), new SqlParameter("@gtype", SqlDbType.Int)}; parameters[0].Value = ZXflag; parameters[1].Value = ZXflagTime; parameters[2].Value = gtype; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 删除一条数据 /// public bool Delete(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("delete from timer_control "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4) }; parameters[0].Value = id; int rows = Mtxfw.Utility.SqlDbHelper_U.ExecuteCmd(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// /// 获得数据列表 /// public int GetZXflag(string selflag,ref DateTime ZXflagTime) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 " + selflag + "," + selflag + "_Time"); strSql.Append(" FROM timer_control a"); int ZXflag = 0; DataSet ds = Mtxfw.Utility.SqlDbHelper_U.GetDataSet(strSql.ToString()); if (ds.Tables[0].Rows.Count > 0) { ZXflag = Convert.ToInt32(ds.Tables[0].Rows[0][selflag]); ZXflagTime = Convert.ToDateTime(ds.Tables[0].Rows[0][selflag+"_Time"]); } ds.Clear(); return ZXflag; } } }