private void SetModel(Web_UserAlbumColumn model) { model.AlbumName = txtAlbumName.Text.Trim(); model.Cover = model.Cover; model.IsPublic = (rdoIsPublic.SelectedIndex == -1) ? Library.PublicState.公开.ToString() : rdoIsPublic.SelectedItem.Value; model.OrderID = model.OrderID; model.UserID = model.UserID; }
protected void Page_Load(object sender, EventArgs e) { if (IntParam == 0) { return; } SeoSetting(SeoConfig.Config.DefaultSeo); Web_UserAlbumColumn album = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == IntParam); if (album == null || album.IsPublic == Library.PublicState.隐藏.ToString()) { return; } TUsers user = DbSession.Default.Get <TUsers>(TUsers._.UserID == album.UserID); if (user == null) { return; } AlbumName = album.AlbumName; UserName = user.NickName; //user.UserName; uid = user.UserID.ToString(); WhereClip where = VUsersAlbum._.ColumnID == IntParam && VUsersAlbum._.Enable == Library.EnableState.通过.ToString(); anpPageIndex.RecordCount = DbSession.Default.Count <VUsersAlbum>(where); anpPageIndex.CurrentPageIndex = PageIndex; //anpPageIndex.PageSize = 4; DataTable dt = DbSession.Default.FromProc("Bzw_GetPager") .AddInputParameter("@QueryStr", DbType.String, "select * from VUsersAlbum where " + string.Format(where.ToString(), "", "")) .AddInputParameter("@PageSize", DbType.Int32, anpPageIndex.PageSize) .AddInputParameter("@PageCurrent", DbType.Int32, PageIndex) .AddInputParameter("@FdShow", DbType.String, "*") .AddInputParameter("@FdOrder", DbType.String, "ShortNum desc,InputTime desc") .ToDataTable(); if (dt.Rows.Count > 0) { rptAlbumColumnList.Visible = true; rptAlbumColumnList.DataSource = dt; rptAlbumColumnList.DataBind(); ltNonData.Visible = false; } else { rptAlbumColumnList.Visible = false; ltNonData.Visible = true; } }
protected void Page_Load(object sender, EventArgs e) { if (!UserLoginInfo.IsLogin) { Response.Redirect("/"); } TUsers model = DbSession.Default.Get <TUsers>(TUsers._.UserName == UserLoginInfo.UserName); if (model == null) { Response.Redirect("/"); } WhereClip where = VUsersAlbum._.UserID == model.UserID; if (ColumnID != 0) { Web_UserAlbumColumn column = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == ColumnID); if (column != null) { where &= VUsersAlbum._.ColumnID == ColumnID; ColumnName = column.AlbumName; } } anpPageIndex.RecordCount = DbSession.Default.Count <VUsersAlbum>(where); anpPageIndex.CurrentPageIndex = PageIndex; anpPageIndex.PageSize = anpPageIndex.PageSize; DataTable dt = DbSession.Default.FromProc("Bzw_GetPager") .AddInputParameter("@QueryStr", DbType.String, "select * from VUsersAlbum where " + string.Format(where.ToString(), "", "")) .AddInputParameter("@PageSize", DbType.Int32, anpPageIndex.PageSize) .AddInputParameter("@PageCurrent", DbType.Int32, PageIndex) .AddInputParameter("@FdShow", DbType.String, "*") .AddInputParameter("@FdOrder", DbType.String, "InputTime desc") .ToDataTable(); //DataTable dt = DbSession.Default.From<Web_UserAlbumColumn>().Where(Web_UserAlbumColumn._.UserID == model.UserID).OrderBy(Web_UserAlbumColumn._.InputTime.Desc).ToDataTable(); if (dt.Rows.Count > 0) { rptAlbumColumnList.DataSource = dt; rptAlbumColumnList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CommonManager.Web.BindListControl(Enum.GetNames(typeof(Library.PublicState)), rdoIsPublic); } string tmp = CommonManager.Web.Request("params", ""); if (!string.IsNullOrEmpty(tmp) && CommonManager.String.IsInteger(tmp)) { Web_UserAlbumColumn album = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == tmp && Web_UserAlbumColumn._.UserID == UserLoginInfo.UserID); if (album != null && !IsPostBack) { txtAlbumName.Text = album.AlbumName; CommonManager.Web.SetListControlSelectedFromValue(rdoIsPublic, album.IsPublic); btnSubmit.Text = "修改相册"; } } }
/// <summary> /// 删除一个相册封面 /// </summary> private void DelAlbumCover() { if (!UserLoginInfo.IsLogin) { Response.Write("您尚未登录。"); return; } TUsers model = DbSession.Default.Get <TUsers>(TUsers._.UserName == UserLoginInfo.UserName); if (model == null) { Response.Write("您尚未登录。"); return; } string tmp = CommonManager.Web.Request("id", ""); if (string.IsNullOrEmpty(tmp) || !CommonManager.String.IsInteger(tmp) || !DbSession.Default.Exists <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == tmp)) { Response.Write("非法操作。"); return; } Web_UserAlbumColumn album = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == tmp); if (album == null) { Response.Write("非法操作。"); return; } CommonManager.File.DeleteFile(album.Cover); DbSession.Default.Update <Web_UserAlbumColumn>(Web_UserAlbumColumn._.Cover, "", Web_UserAlbumColumn._.ID == tmp); Response.Write("success"); }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!IsValid) { return; } if (!CommonManager.Web.CheckPostSource()) { return; } string tmp = CommonManager.Web.Request("params", ""); Web_UserAlbumColumn album; if (!string.IsNullOrEmpty(tmp) && CommonManager.String.IsInteger(tmp)) { //修改 album = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == tmp && Web_UserAlbumColumn._.UserID == UserLoginInfo.UserID); if (album == null) { return; } album.Attach(); SetModel(album); } else { //新建 album = new Web_UserAlbumColumn(); album.InputTime = DateTime.Now; album.OrderID = 0; album.Cover = ""; album.UserID = int.Parse(UserLoginInfo.UserID); SetModel(album); } DbSession.Default.Save <Web_UserAlbumColumn>(album); CommonManager.Web.ResponseEnd("Album.aspx", true); }
/// <summary> /// 设置某张照片为相册封面 /// </summary> private void SetToCover() { if (!UserLoginInfo.IsLogin) { Response.Write("请先登录。"); return; } TUsers user = DbSession.Default.Get <TUsers>(TUsers._.UserID == UserLoginInfo.UserID); if (user == null) { Response.Write("请先登录。"); return; } string aid = CommonManager.Web.Request("id", ""); if (string.IsNullOrEmpty(aid) || !CommonManager.String.IsInteger(aid)) { Response.Write("请不要尝试非法操作。"); return; } Web_UserAlbum pic = DbSession.Default.Get <Web_UserAlbum>(Web_UserAlbum._.ID == aid && Web_UserAlbum._.UserID == user.UserID); if (pic == null) { Response.Write("请不要尝试非法操作。"); return; } Web_UserAlbumColumn column = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == pic.ColumnID); column.Cover = pic.PicPath; column.Attach(); DbSession.Default.Save <Web_UserAlbumColumn>(column); Response.Write("success"); }
/// <summary> /// 设置某个相册排序数字最大 /// </summary> private void SetAlbumTop() { if (!UserLoginInfo.IsLogin) { Response.Write("请先登录。"); return; } TUsers user = DbSession.Default.Get <TUsers>(TUsers._.UserID == UserLoginInfo.UserID); if (user == null) { Response.Write("请先登录。"); return; } string aid = CommonManager.Web.Request("id", ""); if (string.IsNullOrEmpty(aid) || !CommonManager.String.IsInteger(aid)) { Response.Write("请不要尝试非法操作。"); return; } Web_UserAlbumColumn column = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == aid && Web_UserAlbumColumn._.UserID == user.UserID); if (column == null) { Response.Write("请不要尝试非法操作。"); return; } int max = (int)DbSession.Default.Max <Web_UserAlbumColumn>(Web_UserAlbumColumn._.OrderID, Web_UserAlbumColumn._.UserID == UserLoginInfo.UserID); column.OrderID = max + 1; column.Attach(); DbSession.Default.Save <Web_UserAlbumColumn>(column); Response.Write("success"); }
private void SetModel(Web_UserAlbumColumn model) { model.AlbumName = txtAlbumName.Text.Trim(); model.Cover = model.Cover; model.IsPublic = (rdoIsPublic.SelectedIndex == -1) ? Library.PublicState.����.ToString() : rdoIsPublic.SelectedItem.Value; model.OrderID = model.OrderID; model.UserID = model.UserID; }
protected void btnSubmit_Click(object sender, EventArgs e) { if (!IsValid) return; if (!CommonManager.Web.CheckPostSource()) return; string tmp = CommonManager.Web.Request("params", ""); Web_UserAlbumColumn album; if (!string.IsNullOrEmpty(tmp) && CommonManager.String.IsInteger(tmp)) { //�� album = DbSession.Default.Get<Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == tmp && Web_UserAlbumColumn._.UserID == UserLoginInfo.UserID); if (album == null) return; album.Attach(); SetModel(album); } else { //�½� album = new Web_UserAlbumColumn(); album.InputTime = DateTime.Now; album.OrderID = 0; album.Cover = ""; album.UserID = int.Parse(UserLoginInfo.UserID); SetModel(album); } DbSession.Default.Save<Web_UserAlbumColumn>(album); CommonManager.Web.ResponseEnd("Album.aspx", true); }
/// <summary> /// ��ӻ���һ����� /// </summary> private void AddAlbumColumn() { if (!UserLoginInfo.IsLogin) { Response.Write("����δ��¼��<a href='javascript:history.back();'>��˷�����һҳ</a>"); return; } TUsers model = DbSession.Default.Get<TUsers>(TUsers._.UserName == UserLoginInfo.UserName); if (model == null) { Response.Write("����δ��¼��<a href='javascript:history.back();'>��˷�����һҳ</a>"); return; } //��ȡ������� string name = CommonManager.Web.RequestForm("txtAlbumName", ""); string ucover = CommonManager.Web.RequestForm("txtCover", ""); string lcover = ""; if (Request.Files.Count > 0) { try { if (!CommonManager.File.UploadFile(Request.Files["fileCover"], 100 * 1024, new string[] { "jpg", "jpeg", "gif", "bmp", "png" }, "/Upload/UserAlbum", FileOperator.RenameType.��ˮ��, out lcover)) { lcover = ""; } } catch (Exception ex) { Response.Write("�ļ��ϴ�����" + ex.Message + "<a href='javascript:history.back();'>��˷�����һҳ</a>"); return; } } string ispublic = CommonManager.Web.RequestForm("rdoIsPublic", Library.PublicState.����.ToString()); //У�� if (string.IsNullOrEmpty(name)) { Response.Write("����д������ơ�<a href='javascript:history.back();'>��˷�����һҳ</a>"); return; } //������ݿ� string cur = CommonManager.Web.Request("cur", ""); Web_UserAlbumColumn album; if (string.IsNullOrEmpty(cur)) { album = new Web_UserAlbumColumn(); album.InputTime = DateTime.Now; album.UserID = model.UserID; } else { album = DbSession.Default.Get<Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == cur); album.Attach(); } album.AlbumName = name; album.Cover = string.IsNullOrEmpty(album.Cover) ? (string.IsNullOrEmpty(lcover) ? ucover : lcover) : album.Cover; album.IsPublic = ispublic; DbSession.Default.Save<Web_UserAlbumColumn>(album); //������Ϣ Response.Write("<script>location.href='Album.aspx';</script>"); }
/// <summary> /// 添加或修改一个相册 /// </summary> private void AddAlbumColumn() { if (!UserLoginInfo.IsLogin) { Response.Write("您尚未登录。<a href='javascript:history.back();'>点此返回上一页</a>"); return; } TUsers model = DbSession.Default.Get <TUsers>(TUsers._.UserName == UserLoginInfo.UserName); if (model == null) { Response.Write("您尚未登录。<a href='javascript:history.back();'>点此返回上一页</a>"); return; } //获取表单数据 string name = CommonManager.Web.RequestForm("txtAlbumName", ""); string ucover = CommonManager.Web.RequestForm("txtCover", ""); string lcover = ""; if (Request.Files.Count > 0) { try { if (!CommonManager.File.UploadFile(Request.Files["fileCover"], 100 * 1024, new string[] { "jpg", "jpeg", "gif", "bmp", "png" }, "/Upload/UserAlbum", FileOperator.RenameType.流水号, out lcover)) { lcover = ""; } } catch (Exception ex) { Response.Write("文件上传错误:" + ex.Message + "<a href='javascript:history.back();'>点此返回上一页</a>"); return; } } string ispublic = CommonManager.Web.RequestForm("rdoIsPublic", Library.PublicState.公开.ToString()); //校验 if (string.IsNullOrEmpty(name)) { Response.Write("请填写相册名称。<a href='javascript:history.back();'>点此返回上一页</a>"); return; } //填充数据库 string cur = CommonManager.Web.Request("cur", ""); Web_UserAlbumColumn album; if (string.IsNullOrEmpty(cur)) { album = new Web_UserAlbumColumn(); album.InputTime = DateTime.Now; album.UserID = model.UserID; } else { album = DbSession.Default.Get <Web_UserAlbumColumn>(Web_UserAlbumColumn._.ID == cur); album.Attach(); } album.AlbumName = name; album.Cover = string.IsNullOrEmpty(album.Cover) ? (string.IsNullOrEmpty(lcover) ? ucover : lcover) : album.Cover; album.IsPublic = ispublic; DbSession.Default.Save <Web_UserAlbumColumn>(album); //返回信息 Response.Write("<script>location.href='Album.aspx';</script>"); }