protected void btn_save_Click(object sender, EventArgs e) { try { Model.banner model = new Model.banner(); model.banner_id = guid; model.title = this.txttitle.Text.Trim(); model.sortId = Convert.ToInt32(this.txtsort.Text); model.pubdate = DateTime.Now; if (this.UpFile.PostedFile.FileName != "") { if (Upload("Banner", "filetype", UpFile, labimg)) { model.imgurl = "/Upload/Banner/" + guid + Path.GetExtension(this.UpFile.PostedFile.FileName); } else { this.labimg.Text = "图片上传失败,请重试!"; return; } } else { this.labimg.Text = "请选择图片!"; return; } bannerbll.Add(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "提交成功!", ""); } catch { } }
private bool DoAdd() { Model.banner model = new Model.banner(); BLL.banner bll = new BLL.banner(); model.site_path = this.ddlSitePath.SelectedValue; model.title = txtTitle.Text.Trim(); model.href_url = txtHref_url.Text; model.href_target = rblHref_target.SelectedValue; model.bg_color = txtBg_color.Text; model.img_src = txtImgUrl.Text; model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } if (bll.Add(model) > 0) { AddAdminLog(DTEnums.ActionEnum.Add.ToString(), "添加Banner:" + model.title); //记录日志 return(true); } return(false); }
private bool DoEdit(int _id) { bool result = false; BLL.banner bll = new BLL.banner(); Model.banner model = bll.GetModel(_id); model.site_path = this.ddlSitePath.SelectedValue; model.title = txtTitle.Text.Trim(); model.href_url = txtHref_url.Text; model.href_target = rblHref_target.SelectedValue; model.bg_color = txtBg_color.Text; model.img_src = txtImgUrl.Text; model.sort_id = Utils.StrToInt(txtSortId.Text.Trim(), 99); if (cbIsLock.Checked == true) { model.is_lock = 0; } else { model.is_lock = 1; } if (bll.Update(model)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "修改Banner:" + model.title); //记录日志 result = true; } return(result); }
private void BindData(string banner_id) { if (banner_id != "") { Model.banner model = bannerbll.GetModel(banner_id); if (model != null) { this.txttitle.Text = model.title; this.txtsort.Text = model.sortId.ToString(); ViewState["imgurl"] = model.imgurl; } } }
protected void rptBanner_ItemCommand(object source, RepeaterCommandEventArgs e) { HiddenField hidid = (HiddenField)e.Item.FindControl("hidid"); string banner_id = hidid.Value; if (e.CommandName == "delete") { Model.banner model = bannerbll.GetModel(banner_id); if (model != null) { File.Delete(Server.MapPath(model.imgurl)); } bannerbll.Delete(banner_id); } buildGrid(pageSize, Pager.CurrentPageIndex); }
private void ShowInfo(int _id) { BLL.banner bll = new BLL.banner(); Model.banner model = bll.GetModel(_id); this.ddlSitePath.SelectedValue = model.site_path; txtTitle.Text = model.title; txtHref_url.Text = model.href_url; rblHref_target.SelectedValue = model.href_target; txtBg_color.Text = model.bg_color; txtSortId.Text = model.sort_id.ToString(); if (model.is_lock == 0) { cbIsLock.Checked = true; } else { cbIsLock.Checked = false; } this.txtImgUrl.Text = model.img_src; }
protected void btn_save_Click(object sender, EventArgs e) { try { Model.banner model = new Model.banner(); if (!string.IsNullOrEmpty(Request.QueryString["banner_id"].ToString())) { string banner_id = Request.QueryString["banner_id"].ToString(); model.banner_id = banner_id; model.title = this.txttitle.Text.Trim(); model.sortId = Convert.ToInt32(this.txtsort.Text); model.pubdate = DateTime.Now; if (this.UpFile.PostedFile.FileName != "") { if (Upload("Banner", "filetype", UpFile, labimg)) { File.Delete(Server.MapPath(ViewState["imgurl"].ToString())); model.imgurl = "/Upload/Banner/" + guid + Path.GetExtension(this.UpFile.PostedFile.FileName); ViewState["imgurl"] = model.imgurl; } else { this.labimg.Text = "图片上传失败,请重试!"; return; } } else { model.imgurl = ViewState["imgurl"].ToString(); } bannerbll.Update(model); Maticsoft.Common.MessageBox.ShowAndRedirect(this, "提交成功!", ""); } } catch { } }