472 lines
20 KiB
C#
472 lines
20 KiB
C#
using Aspose.Words;
|
|
using BLL;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace FineUIPro.Web.CQMS.ManageReport
|
|
{
|
|
public partial class QuarterlyProjectQuality : PageBase
|
|
{
|
|
#region 项目主键
|
|
/// <summary>
|
|
/// 项目主键
|
|
/// </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)
|
|
{
|
|
Funs.DropDownPageSize(this.ddlPageSize);
|
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
|
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
|
|
{
|
|
this.ProjectId = Request.Params["projectId"];
|
|
}
|
|
////权限按钮方法
|
|
this.GetButtonPower();
|
|
|
|
BLL.ConstValue.InitConstValueDropDownList(this.drpYear, BLL.ConstValue.Group_0008, true);
|
|
BLL.ConstValue.InitConstValueDropDownList(this.drpQuarters, BLL.ConstValue.Group_0011, true);
|
|
this.btnNew.OnClientClick = Window1.GetShowReference("QuarterlyProjectQualityEdit.aspx") + "return false;";
|
|
if (this.CurrUser != null && this.CurrUser.PageSize.HasValue)
|
|
{
|
|
Grid1.PageSize = this.CurrUser.PageSize.Value;
|
|
}
|
|
this.ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|
// 绑定表格
|
|
this.BindGrid();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 绑定数据
|
|
/// </summary>
|
|
private void BindGrid()
|
|
{
|
|
string strSql = @"SELECT QuarterlyProjectQuality.QuarterlyProjectQualityId, "
|
|
+ @"QuarterlyProjectQuality.ProjectId,"
|
|
+ @"QuarterlyProjectQuality.UnitId,"
|
|
+ @"QuarterlyProjectQuality.Year,"
|
|
+ @"QuarterlyProjectQuality.Quarter,"
|
|
+ @"(CAST(QuarterlyProjectQuality.Year AS NVARCHAR(4))+'年 第'+CAST(QuarterlyProjectQuality.Quarter AS NVARCHAR(4))+'季度') AS YearAndQuarters,"
|
|
+ @"QuarterlyProjectQuality.CompileMan,"
|
|
+ @"QuarterlyProjectQuality.CompileDate,"
|
|
+ @"Unit.UnitName,"
|
|
+ @"Users.UserName AS CompileManName,"
|
|
+ @"u.UserName AS ResponsiblePersonName "
|
|
+ @" FROM InformationProject_QuarterlyProjectQuality AS QuarterlyProjectQuality "
|
|
+ @" LEFT JOIN Base_Unit AS Unit ON Unit.UnitId = QuarterlyProjectQuality.UnitId"
|
|
+ @" LEFT JOIN Sys_User AS u ON QuarterlyProjectQuality.ResponsiblePerson = u.UserId"
|
|
+ @" LEFT JOIN Sys_User AS Users ON QuarterlyProjectQuality.CompileMan = Users.UserId WHERE 1=1 ";
|
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|
strSql += " AND QuarterlyProjectQuality.ProjectId = '" + this.ProjectId + "'";
|
|
if (this.drpYear.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND QuarterlyProjectQuality.YearId = @Year";
|
|
listStr.Add(new SqlParameter("@Year", Funs.GetNewInt(this.drpYear.SelectedValue)));
|
|
}
|
|
if (this.drpQuarters.SelectedValue != BLL.Const._Null)
|
|
{
|
|
strSql += " AND QuarterlyProjectQuality.Quarter = @Quarter ";
|
|
listStr.Add(new SqlParameter("@Quarter", Funs.GetNewInt(this.drpQuarters.SelectedValue)));
|
|
}
|
|
SqlParameter[] parameter = listStr.ToArray();
|
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|
|
|
Grid1.RecordCount = tb.Rows.Count;
|
|
|
|
var table = this.GetPagedDataTable(Grid1, tb);
|
|
Grid1.DataSource = table;
|
|
Grid1.DataBind();
|
|
}
|
|
|
|
#region 分页 排序
|
|
/// <summary>
|
|
/// 改变索引事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
|
|
{
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 分页下拉选择事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
this.Grid1.PageSize = Convert.ToInt32(this.ddlPageSize.SelectedValue);
|
|
BindGrid();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 排序
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void TextBox_TextChanged(object sender, EventArgs e)
|
|
{
|
|
this.BindGrid();
|
|
}
|
|
#endregion
|
|
|
|
#region 编辑
|
|
/// <summary>
|
|
/// 双击事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Grid1_RowDoubleClick(object sender, GridRowClickEventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 右键编辑事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuEdit_Click(object sender, EventArgs e)
|
|
{
|
|
this.EditData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 编辑数据方法
|
|
/// </summary>
|
|
private void EditData()
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string id = Grid1.SelectedRowID;
|
|
var quality = BLL.ProjectQuarterlyProjectQualityService.GetQuarterlyProjectQualityById(id);
|
|
if (quality != null)
|
|
{
|
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("QuarterlyProjectQualityEdit.aspx?QuarterlyProjectQualityId={0}", id, "编辑 - ")));
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 删除
|
|
/// <summary>
|
|
/// 右键删除事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnMenuDelete_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length > 0)
|
|
{
|
|
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
|
|
{
|
|
string rowID = Grid1.DataKeys[rowIndex][0].ToString();
|
|
var getV = BLL.ProjectQuarterlyProjectQualityService.GetQuarterlyProjectQualityById(rowID);
|
|
if (getV != null)
|
|
{
|
|
BLL.LogService.AddSys_Log(this.CurrUser, getV.Year.ToString() + "-" + getV.Quarter.ToString(), getV.QuarterlyProjectQualityId, BLL.Const.ProjectQuarterlyProjectQualityMenuId, BLL.Const.BtnDelete);
|
|
BLL.ProjectQuarterlyProjectQualityService.DeleteQuarterlyProjectQualityById(rowID);
|
|
}
|
|
}
|
|
this.BindGrid();
|
|
ShowNotify("删除数据成功!", MessageBoxIcon.Success);
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#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.UserId, BLL.Const.ProjectQuarterlyProjectQualityMenuId);
|
|
if (buttonList.Count() > 0)
|
|
{
|
|
if (buttonList.Contains(BLL.Const.BtnAdd))
|
|
{
|
|
this.btnNew.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnModify))
|
|
{
|
|
this.btnMenuEdit.Hidden = false;
|
|
}
|
|
if (buttonList.Contains(BLL.Const.BtnDelete))
|
|
{
|
|
this.btnMenuDelete.Hidden = false;
|
|
}
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出
|
|
/// <summary>
|
|
/// 导出
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnPrinter_Click(object sender, EventArgs e)
|
|
{
|
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|
{
|
|
Alert.ShowInTop("请至少选择一条记录!", MessageBoxIcon.Warning);
|
|
return;
|
|
}
|
|
string Id = Grid1.SelectedRowID;
|
|
|
|
string rootPath = Server.MapPath("~/");
|
|
string initTemplatePath = string.Empty;
|
|
string uploadfilepath = string.Empty;
|
|
string newUrl = string.Empty;
|
|
string filePath = string.Empty;
|
|
|
|
string projectId = this.CurrUser.LoginProjectId;
|
|
|
|
var pModel = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == projectId);
|
|
|
|
|
|
initTemplatePath = Const.QuarterlyProjectQualityTemplateUrl;
|
|
uploadfilepath = rootPath + initTemplatePath;
|
|
|
|
var report = BLL.ProjectQuarterlyProjectQualityService.GetQuarterlyProjectQualityById(Id);
|
|
|
|
newUrl = uploadfilepath.Replace("季度工程项目质量信息表", "季度工程项目质量信息表(" + pModel.ShortName + report.Year + "年第" + report.Quarter + "季度)");
|
|
|
|
if (File.Exists(newUrl))
|
|
{
|
|
File.Delete(newUrl);
|
|
}
|
|
|
|
File.Copy(uploadfilepath, newUrl);
|
|
Document doc = new Aspose.Words.Document(uploadfilepath);
|
|
|
|
|
|
Bookmark yearId = doc.Range.Bookmarks["YearId"];
|
|
if (yearId != null)
|
|
{
|
|
yearId.Text = report.Year + "年";
|
|
}
|
|
Bookmark quarter = doc.Range.Bookmarks["Quarter"];
|
|
if (quarter != null)
|
|
{
|
|
quarter.Text = "第" + report.Quarter + "季度";
|
|
}
|
|
Bookmark compileDate = doc.Range.Bookmarks["CompileDate"];
|
|
if (compileDate != null)
|
|
{
|
|
compileDate.Text = report.CompileDate.HasValue ? string.Format("{0:yyyy-MM-dd}", report.CompileDate) : "";
|
|
}
|
|
Bookmark responsiblePerson = doc.Range.Bookmarks["ResponsiblePerson"];
|
|
if (responsiblePerson != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(report.ResponsiblePerson))
|
|
{
|
|
responsiblePerson.Text = BLL.UserService.GetUserNameByUserId(report.ResponsiblePerson);
|
|
}
|
|
}
|
|
Bookmark compileMan = doc.Range.Bookmarks["CompileMan"];
|
|
if (compileMan != null)
|
|
{
|
|
if (!string.IsNullOrEmpty(report.CompileMan))
|
|
{
|
|
compileMan.Text = BLL.UserService.GetUserNameByUserId(report.CompileMan);
|
|
}
|
|
}
|
|
Bookmark tel = doc.Range.Bookmarks["Tel"];
|
|
if (tel != null)
|
|
{
|
|
tel.Text = report.Tel;
|
|
}
|
|
Bookmark qualityManagePersonNum = doc.Range.Bookmarks["QualityManagePersonNum"];
|
|
if (qualityManagePersonNum != null)
|
|
{
|
|
qualityManagePersonNum.Text = report.QualityManagePersonNum.HasValue ? report.QualityManagePersonNum.ToString() : "";
|
|
}
|
|
Bookmark advancedTitlePersonNum = doc.Range.Bookmarks["AdvancedTitlePersonNum"];
|
|
if (advancedTitlePersonNum != null)
|
|
{
|
|
advancedTitlePersonNum.Text = report.AdvancedTitlePersonNum.HasValue ? report.AdvancedTitlePersonNum.ToString() : "";
|
|
}
|
|
Bookmark intermediateTitlePersonNum = doc.Range.Bookmarks["IntermediateTitlePersonNum"];
|
|
if (intermediateTitlePersonNum != null)
|
|
{
|
|
intermediateTitlePersonNum.Text = report.IntermediateTitlePersonNum.HasValue ? report.IntermediateTitlePersonNum.ToString() : "";
|
|
}
|
|
Bookmark beImplementedProjectNum = doc.Range.Bookmarks["BeImplementedProjectNum"];
|
|
if (beImplementedProjectNum != null)
|
|
{
|
|
beImplementedProjectNum.Text = report.BeImplementedProjectNum.HasValue ? report.BeImplementedProjectNum.ToString() : "";
|
|
}
|
|
Bookmark startImplementedProjectNum = doc.Range.Bookmarks["StartImplementedProjectNum"];
|
|
if (startImplementedProjectNum != null)
|
|
{
|
|
startImplementedProjectNum.Text = report.StartImplementedProjectNum.HasValue ? report.StartImplementedProjectNum.ToString():"";
|
|
}
|
|
Bookmark accumulativeStartImplemented = doc.Range.Bookmarks["AccumulativeStartImplemented"];
|
|
if (accumulativeStartImplemented != null)
|
|
{
|
|
accumulativeStartImplemented.Text = report.AccumulativeStartImplemented.HasValue? report.AccumulativeStartImplemented.ToString():"";
|
|
}
|
|
Bookmark completeProjectNum = doc.Range.Bookmarks["CompleteProjectNum"];
|
|
if (completeProjectNum != null)
|
|
{
|
|
completeProjectNum.Text = report.CompleteProjectNum.HasValue ? report.CompleteProjectNum.ToString() : "";
|
|
}
|
|
Bookmark yearCompleteProjectNum = doc.Range.Bookmarks["YearCompleteProjectNum"];
|
|
if (yearCompleteProjectNum != null)
|
|
{
|
|
yearCompleteProjectNum.Text = report.YearCompleteProjectNum.HasValue? report.YearCompleteProjectNum.ToString():"";
|
|
}
|
|
Bookmark quarterTotal = doc.Range.Bookmarks["QuarterTotal"];
|
|
if (quarterTotal != null)
|
|
{
|
|
quarterTotal.Text = report.QuarterTotal.HasValue? report.QuarterTotal.ToString():"";
|
|
}
|
|
Bookmark quarterFirstPassNum = doc.Range.Bookmarks["QuarterFirstPassNum"];
|
|
if (quarterFirstPassNum != null)
|
|
{
|
|
quarterFirstPassNum.Text = report.QuarterFirstPassNum.HasValue? report.QuarterFirstPassNum.ToString():"";
|
|
}
|
|
Bookmark quarterFirstPassRate = doc.Range.Bookmarks["QuarterFirstPassRate"];
|
|
if (quarterFirstPassRate != null)
|
|
{
|
|
quarterFirstPassRate.Text = report.QuarterFirstPassRate.HasValue? report.QuarterFirstPassRate.ToString():"";
|
|
}
|
|
Bookmark yearTotal = doc.Range.Bookmarks["YearTotal"];
|
|
if (yearTotal != null)
|
|
{
|
|
yearTotal.Text = report.YearTotal.HasValue ? report.YearTotal.ToString() : "";
|
|
}
|
|
Bookmark yearFirstPassNum = doc.Range.Bookmarks["YearFirstPassNum"];
|
|
if (yearFirstPassNum != null)
|
|
{
|
|
yearFirstPassNum.Text = report.YearFirstPassNum.HasValue ? report.YearFirstPassNum.ToString() : "";
|
|
}
|
|
Bookmark yearFirstPassRate = doc.Range.Bookmarks["YearFirstPassRate"];
|
|
if (yearFirstPassRate != null)
|
|
{
|
|
yearFirstPassRate.Text = report.YearFirstPassRate.HasValue ? report.YearFirstPassRate.ToString() : "";
|
|
}
|
|
Bookmark quaterCheckSuperviseNum = doc.Range.Bookmarks["QuaterCheckSuperviseNum"];
|
|
if (quaterCheckSuperviseNum != null)
|
|
{
|
|
quaterCheckSuperviseNum.Text = report.QuaterCheckSuperviseNum.HasValue ? report.QuaterCheckSuperviseNum.ToString() : "";
|
|
}
|
|
Bookmark quaterCorrectiveNoticeNum = doc.Range.Bookmarks["QuaterCorrectiveNoticeNum"];
|
|
if (quaterCorrectiveNoticeNum != null)
|
|
{
|
|
quaterCorrectiveNoticeNum.Text = report.QuaterCorrectiveNoticeNum.HasValue ? report.QuaterCorrectiveNoticeNum.ToString() : "";
|
|
}
|
|
Bookmark quaterQualityProblemNum = doc.Range.Bookmarks["QuaterQualityProblemNum"];
|
|
if (quaterQualityProblemNum != null)
|
|
{
|
|
quaterQualityProblemNum.Text = report.QuaterQualityProblemNum.HasValue ? report.QuaterQualityProblemNum.ToString() : "";
|
|
}
|
|
Bookmark quaterClosedQualityProblemNum = doc.Range.Bookmarks["QuaterClosedQualityProblemNum"];
|
|
if (quaterClosedQualityProblemNum != null)
|
|
{
|
|
quaterClosedQualityProblemNum.Text = report.QuaterClosedQualityProblemNum.HasValue ? report.QuaterClosedQualityProblemNum.ToString() : "";
|
|
}
|
|
Bookmark yearCheckSuperviseNum = doc.Range.Bookmarks["YearCheckSuperviseNum"];
|
|
if (yearCheckSuperviseNum != null)
|
|
{
|
|
yearCheckSuperviseNum.Text = report.YearCheckSuperviseNum.HasValue ? report.YearCheckSuperviseNum.ToString() : "";
|
|
}
|
|
Bookmark yearCorrectiveNoticeNum = doc.Range.Bookmarks["YearCorrectiveNoticeNum"];
|
|
if (yearCorrectiveNoticeNum != null)
|
|
{
|
|
yearCorrectiveNoticeNum.Text = report.YearCorrectiveNoticeNum.HasValue ? report.YearCorrectiveNoticeNum.ToString() : "";
|
|
}
|
|
Bookmark yearQualityProblemNum = doc.Range.Bookmarks["YearQualityProblemNum"];
|
|
if (yearQualityProblemNum != null)
|
|
{
|
|
yearQualityProblemNum.Text = report.YearQualityProblemNum.HasValue ? report.YearQualityProblemNum.ToString() : "";
|
|
}
|
|
Bookmark yearClosedQualityProblemNum = doc.Range.Bookmarks["YearClosedQualityProblemNum"];
|
|
if (yearClosedQualityProblemNum != null)
|
|
{
|
|
yearClosedQualityProblemNum.Text = report.YearClosedQualityProblemNum.HasValue ? report.YearClosedQualityProblemNum.ToString() : "";
|
|
}
|
|
Bookmark quaterQualityAccidentNum = doc.Range.Bookmarks["QuaterQualityAccidentNum"];
|
|
if (quaterQualityAccidentNum != null)
|
|
{
|
|
quaterQualityAccidentNum.Text = report.QuaterQualityAccidentNum.HasValue ? report.QuaterQualityAccidentNum.ToString() : "";
|
|
}
|
|
Bookmark quaterDirectEconomicLoss = doc.Range.Bookmarks["QuaterDirectEconomicLoss"];
|
|
if (quaterDirectEconomicLoss != null)
|
|
{
|
|
quaterDirectEconomicLoss.Text = report.QuaterDirectEconomicLoss.HasValue ? report.QuaterDirectEconomicLoss.ToString() : "";
|
|
}
|
|
Bookmark yearQualityAccidentNum = doc.Range.Bookmarks["YearQualityAccidentNum"];
|
|
if (yearQualityAccidentNum != null)
|
|
{
|
|
yearQualityAccidentNum.Text = report.YearQualityAccidentNum.HasValue ? report.YearQualityAccidentNum.ToString() : "";
|
|
}
|
|
Bookmark yearDirectEconomicLoss = doc.Range.Bookmarks["YearDirectEconomicLoss"];
|
|
if (yearDirectEconomicLoss != null)
|
|
{
|
|
yearDirectEconomicLoss.Text = report.YearDirectEconomicLoss.HasValue ? report.YearDirectEconomicLoss.ToString() : "";
|
|
}
|
|
|
|
doc.Save(newUrl);
|
|
|
|
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
|
|
}
|
|
} |