365 lines
13 KiB
C#
365 lines
13 KiB
C#
using BLL;
|
||
using Newtonsoft.Json.Linq;
|
||
using NPOI.SS.Formula.Functions;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace FineUIPro.Web.CQMS.ProjectHighlightsSite
|
||
{
|
||
public partial class ProjectHighlightsSitePicReport : 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.ucTree.UnitId = this.CurrUser.UnitId;
|
||
this.ucTree.ProjectId = this.ProjectId;
|
||
//if (!string.IsNullOrEmpty(this.ProjectId))
|
||
//{
|
||
// this.panelLeftRegion.Hidden = true;
|
||
//}
|
||
////权限按钮方法
|
||
this.GetButtonPower();
|
||
//UpdateProjectHighlightsSiteType();
|
||
BLL.ProjectHighlightsSiteService.InitProjectHighlightsSiteTypeNameDropDownList(this.drpMainType, true);
|
||
// 绑定表格
|
||
BindGrid();
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 公司级树加载
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void changeTree(object sender, EventArgs e)
|
||
{
|
||
this.ProjectId = this.ucTree.ProjectId;
|
||
//this.InitDropDownList();
|
||
this.GetButtonPower();
|
||
//if (string.IsNullOrEmpty(this.CurrUser.LoginProjectId))
|
||
//{
|
||
// btnNew.Hidden = true;
|
||
//}
|
||
this.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();
|
||
var q = (from x in Funs.DB.CQMS_ProjectHighlightsSitePic orderby x.MainType, x.SubType select x).ToList();
|
||
if (!string.IsNullOrWhiteSpace(this.ProjectId))
|
||
{
|
||
q = q.Where(x => x.ProjectId == this.ProjectId).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 = string.Empty;
|
||
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 orderby x.MainType, x.SubType select x).ToList();
|
||
List<Model.CQMS_ProjectHighlightsSitePic> paged = new List<Model.CQMS_ProjectHighlightsSitePic>();
|
||
if (!string.IsNullOrWhiteSpace(this.ProjectId))
|
||
{
|
||
source = source.Where(x => x.ProjectId == this.ProjectId).ToList();
|
||
}
|
||
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>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnReportPro_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrWhiteSpace(this.ProjectId))
|
||
{
|
||
//var report = ProjectHighlightsSiteService.ReportProjectHighlightsSiteTypeToGroup(this.ProjectId, this.CurrUser);
|
||
Report(this.ProjectId);
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInTop("请选择上报项目!", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 上报所有项目
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnReport_Click(object sender, EventArgs e)
|
||
{
|
||
//ProjectHighlightsSiteService.ReportProjectHighlightsSiteTypeToGroup("", this.CurrUser);
|
||
Report("");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 上报集团
|
||
/// </summary>
|
||
/// <param name="projectId"></param>
|
||
private void Report(string projectId)
|
||
{
|
||
var report = ProjectHighlightsSiteService.ReportProjectHighlightsSiteTypeToGroup(projectId, this.CurrUser);
|
||
if (report.code == 1)
|
||
{
|
||
ShowNotify($"上报成功:{report.message}!", MessageBoxIcon.Success);
|
||
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
Alert.ShowInParent($"上报失败:{report.message}!", MessageBoxIcon.Error);
|
||
}
|
||
}
|
||
|
||
|
||
#region 获取按钮权限
|
||
|
||
/// <summary>
|
||
/// 获取按钮权限
|
||
/// </summary>
|
||
/// <param name="button"></param>
|
||
/// <returns></returns>
|
||
private void GetButtonPower()
|
||
{
|
||
if (Request.Params["value"] == "0")
|
||
{
|
||
return;
|
||
}
|
||
var buttonList = BLL.CommonService.GetAllButtonList(null, this.CurrUser.UserId, BLL.Const.ProjectHighlightsSitePicReportMenuId);
|
||
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;
|
||
}
|
||
if (buttonList.Contains(BLL.Const.BtnSaveUp))
|
||
{
|
||
this.btnReport.Hidden = false;
|
||
this.btnReportPro.Hidden = false;
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
} |