修改进度模块
This commit is contained in:
@@ -3,6 +3,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
@@ -557,5 +558,103 @@ namespace FineUIPro.Web.CQMS.WBS
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 生成项目WBS编码
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnCreateCode_Click(object sender, EventArgs e)
|
||||
{
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
string projectCode = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId);
|
||||
var unitWorks = from x in db.WBS_UnitWork where x.ProjectId == this.CurrUser.LoginProjectId orderby x.UnitWorkCode select x;
|
||||
var workPackages = (from x in db.WBS_WorkPackage where x.ProjectId == this.CurrUser.LoginProjectId && x.IsApprove == true select x).ToList();
|
||||
var controlItemAndCycles = (from x in db.WBS_ControlItemAndCycle where x.ProjectId == this.CurrUser.LoginProjectId && x.IsApprove == true select x).ToList();
|
||||
foreach (var unitWork in unitWorks)
|
||||
{
|
||||
unitWork.WBSCode = projectCode + unitWork.UnitWorkCode;
|
||||
var workPackage1s = workPackages.Where(x => x.UnitWorkId == unitWork.UnitWorkId && x.SuperWorkPack == null).OrderBy(x => x.WorkPackageCode);
|
||||
foreach (var workPackage1 in workPackage1s)
|
||||
{
|
||||
if (!workPackage1.PackageContent.Contains("-"))
|
||||
{
|
||||
workPackage1.WBSCode = projectCode + unitWork.UnitWorkCode + unitWork.ProjectType + workPackage1.PackageCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
workPackage1.WBSCode = projectCode + unitWork.UnitWorkCode + unitWork.ProjectType + workPackage1.PackageCode + workPackage1.WorkPackageCode.Substring(workPackage1.WorkPackageCode.Length - 2, 2);
|
||||
}
|
||||
UpdateWBSCode(db, workPackages, workPackage1.WorkPackageId, workPackage1.WBSCode, controlItemAndCycles);
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
ShowNotify("生成成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
|
||||
private void UpdateWBSCode(Model.SGGLDB db, List<Model.WBS_WorkPackage> workPackages, string workPackageId, string wbsCode, List<Model.WBS_ControlItemAndCycle> controlItemAndCycles)
|
||||
{
|
||||
var childWorkPackages = workPackages.Where(x => x.SuperWorkPackageId == workPackageId);
|
||||
if (childWorkPackages.Count() > 0)
|
||||
{
|
||||
foreach (var childWorkPackage in childWorkPackages)
|
||||
{
|
||||
if (!childWorkPackage.PackageContent.Contains("-"))
|
||||
{
|
||||
childWorkPackage.WBSCode = wbsCode + childWorkPackage.PackageCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
childWorkPackage.WBSCode = wbsCode + childWorkPackage.PackageCode + childWorkPackage.WorkPackageCode.Substring(childWorkPackage.WorkPackageCode.Length - 2, 2);
|
||||
}
|
||||
UpdateWBSCode(db, workPackages, childWorkPackage.WorkPackageId, childWorkPackage.WBSCode, controlItemAndCycles);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var controlItemAndCycleItems = controlItemAndCycles.Where(x => x.WorkPackageId == workPackageId);
|
||||
foreach (var controlItemAndCycleItem in controlItemAndCycleItems)
|
||||
{
|
||||
controlItemAndCycleItem.WBSCode = wbsCode + controlItemAndCycleItem.InitControlItemCode.Substring(controlItemAndCycleItem.InitControlItemCode.Length - 2, 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 下载WBS编码规则文件
|
||||
/// <summary>
|
||||
/// 下载WBS编码规则文件按钮
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnFile_Click(object sender, EventArgs e)
|
||||
{
|
||||
PageContext.RegisterStartupScript(Confirm.GetShowReference("确定下载WBS编码规则文件吗?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 下载导入模板
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void PageManager1_CustomEvent(object sender, CustomEventArgs e)
|
||||
{
|
||||
if (e.EventArgument == "Confirm_OK")
|
||||
{
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string filePath = Const.WBSCodeTemplateUrl;
|
||||
string uploadfilepath = rootPath + filePath;
|
||||
string fileName = Path.GetFileName(filePath);
|
||||
FileInfo info = new FileInfo(uploadfilepath);
|
||||
long fileSize = info.Length;
|
||||
Response.ClearContent();
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
Response.ContentType = "excel/plain";
|
||||
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
||||
Response.AddHeader("Content-Length", fileSize.ToString().Trim());
|
||||
Response.TransmitFile(uploadfilepath, 0, fileSize);
|
||||
Response.End();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user