/// <summary> /// 更新一条数据 /// </summary> public bool Update(DBCommon.Model.DBBranchAction model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update BranchActionInfo set "); strSql.Append("BeginTime=@BeginTime,"); strSql.Append("EndTime=@EndTime,"); strSql.Append("Title=@Title,"); strSql.Append("BranchID=@BranchID,"); strSql.Append("PointID=@PointID,"); strSql.Append("QrCode=@QrCode"); strSql.Append(" where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@BeginTime", DbType.DateTime), new SQLiteParameter("@EndTime", DbType.DateTime), new SQLiteParameter("@Title", DbType.String), new SQLiteParameter("@BranchID", DbType.String), new SQLiteParameter("@PointID", DbType.String), new SQLiteParameter("@QrCode", DbType.String), new SQLiteParameter("@ID", DbType.String) }; parameters[0].Value = model.BeginTime; parameters[1].Value = model.EndTime; parameters[2].Value = model.Title; parameters[3].Value = model.BranchID; parameters[4].Value = model.PointID; parameters[5].Value = model.QrCode; parameters[6].Value = model.ID; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(DBCommon.Model.DBBranchAction model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into BranchActionInfo("); strSql.Append("ID,BeginTime,EndTime,Title,BranchID,PointID,QrCode)"); strSql.Append(" values ("); strSql.Append("@ID,@BeginTime,@EndTime,@Title,@BranchID,@PointID,@QrCode)"); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.String), new SQLiteParameter("@BeginTime", DbType.DateTime), new SQLiteParameter("@EndTime", DbType.DateTime), new SQLiteParameter("@Title", DbType.String), new SQLiteParameter("@BranchID", DbType.String), new SQLiteParameter("@PointID", DbType.String), new SQLiteParameter("@QrCode", DbType.String) }; parameters[0].Value = model.ID; parameters[1].Value = model.BeginTime; parameters[2].Value = model.EndTime; parameters[3].Value = model.Title; parameters[4].Value = model.BranchID; parameters[5].Value = model.PointID; parameters[6].Value = model.QrCode; int rows = DbHelperSQLite.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public DBCommon.Model.DBBranchAction DataRowToModel(DataRow row) { DBCommon.Model.DBBranchAction model = new DBCommon.Model.DBBranchAction(); if (row != null) { if (row["ID"] != null) { model.ID = row["ID"].ToString(); } if (row["BeginTime"] != null && row["BeginTime"].ToString() != "") { model.BeginTime = DateTime.Parse(row["BeginTime"].ToString()); } if (row["EndTime"] != null && row["EndTime"].ToString() != "") { model.EndTime = DateTime.Parse(row["EndTime"].ToString()); } if (row["Title"] != null) { model.Title = row["Title"].ToString(); } if (row["BranchID"] != null) { model.BranchID = row["BranchID"].ToString(); } if (row["PointID"] != null) { model.PointID = row["PointID"].ToString(); } if (row["QrCode"] != null) { model.QrCode = row["QrCode"].ToString(); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public DBCommon.Model.DBBranchAction GetModel(string ID) { StringBuilder strSql = new StringBuilder(); strSql.Append("select ID,BeginTime,EndTime,Title,BranchID,PointID,QrCode from BranchActionInfo "); strSql.Append(" where ID=@ID "); SQLiteParameter[] parameters = { new SQLiteParameter("@ID", DbType.String) }; parameters[0].Value = ID; DBCommon.Model.DBBranchAction model = new DBCommon.Model.DBBranchAction(); DataSet ds = DbHelperSQLite.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }