1
This commit is contained in:
@@ -0,0 +1,292 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.CQMS.ProjectHighlightsSite
|
||||
{
|
||||
public partial class ProjectHighlightsSitePic : PageBase
|
||||
{
|
||||
#region 定义项
|
||||
|
||||
/// <summary>
|
||||
/// 项目id
|
||||
/// </summary>
|
||||
public string ProjectId
|
||||
{
|
||||
get
|
||||
{
|
||||
return (string)ViewState["ProjectId"];
|
||||
}
|
||||
set
|
||||
{
|
||||
ViewState["ProjectId"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 加载
|
||||
/// <summary>
|
||||
/// 加载页面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
||||
{
|
||||
this.ProjectId = Request.Params["projectId"];
|
||||
}
|
||||
|
||||
////权限按钮方法
|
||||
this.GetButtonPower();
|
||||
UpdateProjectHighlightsSiteType();
|
||||
BLL.ProjectHighlightsSiteService.InitProjectHighlightsSiteTypeNameDropDownList(this.drpMainType, true);
|
||||
// 绑定表格
|
||||
BindGrid();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
var q = (from x in Funs.DB.CQMS_ProjectHighlightsSitePic where x.ProjectId == this.ProjectId orderby x.MainType, x.SubType select x).ToList();
|
||||
if (!string.IsNullOrWhiteSpace(this.drpMainType.SelectedValue) && this.drpMainType.SelectedValue != Const._Null)
|
||||
{
|
||||
q = q.Where(x => x.MainTypeName == this.drpMainType.SelectedValue).ToList();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.drpReport.SelectedValue) && this.drpReport.SelectedValue != Const._Null)
|
||||
{
|
||||
q = q.Where(x => x.IsReport == (this.drpReport.SelectedValue == "1")).ToList();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.drpUploadPic.SelectedValue) && this.drpUploadPic.SelectedValue != Const._Null)
|
||||
{
|
||||
q = q.Where(x => string.IsNullOrWhiteSpace(x.PicUrl) == (this.drpUploadPic.SelectedValue == "0")).ToList();
|
||||
}
|
||||
Grid1.RecordCount = q.Count();
|
||||
// 2.获取当前分页数据
|
||||
var table = GetPagedDataTable(Grid1.PageIndex, Grid1.PageSize);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
PageContext.RegisterStartupScript("showImg();");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 项目亮点照片(放于Img中)
|
||||
/// </summary>
|
||||
/// <param name="picUrl"></param>
|
||||
/// <returns></returns>
|
||||
protected string ConvertImageUrlByImage(object picUrl)
|
||||
{
|
||||
string url = string.Empty;
|
||||
if (picUrl != null && !string.IsNullOrWhiteSpace(picUrl.ToString()))
|
||||
{
|
||||
string httpUrl = Funs.SGGLUrl;
|
||||
//var sysSet6 = (from x in Funs.DB.Sys_Set where x.SetName == "程序访问地址" select x).ToList().FirstOrDefault();
|
||||
//if (sysSet6 != null)
|
||||
//{
|
||||
// httpUrl = sysSet6.SetValue;
|
||||
//}
|
||||
url = BLL.UploadAttachmentService.ShowImage(httpUrl, picUrl.ToString());
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 分页
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<Model.CQMS_ProjectHighlightsSitePic> GetPagedDataTable(int pageIndex, int pageSize)
|
||||
{
|
||||
List<Model.CQMS_ProjectHighlightsSitePic> source = (from x in Funs.DB.CQMS_ProjectHighlightsSitePic where x.ProjectId == this.ProjectId orderby x.MainType, x.SubType select x).ToList();
|
||||
List<Model.CQMS_ProjectHighlightsSitePic> paged = new List<Model.CQMS_ProjectHighlightsSitePic>();
|
||||
if (!string.IsNullOrWhiteSpace(this.drpMainType.SelectedValue) && this.drpMainType.SelectedValue != Const._Null)
|
||||
{
|
||||
source = source.Where(x => x.MainTypeName == this.drpMainType.SelectedValue).ToList();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.drpReport.SelectedValue) && this.drpReport.SelectedValue != Const._Null)
|
||||
{
|
||||
source = source.Where(x => x.IsReport == (this.drpReport.SelectedValue == "1")).ToList();
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(this.drpUploadPic.SelectedValue) && this.drpUploadPic.SelectedValue != Const._Null)
|
||||
{
|
||||
source = source.Where(x => string.IsNullOrWhiteSpace(x.PicUrl) == (this.drpUploadPic.SelectedValue == "0")).ToList();
|
||||
}
|
||||
int rowbegin = pageIndex * pageSize;
|
||||
int rowend = (pageIndex + 1) * pageSize;
|
||||
if (rowend > source.Count())
|
||||
{
|
||||
rowend = source.Count();
|
||||
}
|
||||
|
||||
for (int i = rowbegin; i < rowend; i++)
|
||||
{
|
||||
paged.Add(source[i]);
|
||||
}
|
||||
|
||||
return paged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 窗口关闭后刷新界面
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维护项目亮点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuModify_Click(object sender, EventArgs e)
|
||||
{
|
||||
EditData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击维护项目亮点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
||||
{
|
||||
btnMenuModify_Click(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除项目亮点
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnMenuDel_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length > 0)
|
||||
{
|
||||
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
||||
{
|
||||
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
||||
ProjectHighlightsSiteService.ResetProjectHighlightsSitePicById(rowID);
|
||||
}
|
||||
|
||||
BindGrid();
|
||||
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 维护项目亮点
|
||||
/// </summary>
|
||||
private void EditData()
|
||||
{
|
||||
if (Grid1.SelectedRowIndexArray.Length != 1)
|
||||
{
|
||||
Alert.ShowInTop("请选择一条记录", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
if (this.btnMenuModify.Hidden)////双击事件 编辑权限有:编辑页面,无:查看页面 或者状态是完成时查看页面
|
||||
{
|
||||
Alert.ShowInTop("抱歉,您无权维护亮点!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
//PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectHighlightsSitePicView.aspx?Id={0}", Grid1.SelectedRowID), "查看项目亮点"));
|
||||
}
|
||||
else
|
||||
{
|
||||
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("ProjectHighlightsSitePicEdit.aspx?Id={0}", Grid1.SelectedRowID), "维护项目亮点"));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 大类下拉触发事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void drpMainType_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 改变索引事件
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
||||
{
|
||||
Grid1.PageIndex = e.NewPageIndex;
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 过滤表头
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Grid1_FilterChange(object sender, EventArgs e)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 更新项目亮点类型
|
||||
/// </summary>
|
||||
protected void UpdateProjectHighlightsSiteType()
|
||||
{
|
||||
var returnValue = ProjectHighlightsSiteService.UpdateProjectHighlightsSiteTypeFromGroup(this.ProjectId);
|
||||
if (returnValue)
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert.ShowInTop("更新项目亮点类型失败", MessageBoxIcon.Success);
|
||||
}
|
||||
}
|
||||
|
||||
#region 获取按钮权限
|
||||
|
||||
/// <summary>
|
||||
/// 获取按钮权限
|
||||
/// </summary>
|
||||
/// <param name="button"></param>
|
||||
/// <returns></returns>
|
||||
private void GetButtonPower()
|
||||
{
|
||||
if (Request.Params["value"] == "0")
|
||||
{
|
||||
return;
|
||||
}
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.ProjectId, this.CurrUser.PersonId, BLL.Const.ProjectHighlightsSitePicMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
//if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
//{
|
||||
// this.btnNew.Hidden = false;
|
||||
//}
|
||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||
{
|
||||
this.btnMenuModify.Hidden = false;
|
||||
}
|
||||
if (buttonList.Contains(BLL.Const.BtnDelete))
|
||||
{
|
||||
this.btnMenuDel.Hidden = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user