protected void Page_Load(object sender, EventArgs e) { if (null != Common.Common.NoHtml(Request.QueryString["action"])) { strAction = Common.Common.NoHtml(Request.QueryString["action"]); } if (null != Common.Common.NoHtml(Request.QueryString["id"])) { strID = Common.Common.NoHtml(Request.QueryString["id"]); } AlbumTypeDAL dal = new AlbumTypeDAL(); int statein = 0; try { statein = Convert.ToInt32(dal.GetAlbumTypeValue("IsDel", strID)); } catch (Exception) { statein = 0; } switch (statein) { case 0: statein = 1; break; default: statein = 0; break; } PA_AlbumType model = new PA_AlbumType(); model.ID = strID; model.IsDel = statein; switch (strAction) { case "del": if (dal.UpdateAlbumType(model)) { strMessage = "操作成功!"; } else { strMessage = "操作失败!"; } break; default: break; } Response.Write(strMessage); Response.End(); }
/// <summary> /// 加载数据 /// </summary> /// <param name="strWhere">条件</param> void LoadData(string strWhere) { txtTitle.Text = ""; AlbumTypeDAL dal = new AlbumTypeDAL(); DataSet ds = dal.GetAlbumTypeBySiteCode(strWhere); DataView dv = ds.Tables[0].DefaultView; AspNetPager1.RecordCount = dv.Count; PagedDataSource pds = new PagedDataSource(); pds.DataSource = dv; pds.AllowPaging = true; pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1; pds.PageSize = AspNetPager1.PageSize; Repeater1.DataSource = pds; Repeater1.DataBind(); }
/// <summary> /// 页面加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(Session["strSiteCode"].ToString()) && Session["strRoleCode"].ToString() != "ADMIN") { Response.Write("<script language=JavaScript>parent.location.href='../Index.aspx';</script>"); Response.End(); } if (!IsPostBack) { #region 初始化界面 this.ddlAlbumType.Items.Clear(); AlbumTypeDAL dal = new AlbumTypeDAL(); DataSet ds = new DataSet(); if (GlobalSession.strRoleCode == "ADMIN") { ds = dal.GetAlbumTypeByIsDel(""); } else { ds = dal.GetAlbumTypeByIsDel(" SiteCode ='" + Session["strSiteCode"].ToString() + "' "); } DataTable dt = ds.Tables[0]; DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = "0"; dr["Name"] = "请选择相关类别"; dt.Rows.InsertAt(dr, 0); this.ddlAlbumType.DataSource = ds.Tables[0].DefaultView; this.ddlAlbumType.DataTextField = "Name"; this.ddlAlbumType.DataValueField = "ID"; this.ddlAlbumType.DataBind(); if (null != Common.Common.NoHtml(Request.QueryString["action"])) { strAction = Common.Common.NoHtml(Request.QueryString["action"]); } if (null != Common.Common.NoHtml(Request.QueryString["id"])) { strID = Common.Common.NoHtml(Request.QueryString["id"]); } #endregion } }
public void ShowArticleInfo(string strID) { AlbumTypeDAL dal = new AlbumTypeDAL(); DataSet ds = dal.GetAlbumTypeDetail(strID); PA_AlbumType model = DataConvert.DataRowToModel <PA_AlbumType>(ds.Tables[0].Rows[0]); this.hd_content.Value = model.Content; this.AlbumTypeName.Text = model.Name; this.img0.Src = "../../" + model.Cover; if (model.IsDel == 0) { isstateyes.Checked = true; } else { isstateno.Checked = true; } if (strAction == "show") { this.btnReset.Visible = false; this.btnSave.Visible = false; } }
const string vsKey = "searchCriteria"; //ViewState key /// <summary> /// 页面加载事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ddlCategory.Items.Clear(); AlbumTypeDAL dal = new AlbumTypeDAL(); DataSet ds = new DataSet(); if (Session["strRoleCode"].ToString() == "ADMIN") { ds = dal.GetAlbumTypeByIsDel(""); } else { ds = dal.GetAlbumTypeByIsDel(" SiteCode ='" + Session["strSiteCode"].ToString() + "' "); } DataTable dt = ds.Tables[0]; DataRow dr = ds.Tables[0].NewRow(); dr["ID"] = "0"; dr["Name"] = "--全部--"; dt.Rows.InsertAt(dr, 0); this.ddlCategory.DataSource = ds.Tables[0].DefaultView; this.ddlCategory.DataTextField = "Name"; this.ddlCategory.DataValueField = "ID"; this.ddlCategory.DataBind(); AspNetPager1.CurrentPageIndex = 1; string s = ""; if (Session["strRoleCode"].ToString() != "ADMIN") { s = " b.SiteCode = '" + Session["strSiteCode"].ToString() + "' "; } ViewState[vsKey] = s; LoadData(s); } }
/// <summary> /// 单击"保存"按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnSave_Click(object sender, EventArgs e) { if (null == Session["strSiteName"] || null == Session["strSiteCode"] || null == Session["strLoginName"]) { Response.Write("<script language=JavaScript>;parent.location.href='../Index.aspx';</script>"); Response.End(); } //上传封面图像 string strIconFileName = string.Empty; //封面图像路径 string strIconSaveFileName = string.Empty; //网址路径 try { if (this.file0.PostedFile.FileName == "") { strIconSaveFileName = ""; } else { if (!System.IO.Directory.Exists(Server.MapPath("~") + @"/Images")) { System.IO.Directory.CreateDirectory(Server.MapPath("~") + @"/Images"); } if (!System.IO.Directory.Exists(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString()))) { System.IO.Directory.CreateDirectory(String.Format(@"{0}/Images/{1}", Server.MapPath("~"), Session["strSiteCode"].ToString())); } string orignalName = this.file0.PostedFile.FileName; //获取客户机上传文件的文件名 string extendName = orignalName.Substring(orignalName.LastIndexOf(".")); //获取扩展名 if (extendName != ".gif" && extendName != ".jpg" && extendName != ".jpeg" && extendName != ".png") { MessageBox.Show(this, "文件格式有误!"); return; }//检查文件格式 string newName = String.Format("{0}_{1}{2}", DateTime.Now.Millisecond, file0.PostedFile.ContentLength, extendName);//对文件进行重命名 strIconFileName = String.Format(@"{0}Images/{1}/{2}", Server.MapPath("~"), Session["strSiteCode"].ToString(), newName); strIconSaveFileName = String.Format(@"Images/{0}/{1}", Session["strSiteCode"].ToString(), newName); file0.PostedFile.SaveAs(strIconFileName); } } catch (Exception ex) { MessageBox.Show(this, "上传发生错误!原因是:" + ex.ToString()); } AlbumTypeDAL dal = new AlbumTypeDAL(); PA_AlbumType model = new PA_AlbumType(); if (AlbumTypeName.Text.Trim() != null && AlbumTypeName.Text.Trim() != "") { model.Name = AlbumTypeName.Text; model.Content = hd_content.Value; model.Cover = strIconSaveFileName; model.SiteCode = Session["strSiteCode"].ToString(); model.ID = strID; model.IsDel = isstateyes.Checked ? 0 : 1; if (dal.UpdateAlbumType(model)) { MessageBox.Show(this, "修改成功!"); } else { MessageBox.Show(this, "修改失败!"); } } else { MessageBox.Show(this, "请输入相应标题名称!"); } }