关键事项、周进度、月度计划
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
using BLL;
|
||||
using NPOI.SS.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.DataVisualization.Charting;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
namespace FineUIPro.Web.PZHGL.GJSX
|
||||
@@ -21,26 +24,27 @@ namespace FineUIPro.Web.PZHGL.GJSX
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
UnitService.InitUnitDropDownList(this.DropUnitId, this.CurrUser.LoginProjectId, true);
|
||||
//责任单位
|
||||
UnitService.InitUnitDropDownList(this.DropUnitId, this.CurrUser.LoginProjectId, false);
|
||||
//专业
|
||||
CNProfessionalService.InitCNProfessional(this.DropCNProfessional_ID, true);
|
||||
CNProfessionalService.InitCNProfessional(this.DropCNProfessional_ID, false);
|
||||
//编号
|
||||
string projectCode = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId);
|
||||
|
||||
//紧急程度
|
||||
QuestionTypeService.InitQuestionTypeDropDownList(this.DropQuestionTypeID, true);
|
||||
QuestionTypeService.InitQuestionTypeDropDownList(this.DropQuestionTypeID, false);
|
||||
//事项类别
|
||||
GJSXTypeService.InitGJSXTypeDropDownList(this.DropGJSXTypeID, true);
|
||||
GJSXTypeService.InitGJSXTypeDropDownList(this.DropGJSXTypeID, false);
|
||||
//验收人
|
||||
UserService.InitUserDropDownList(DropUser_ReceiveID, CurrUser.LoginProjectId, true, string.Empty);
|
||||
UserService.InitUserDropDownList(DropUser_ReceiveID, CurrUser.LoginProjectId, false, string.Empty);
|
||||
//接收人
|
||||
UserService.InitUserDropDownList(DropUser_Acceptance, CurrUser.LoginProjectId, true, string.Empty);
|
||||
UserService.InitUserDropDownList(DropUser_Acceptance, CurrUser.LoginProjectId, false, string.Empty);
|
||||
//提出人
|
||||
UserService.InitUserDropDownList(DropUserId, CurrUser.LoginProjectId, true, string.Empty);
|
||||
UserService.InitUserDropDownList(DropUserId, CurrUser.LoginProjectId, false, string.Empty);
|
||||
Funs.DropDownPageSize(this.ddlPageSize);
|
||||
////权限按钮方法
|
||||
this.GetButtonPower();
|
||||
this.btnNew.OnClientClick = Window1.GetShowReference("GJSXListEdit.aspx?EditType=add") + "return false;";
|
||||
//this.btnNew.OnClientClick = Window1.GetShowReference("GJSXListEdit.aspx?EditType=add") + "return false;";
|
||||
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
||||
{
|
||||
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
||||
@@ -57,7 +61,53 @@ namespace FineUIPro.Web.PZHGL.GJSX
|
||||
/// </summary>
|
||||
private void BindGrid()
|
||||
{
|
||||
string strSql = "";
|
||||
DataTable tb = BindData();
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < Grid1.Rows.Count; i++)
|
||||
{
|
||||
var state = tb.Rows[i]["state"].ToString().Trim();
|
||||
var completeDate = tb.Rows[i]["CompleteDate"].ToString();
|
||||
DateTime dtCompleteDate = Convert.ToDateTime(completeDate);
|
||||
if (Grid1.Rows[i].DataKeys[0] != null && !string.IsNullOrWhiteSpace(state))
|
||||
{
|
||||
if (state == "0")
|
||||
{
|
||||
//Grid1.Rows[i].RowCssClass = "green";
|
||||
Grid1.Rows[i].CellCssClasses[5] = "green";
|
||||
}
|
||||
else if (state == "2" || state == "3")
|
||||
{
|
||||
if (DateTime.Now > dtCompleteDate.AddDays(1))
|
||||
{
|
||||
//Grid1.Rows[i].RowCssClass = "red";
|
||||
Grid1.Rows[i].CellCssClasses[5] = "red";
|
||||
//Grid1.Rows[i].Cells[5].Text = "red";
|
||||
}
|
||||
else
|
||||
{
|
||||
//Grid1.Rows[i].RowCssClass = "blue";
|
||||
Grid1.Rows[i].CellCssClasses[5] = "blue";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据加载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private DataTable BindData()
|
||||
{
|
||||
string strSql = " AND state in (0,2,3,4) ";
|
||||
List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
|
||||
if (!string.IsNullOrEmpty(Request.Params["projectId"])) ///是否文件柜查看页面传项目值
|
||||
@@ -68,38 +118,115 @@ namespace FineUIPro.Web.PZHGL.GJSX
|
||||
{
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
}
|
||||
if (this.state.SelectedValue != "null")//状态
|
||||
{
|
||||
strSql += " AND state LIKE " + "'%" + this.state.SelectedText.Trim() + "%'";
|
||||
if (this.state.SelectedItemArray.Count() > 0)
|
||||
{//状态
|
||||
var stateList = String.Join(", ", this.state.SelectedValueArray).Split(',');
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in stateList)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item) && item != BLL.Const._Null && item != "4")
|
||||
{
|
||||
strSql += $" OR state = '{item}' ";
|
||||
}
|
||||
else if (item == "4")
|
||||
{
|
||||
strSql += " OR (state <> '0' and getdate() > DATEADD(day, 1, CompleteDate)) ";
|
||||
}
|
||||
i++;
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
|
||||
if (this.DropUserId.SelectedValue != Const._Null)//提出人
|
||||
{
|
||||
strSql += " AND username LIKE " + "'%" + this.DropUserId.SelectedText.Trim() + "%'";
|
||||
if (this.DropUserId.SelectedItemArray.Count() > 1 || (this.DropUserId.SelectedValue != BLL.Const._Null && this.DropUserId.SelectedItemArray.Count() == 1))
|
||||
{//提出人
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropUserId.SelectedItemArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Text) && item.Text != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR username = '{item.Text}' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (this.DropUser_ReceiveID.SelectedValue != Const._Null)//接受人
|
||||
{
|
||||
strSql += " AND User_ReceiveID LIKE " + "'%" + this.DropUser_ReceiveID.SelectedText.Trim() + "%'";
|
||||
if (this.DropUser_ReceiveID.SelectedItemArray.Count() > 1 || (this.DropUser_ReceiveID.SelectedValue != BLL.Const._Null && this.DropUser_ReceiveID.SelectedItemArray.Count() == 1))
|
||||
{//跟踪人
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropUser_ReceiveID.SelectedItemArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Text) && item.Text != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR User_ReceiveID LIKE '%{item.Text}%' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (this.DropUnitId.SelectedValue != Const._Null)//责任单位
|
||||
{
|
||||
strSql += " AND unitname LIKE " + "'%" + this.DropUnitId.SelectedText.Trim() + "%'";
|
||||
if (this.DropUser_Acceptance.SelectedItemArray.Count() > 1 || (this.DropUser_Acceptance.SelectedValue != BLL.Const._Null && this.DropUser_Acceptance.SelectedItemArray.Count() == 1))
|
||||
{//责任人
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropUser_Acceptance.SelectedItemArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Text) && item.Text != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR user_Acceptance = '{item.Text}' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (this.DropCNProfessional_ID.SelectedValue != Const._Null)//专业
|
||||
{
|
||||
strSql += " AND CNProfessionalId LIKE " + "'%" + this.DropCNProfessional_ID.SelectedText.Trim() + "%'";
|
||||
if (this.DropUnitId.SelectedItemArray.Count() > 1 || (this.DropUnitId.SelectedValue != BLL.Const._Null && this.DropUnitId.SelectedItemArray.Count() == 1))
|
||||
{//责任单位
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropUnitId.SelectedItemArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Text) && item.Text != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR unitname LIKE '%{item.Text}%' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (this.DropQuestionTypeID.SelectedValue != Const._Null)//紧急程度
|
||||
if (this.DropCNProfessional_ID.SelectedItemArray.Count() > 1 || (this.DropCNProfessional_ID.SelectedValue != BLL.Const._Null && this.DropCNProfessional_ID.SelectedItemArray.Count() == 1))
|
||||
{
|
||||
strSql += " AND QuestionTypeName LIKE " + "'%" + this.DropQuestionTypeID.SelectedText.Trim() + "%'";
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropCNProfessional_ID.SelectedValueArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item) && item != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR CNProfessionalId LIKE '%{item}%' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (this.DropGJSXTypeID.SelectedValue != Const._Null)//事项类别
|
||||
{
|
||||
strSql += " AND GJSXTypeName LIKE " + "'%" + this.DropGJSXTypeID.SelectedText.Trim() + "%'";
|
||||
if (this.DropQuestionTypeID.SelectedItemArray.Count() > 1 || (this.DropQuestionTypeID.SelectedValue != BLL.Const._Null && this.DropQuestionTypeID.SelectedItemArray.Count() == 1))
|
||||
{//紧急程度
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropQuestionTypeID.SelectedItemArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Text) && item.Text != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR QuestionTypeName LIKE '%{item.Text}%' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (this.DropUser_Acceptance.SelectedValue != Const._Null)//验收人
|
||||
{
|
||||
strSql += " AND user_Acceptance LIKE " + "'%" + this.DropUser_Acceptance.SelectedText.Trim() + "%'";
|
||||
if (this.DropGJSXTypeID.SelectedItemArray.Count() > 1 || (this.DropGJSXTypeID.SelectedValue != BLL.Const._Null && this.DropGJSXTypeID.SelectedItemArray.Count() == 1))
|
||||
{//事项类别
|
||||
strSql += " AND (1=2 ";
|
||||
int i = 0;
|
||||
foreach (var item in this.DropGJSXTypeID.SelectedItemArray)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(item.Text) && item.Text != BLL.Const._Null)
|
||||
{
|
||||
strSql += $" OR GJSXTypeName LIKE '%{item.Text}%' ";
|
||||
}
|
||||
}
|
||||
strSql += ")";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(this.txtStartTime.Text))//要求完成时间 start
|
||||
{
|
||||
@@ -114,14 +241,10 @@ namespace FineUIPro.Web.PZHGL.GJSX
|
||||
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunProc("Sp_GJSX_getlist", parameter);
|
||||
Grid1.RecordCount = tb.Rows.Count;
|
||||
var table = this.GetPagedDataTable(Grid1, tb);
|
||||
Grid1.DataSource = table;
|
||||
Grid1.DataBind();
|
||||
return tb;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region 查询
|
||||
/// <summary>
|
||||
/// 查询
|
||||
@@ -145,11 +268,11 @@ namespace FineUIPro.Web.PZHGL.GJSX
|
||||
var buttonList = BLL.CommonService.GetAllButtonList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, BLL.Const.PersonSetMenuId);
|
||||
if (buttonList.Count() > 0)
|
||||
{
|
||||
if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
{
|
||||
this.btnNew.Hidden = false;
|
||||
// this.btnImport.Hidden = false;
|
||||
}
|
||||
//if (buttonList.Contains(BLL.Const.BtnAdd))
|
||||
//{
|
||||
// this.btnNew.Hidden = false;
|
||||
// // this.btnImport.Hidden = false;
|
||||
//}
|
||||
if (buttonList.Contains(BLL.Const.BtnModify))
|
||||
{
|
||||
this.btnMenuEdit.Hidden = false;
|
||||
@@ -329,5 +452,139 @@ namespace FineUIPro.Web.PZHGL.GJSX
|
||||
{
|
||||
BindGrid();
|
||||
}
|
||||
|
||||
|
||||
#region 导出按钮
|
||||
/// 导出按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (Grid1.Rows.Count == 0)
|
||||
{
|
||||
ShowNotify("无数据可导出!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initTemplatePath = string.Empty;
|
||||
string uploadfilepath = string.Empty;
|
||||
string newUrl = string.Empty;
|
||||
string filePath = string.Empty;
|
||||
initTemplatePath = Const.GJSXOutTemplateUrl;
|
||||
uploadfilepath = rootPath + initTemplatePath;
|
||||
newUrl = uploadfilepath.Replace(".xlsx", "(" + DateTime.Now.ToString("yyyyMMdd") + ").xlsx");
|
||||
File.Copy(uploadfilepath, newUrl);
|
||||
// 第一步:读取文件流
|
||||
NPOI.SS.UserModel.IWorkbook workbook;
|
||||
using (FileStream stream = new FileStream(newUrl, FileMode.Open, FileAccess.Read))
|
||||
{
|
||||
workbook = new NPOI.XSSF.UserModel.XSSFWorkbook(stream);
|
||||
}
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
DataTable tb = BindData();
|
||||
// 创建单元格样式
|
||||
NPOI.SS.UserModel.ICellStyle cellStyle = workbook.CreateCellStyle();
|
||||
cellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
||||
cellStyle.Alignment = NPOI.SS.UserModel.HorizontalAlignment.Center;
|
||||
cellStyle.VerticalAlignment = NPOI.SS.UserModel.VerticalAlignment.Center;
|
||||
cellStyle.WrapText = true;
|
||||
var font = workbook.CreateFont();
|
||||
font.FontHeightInPoints = 10;
|
||||
//font.FontHeightInPoints = (short)8.5;字号为小数时要转为short
|
||||
cellStyle.SetFont(font);
|
||||
// 第二步:创建新数据行
|
||||
NPOI.SS.UserModel.ISheet sheet = workbook.GetSheetAt(0);
|
||||
NPOI.SS.UserModel.IRow row = null;
|
||||
NPOI.SS.UserModel.ICell cell;
|
||||
int i = 2;
|
||||
for (int j = 0; j < tb.Rows.Count; j++)
|
||||
{
|
||||
string state = tb.Rows[j]["State"].ToString();
|
||||
string createDate = string.Empty;
|
||||
if (tb.Rows[j]["CreateDate"] != DBNull.Value)
|
||||
{
|
||||
createDate = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(tb.Rows[j]["CreateDate"].ToString()));
|
||||
}
|
||||
string completeDate = string.Empty;
|
||||
if (tb.Rows[j]["CompleteDate"] != DBNull.Value)
|
||||
{
|
||||
completeDate = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(tb.Rows[j]["CompleteDate"].ToString()));
|
||||
}
|
||||
string closeDate = string.Empty;
|
||||
if (tb.Rows[j]["CloseDate"] != DBNull.Value)
|
||||
{
|
||||
closeDate = string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(tb.Rows[j]["CloseDate"].ToString()));
|
||||
}
|
||||
// 第二步:创建新数据行
|
||||
row = sheet.CreateRow(i);
|
||||
// 添加数据
|
||||
cell = row.CreateCell(0);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue((i - 1).ToString());
|
||||
cell = row.CreateCell(1);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["QuestionTypeName"].ToString());
|
||||
cell = row.CreateCell(2);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["CNProfessionalID"].ToString());
|
||||
cell = row.CreateCell(3);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["Detail"].ToString());
|
||||
cell = row.CreateCell(4);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["GJSXTypeName"].ToString());
|
||||
cell = row.CreateCell(5);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["StateStr"].ToString());
|
||||
cell = row.CreateCell(6);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(createDate);
|
||||
cell = row.CreateCell(7);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(completeDate);
|
||||
cell = row.CreateCell(8);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(closeDate);
|
||||
cell = row.CreateCell(9);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["unitname"].ToString());
|
||||
cell = row.CreateCell(10);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["username"].ToString());
|
||||
cell = row.CreateCell(11);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["User_Acceptance"].ToString());
|
||||
cell = row.CreateCell(12);
|
||||
cell.CellStyle = cellStyle;
|
||||
cell.SetCellValue(tb.Rows[j]["User_ReceiveID"].ToString());
|
||||
//cell = row.CreateCell(13);
|
||||
//cell.CellStyle = cellStyle;
|
||||
//cell.SetCellValue("");
|
||||
i++;
|
||||
}
|
||||
// 第三步:写入文件流
|
||||
using (FileStream stream = new FileStream(newUrl, FileMode.Create, FileAccess.Write))
|
||||
{
|
||||
workbook.Write(stream);
|
||||
workbook.Close();
|
||||
}
|
||||
string fileName = Path.GetFileName(newUrl);
|
||||
FileInfo info = new FileInfo(newUrl);
|
||||
long fileSize = info.Length;
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/x-zip-compressed";
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
Response.TransmitFile(newUrl, 0, fileSize);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
File.Delete(newUrl);
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user