/// <summary> /// 得到一个对象实体 /// </summary> public Model.advert_banner GetModel(int id) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); Model.advert_banner model = new Model.advert_banner(); //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); foreach (PropertyInfo p in pros) { str1.Append(p.Name + ",");//拼接字段 } strSql.Append("select top 1 " + str1.ToString().Trim(',')); strSql.Append(" from " + databaseprefix + "advert_banner"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; DataTable dt = DbHelperSQL.Query(strSql.ToString(), parameters).Tables[0]; if (dt.Rows.Count > 0) { return(DataRowToModel(dt.Rows[0])); } else { return(null); } }
private bool DoAdd() { bool result = false; Model.advert_banner model = new Model.advert_banner(); BLL.advert_banner bll = new BLL.advert_banner(); model.aid = int.Parse(ddlAdvertId.SelectedValue); model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.file_path = txtFilePath.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); model.add_time = DateTime.Now; this.aid = model.aid; if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加广告内容:" + model.title); //记录日志 result = true; } return(result); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.advert_banner model) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); List <SqlParameter> paras = new List <SqlParameter>(); strSql.Append("update " + databaseprefix + "advert_banner set "); foreach (PropertyInfo pi in pros) { //如果不是主键则追加sql字符串 if (!pi.Name.Equals("id")) { //判断属性值是否为空 if (pi.GetValue(model, null) != null) { str1.Append(pi.Name + "=@" + pi.Name + ","); //声明参数 paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值 } } } strSql.Append(str1.ToString().Trim(',')); strSql.Append(" where id=@id "); paras.Add(new SqlParameter("@id", model.id)); return(DbHelperSQL.ExecuteSql(strSql.ToString(), paras.ToArray()) > 0); }
/// <summary> /// 组合成对象实体 /// </summary> private Model.advert_banner DataRowToModel(DataRow row) { Model.advert_banner model = new Model.advert_banner(); if (row != null) { if (row["id"].ToString() != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["aid"].ToString() != null && row["aid"].ToString() != "") { model.aid = int.Parse(row["aid"].ToString()); } if (row["title"].ToString() != "") { model.title = row["title"].ToString(); } if (row["start_time"].ToString() != null && row["start_time"].ToString() != "") { model.start_time = DateTime.Parse(row["start_time"].ToString()); } if (row["end_time"].ToString() != null && row["end_time"].ToString() != "") { model.end_time = DateTime.Parse(row["end_time"].ToString()); } if (row["file_path"].ToString() != "") { model.file_path = row["file_path"].ToString(); } if (row["link_url"].ToString() != "") { model.link_url = row["link_url"].ToString(); } if (row["content"].ToString() != "") { model.content = row["content"].ToString(); } if (row["target"].ToString() != "") { model.target = row["target"].ToString(); } if (row["sort_id"].ToString() != null && row["sort_id"].ToString() != "") { model.sort_id = int.Parse(row["sort_id"].ToString()); } if (row["is_lock"].ToString() != null && row["is_lock"].ToString() != "") { model.is_lock = int.Parse(row["is_lock"].ToString()); } if (row["add_time"].ToString() != null && row["add_time"].ToString() != "") { model.add_time = DateTime.Parse(row["add_time"].ToString()); } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.advert_banner model) { int newId; using (OleDbConnection conn = new OleDbConnection(DbHelperOleDb.connectionString)) { conn.Open(); using (OleDbTransaction trans = conn.BeginTransaction()) { try { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "advert_banner("); strSql.Append("aid,title,start_time,end_time,file_path,link_url,content,sort_id,is_lock,add_time)"); strSql.Append(" values ("); strSql.Append("@aid,@title,@start_time,@end_time,@file_path,@link_url,@content,@sort_id,@is_lock,@add_time)"); OleDbParameter[] parameters = { new OleDbParameter("@aid", OleDbType.Integer, 4), new OleDbParameter("@title", OleDbType.VarChar, 100), new OleDbParameter("@start_time", OleDbType.Date), new OleDbParameter("@end_time", OleDbType.Date), new OleDbParameter("@file_path", OleDbType.VarChar, 255), new OleDbParameter("@link_url", OleDbType.VarChar, 255), new OleDbParameter("@content", OleDbType.VarChar), new OleDbParameter("@sort_id", OleDbType.Integer, 4), new OleDbParameter("@is_lock", OleDbType.Integer, 4), new OleDbParameter("@add_time", OleDbType.Date) }; parameters[0].Value = model.aid; parameters[1].Value = model.title; parameters[2].Value = model.start_time; parameters[3].Value = model.end_time; parameters[4].Value = model.file_path; parameters[5].Value = model.link_url; parameters[6].Value = model.content; parameters[7].Value = model.sort_id; parameters[8].Value = model.is_lock; parameters[9].Value = model.add_time; DbHelperOleDb.ExecuteSql(conn, trans, strSql.ToString(), parameters); //取得新插入的ID newId = GetMaxId(conn, trans); trans.Commit(); } catch { trans.Rollback(); return(-1); } } } return(newId); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.advert_banner model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update " + databaseprefix + "advert_banner set "); strSql.Append("aid=@aid,"); strSql.Append("title=@title,"); strSql.Append("start_time=@start_time,"); strSql.Append("end_time=@end_time,"); strSql.Append("file_path=@file_path,"); strSql.Append("link_url=@link_url,"); strSql.Append("content=@content,"); strSql.Append("sort_id=@sort_id,"); strSql.Append("is_lock=@is_lock,"); strSql.Append("add_time=@add_time"); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@aid", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@start_time", SqlDbType.DateTime), new SqlParameter("@end_time", SqlDbType.DateTime), new SqlParameter("@file_path", SqlDbType.NVarChar, 255), new SqlParameter("@link_url", SqlDbType.NVarChar, 255), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime), new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = model.aid; parameters[1].Value = model.title; parameters[2].Value = model.start_time; parameters[3].Value = model.end_time; parameters[4].Value = model.file_path; parameters[5].Value = model.link_url; parameters[6].Value = model.content; parameters[7].Value = model.sort_id; parameters[8].Value = model.is_lock; parameters[9].Value = model.add_time; parameters[10].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
private void ShowInfo(int _id) { BLL.advert_banner bll = new BLL.advert_banner(); Model.advert_banner model = bll.GetModel(_id); this.aid = model.aid; this.LitTitle.Text = new BLL.advert().GetTitle(this.aid); this.txtTitle.Text = model.title; this.cbIsLock.Checked = model.is_lock == 0; this.txtSortId.Text = model.sort_id.ToString(); this.txtLinkUrl.Text = model.link_url; this.txtImgUrl.Text = model.file_path; this.txtContent.Text = model.content; }
private void ShowInfo(int _id) { BLL.advert_banner bll = new BLL.advert_banner(); Model.advert_banner model = bll.GetModel(_id); this.aid = model.aid; ddlAdvertId.SelectedValue = model.aid.ToString(); txtTitle.Text = model.title; rblIsLock.SelectedValue = model.is_lock.ToString(); txtSortId.Text = model.sort_id.ToString(); txtStartTime.Text = model.start_time.ToString("yyyy-MM-dd"); txtEndTime.Text = model.end_time.ToString("yyyy-MM-dd"); txtLinkUrl.Text = model.link_url; txtFilePath.Text = model.file_path; txtContent.Text = model.content; }
private bool DoEdit(int _id) { bool result = false; BLL.advert_banner bll = new BLL.advert_banner(); Model.advert_banner model = bll.GetModel(_id); model.aid = int.Parse(ddlAdvertId.SelectedValue); model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.link_url = txtLinkUrl.Text.Trim(); model.target = rblTarget.SelectedValue; model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); this.aid = model.aid; //判断上传图片 if (this.imgUpload.HasFile) { //上传前先删除原图片 if (!string.IsNullOrEmpty(model.file_path)) { Utils.DeleteFile(model.file_path); } DTcms.Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false); if (upfile.status > 0) { model.file_path = upfile.path; } } else { //判断是否需要删除原图 if (txtFilePath.Text.Trim() == "" && !string.IsNullOrEmpty(model.file_path)) { Utils.DeleteFile(model.file_path); } model.file_path = txtFilePath.Text.Trim(); } if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改广告内容:" + model.title); //记录日志 result = true; } return(result); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.advert_banner model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into " + databaseprefix + "advert_banner("); strSql.Append("aid,title,start_time,end_time,file_path,link_url,content,sort_id,is_lock,add_time)"); strSql.Append(" values ("); strSql.Append("@aid,@title,@start_time,@end_time,@file_path,@link_url,@content,@sort_id,@is_lock,@add_time)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@aid", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.NVarChar, 100), new SqlParameter("@start_time", SqlDbType.DateTime), new SqlParameter("@end_time", SqlDbType.DateTime), new SqlParameter("@file_path", SqlDbType.NVarChar, 255), new SqlParameter("@link_url", SqlDbType.NVarChar, 255), new SqlParameter("@content", SqlDbType.NText), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@is_lock", SqlDbType.TinyInt, 1), new SqlParameter("@add_time", SqlDbType.DateTime) }; parameters[0].Value = model.aid; parameters[1].Value = model.title; parameters[2].Value = model.start_time; parameters[3].Value = model.end_time; parameters[4].Value = model.file_path; parameters[5].Value = model.link_url; parameters[6].Value = model.content; parameters[7].Value = model.sort_id; parameters[8].Value = model.is_lock; parameters[9].Value = model.add_time; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 将对象转换实体 /// </summary> public Model.advert_banner DataRowToModel(DataRow row) { Model.advert_banner model = new Model.advert_banner(); if (row != null) { //利用反射获得属性的所有公共属性 Type modelType = model.GetType(); for (int i = 0; i < row.Table.Columns.Count; i++) { //查找实体是否存在列表相同的公共属性 PropertyInfo proInfo = modelType.GetProperty(row.Table.Columns[i].ColumnName); if (proInfo != null && row[i] != DBNull.Value) { proInfo.SetValue(model, row[i], null);//用索引值设置属性值 } } } return(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.advert_banner model) { StringBuilder strSql = new StringBuilder(); StringBuilder str1 = new StringBuilder(); //数据字段 StringBuilder str2 = new StringBuilder(); //数据参数 //利用反射获得属性的所有公共属性 PropertyInfo[] pros = model.GetType().GetProperties(); List <SqlParameter> paras = new List <SqlParameter>(); strSql.Append("insert into " + databaseprefix + "advert_banner("); foreach (PropertyInfo pi in pros) { //如果不是主键则追加sql字符串 if (!pi.Name.Equals("id")) { //判断属性值是否为空 if (pi.GetValue(model, null) != null) { str1.Append(pi.Name + ","); //拼接字段 str2.Append("@" + pi.Name + ","); //声明参数 paras.Add(new SqlParameter("@" + pi.Name, pi.GetValue(model, null))); //对参数赋值 } } } strSql.Append(str1.ToString().Trim(',')); strSql.Append(") values ("); strSql.Append(str2.ToString().Trim(',')); strSql.Append(") "); strSql.Append(";select @@IDENTITY;"); object obj = DbHelperSQL.GetSingle(strSql.ToString(), paras.ToArray()); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
private bool DoEdit(int _id) { bool result = false; BLL.advert_banner bll = new BLL.advert_banner(); Model.advert_banner model = bll.GetModel(_id); this.aid = model.aid; model.title = this.txtTitle.Text.Trim(); model.file_path = this.txtImgUrl.Text.Trim(); model.link_url = this.txtLinkUrl.Text.Trim(); model.content = this.txtContent.Text; model.sort_id = int.Parse(this.txtSortId.Text.Trim()); model.is_lock = this.cbIsLock.Checked ? 0 : 1; if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改广告内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoAdd() { Model.advert_banner model = new Model.advert_banner(); BLL.advert_banner bll = new BLL.advert_banner(); model.aid = this.aid; model.title = this.txtTitle.Text.Trim(); model.file_path = this.txtImgUrl.Text.Trim(); model.link_url = this.txtLinkUrl.Text.Trim(); model.content = this.txtContent.Text; model.sort_id = int.Parse(this.txtSortId.Text.Trim()); model.is_lock = this.cbIsLock.Checked ? 0 : 1; model.start_time = DateTime.Now; model.end_time = DateTime.Now.AddYears(100); model.add_time = DateTime.Now; if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加广告内容:" + model.title); //记录日志 return(true); } return(false); }
private bool DoAdd() { bool result = false; Model.advert_banner model = new Model.advert_banner(); BLL.advert_banner bll = new BLL.advert_banner(); model.aid = int.Parse(ddlAdvertId.SelectedValue); model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.target = rblTarget.SelectedValue; model.link_url = txtLinkUrl.Text.Trim(); model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); model.add_time = DateTime.Now; this.aid = model.aid; //判断上传图片 if (this.imgUpload.HasFile) { DTcms.Model.upLoad upfile = new Web.UI.UpLoad().fileSaveAs(this.imgUpload.PostedFile, 0, false, false); if (upfile.status > 0) { model.file_path = upfile.path; } } else { model.file_path = txtFilePath.Text.Trim(); } if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加广告内容:" + model.title); //记录日志 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = true; BLL.advert_banner bll = new BLL.advert_banner(); Model.advert_banner model = bll.GetModel(_id); this.aid = model.aid; model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.file_path = txtFilePath.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); if (!bll.Update(model)) { result = false; } return(result); }
private bool DoAdd() { bool result = true; Model.advert_banner model = new Model.advert_banner(); BLL.advert_banner bll = new BLL.advert_banner(); model.aid = this.aid; model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.file_path = txtFilePath.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); model.add_time = DateTime.Now; if (bll.Add(model) < 1) { result = false; } return(result); }
private void ShowInfo(int _id) { BLL.advert_banner bll = new BLL.advert_banner(); Model.advert_banner model = bll.GetModel(_id); this.aid = model.aid; ddlAdvertId.SelectedValue = model.aid.ToString(); txtTitle.Text = model.title; rblIsLock.SelectedValue = model.is_lock.ToString(); txtSortId.Text = model.sort_id.ToString(); txtStartTime.Text = model.start_time.ToString("yyyy-MM-dd"); txtEndTime.Text = model.end_time.ToString("yyyy-MM-dd"); rblTarget.SelectedValue = model.target; txtLinkUrl.Text = model.link_url; txtContent.Text = model.content; //图片 txtFilePath.Text = model.file_path; //判断是否是图片 if (!string.IsNullOrEmpty(model.file_path) && Utils.IsImage(Utils.GetFileExt(model.file_path))) { ImgDiv.Visible = true; ImgUrl.ImageUrl = model.file_path; } }
private bool DoAdd() { bool result = true; Model.advert_banner model = new Model.advert_banner(); BLL.advert_banner bll = new BLL.advert_banner(); model.aid = this.aid; model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.file_path = txtFilePath.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); model.add_time = DateTime.Now; if (bll.Add(model) < 1) { result = false; } return result; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.advert_banner GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,aid,title,start_time,end_time,file_path,link_url,content,sort_id,is_lock,add_time from " + databaseprefix + "advert_banner "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int, 4) }; parameters[0].Value = id; Model.advert_banner model = new Model.advert_banner(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["aid"] != null && ds.Tables[0].Rows[0]["aid"].ToString() != "") { model.aid = int.Parse(ds.Tables[0].Rows[0]["aid"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["start_time"] != null && ds.Tables[0].Rows[0]["start_time"].ToString() != "") { model.start_time = DateTime.Parse(ds.Tables[0].Rows[0]["start_time"].ToString()); } if (ds.Tables[0].Rows[0]["end_time"] != null && ds.Tables[0].Rows[0]["end_time"].ToString() != "") { model.end_time = DateTime.Parse(ds.Tables[0].Rows[0]["end_time"].ToString()); } if (ds.Tables[0].Rows[0]["file_path"] != null && ds.Tables[0].Rows[0]["file_path"].ToString() != "") { model.file_path = ds.Tables[0].Rows[0]["file_path"].ToString(); } if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "") { model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return(model); } else { return(null); } }
/// <summary> /// �õ�һ������ʵ�� /// </summary> public Model.advert_banner GetModel(int id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,aid,title,start_time,end_time,file_path,link_url,content,sort_id,is_lock,add_time from " + databaseprefix + "advertbanners "); strSql.Append(" where id=@id"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.Int,4)}; parameters[0].Value = id; Model.advert_banner model = new Model.advert_banner(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["id"] != null && ds.Tables[0].Rows[0]["id"].ToString() != "") { model.id = int.Parse(ds.Tables[0].Rows[0]["id"].ToString()); } if (ds.Tables[0].Rows[0]["aid"] != null && ds.Tables[0].Rows[0]["aid"].ToString() != "") { model.aid = int.Parse(ds.Tables[0].Rows[0]["aid"].ToString()); } if (ds.Tables[0].Rows[0]["title"] != null && ds.Tables[0].Rows[0]["title"].ToString() != "") { model.title = ds.Tables[0].Rows[0]["title"].ToString(); } if (ds.Tables[0].Rows[0]["start_time"] != null && ds.Tables[0].Rows[0]["start_time"].ToString() != "") { model.start_time = DateTime.Parse(ds.Tables[0].Rows[0]["start_time"].ToString()); } if (ds.Tables[0].Rows[0]["end_time"] != null && ds.Tables[0].Rows[0]["end_time"].ToString() != "") { model.end_time = DateTime.Parse(ds.Tables[0].Rows[0]["end_time"].ToString()); } if (ds.Tables[0].Rows[0]["file_path"] != null && ds.Tables[0].Rows[0]["file_path"].ToString() != "") { model.file_path = ds.Tables[0].Rows[0]["file_path"].ToString(); } if (ds.Tables[0].Rows[0]["link_url"] != null && ds.Tables[0].Rows[0]["link_url"].ToString() != "") { model.link_url = ds.Tables[0].Rows[0]["link_url"].ToString(); } if (ds.Tables[0].Rows[0]["content"] != null && ds.Tables[0].Rows[0]["content"].ToString() != "") { model.content = ds.Tables[0].Rows[0]["content"].ToString(); } if (ds.Tables[0].Rows[0]["sort_id"] != null && ds.Tables[0].Rows[0]["sort_id"].ToString() != "") { model.sort_id = int.Parse(ds.Tables[0].Rows[0]["sort_id"].ToString()); } if (ds.Tables[0].Rows[0]["is_lock"] != null && ds.Tables[0].Rows[0]["is_lock"].ToString() != "") { model.is_lock = int.Parse(ds.Tables[0].Rows[0]["is_lock"].ToString()); } if (ds.Tables[0].Rows[0]["add_time"] != null && ds.Tables[0].Rows[0]["add_time"].ToString() != "") { model.add_time = DateTime.Parse(ds.Tables[0].Rows[0]["add_time"].ToString()); } return model; } else { return null; } }
private bool DoAdd() { bool result = false; Model.advert_banner model = new Model.advert_banner(); BLL.advert_banner bll = new BLL.advert_banner(); model.aid = int.Parse(ddlAdvertId.SelectedValue); model.title = txtTitle.Text.Trim(); model.start_time = DateTime.Parse(this.txtStartTime.Text.Trim()); model.end_time = DateTime.Parse(this.txtEndTime.Text.Trim()); model.file_path = txtFilePath.Text.Trim(); model.link_url = txtLinkUrl.Text.Trim(); model.content = txtContent.Text; model.sort_id = int.Parse(txtSortId.Text.Trim()); model.is_lock = int.Parse(rblIsLock.SelectedValue); model.add_time = DateTime.Now; this.aid = model.aid; if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加广告内容:" + model.title); //记录日志 result = true; } return result; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.advert_banner model) { return(dal.Add(model)); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.advert_banner model) { return(dal.Update(model)); }