2886 lines
159 KiB
C#
2886 lines
159 KiB
C#
|
using BLL;
|
|||
|
using BLL.Common;
|
|||
|
using Model;
|
|||
|
using Newtonsoft.Json;
|
|||
|
using NPOI.HSSF.Util;
|
|||
|
using NPOI.SS.UserModel;
|
|||
|
using NPOI.SS.Util;
|
|||
|
using NPOI.XSSF.UserModel;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Globalization;
|
|||
|
using System.IO;
|
|||
|
using System.Linq;
|
|||
|
using System.Linq.Expressions;
|
|||
|
using System.Text.RegularExpressions;
|
|||
|
using System.Web.UI.WebControls;
|
|||
|
using System.Data.SqlClient;
|
|||
|
|
|||
|
namespace FineUIPro.Web.CPT
|
|||
|
{
|
|||
|
public partial class SESReportToCPT : PageBase
|
|||
|
{
|
|||
|
//定义变量
|
|||
|
/// <summary>
|
|||
|
/// 上传预设的虚拟路径
|
|||
|
/// </summary>
|
|||
|
private string initPath = Const.ExcelUrl;
|
|||
|
/// <summary>
|
|||
|
/// 错误集合
|
|||
|
/// </summary>
|
|||
|
public static string errorInfos = string.Empty;
|
|||
|
|
|||
|
protected void Page_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (!IsPostBack)
|
|||
|
{
|
|||
|
var a1 = ViewState["sesNoList"];
|
|||
|
var b1 = ViewState["fcCptList"];
|
|||
|
var c1 = ViewState["sesRelateFoList"];
|
|||
|
var d1 = ViewState["sesList"];
|
|||
|
|
|||
|
var userList = from a in Funs.DB.Sys_User
|
|||
|
join b in Funs.DB.Sys_Role
|
|||
|
on a.RoleId equals b.RoleId
|
|||
|
where (b.RoleName.Contains("CT GM") || b.RoleName.Contains("CT Director"))
|
|||
|
&& a.IsPost == true
|
|||
|
select new { a.UserId, a.UserName, b.RoleId, b.RoleName };
|
|||
|
ddlCtDirector.DataTextField = "UserName";
|
|||
|
ddlCtDirector.DataValueField = "UserId";
|
|||
|
ddlCtDirector.DataSource = userList.Where(p => p.RoleName.Contains("CT Director")).ToList();
|
|||
|
hidCTGM.Text = userList.Where(p => p.RoleName.Contains("CT GM")).Select(p => p.UserId).FirstOrDefault();
|
|||
|
ddlCtDirector.DataBind();
|
|||
|
//if (userList.Count(p => p.RoleName.Contains("CT Director")) <= 0)
|
|||
|
//{
|
|||
|
Funs.FineUIPleaseSelect(ddlCtDirector);
|
|||
|
//}
|
|||
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|||
|
// 绑定表格
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 绑定数据
|
|||
|
/// <summary>
|
|||
|
/// 绑定Grid1
|
|||
|
/// </summary>
|
|||
|
private void BindGrid()
|
|||
|
{
|
|||
|
string strSql = @"SELECT cpt.ID,cpt.CPT_No,cpt.Contract_No,
|
|||
|
(cpt.ContractorEng+' '+cpt.ContractorCN) AS Contractor,
|
|||
|
cpt.FC_Desctription,cpt.Report_Date,ps.PriceScheme,
|
|||
|
cpt.FC_Start_Date,cpt.FC_End_Date
|
|||
|
FROM dbo.CPTList cpt
|
|||
|
LEFT JOIN dbo.Base_PriceScheme ps ON ps.PriceSchemeId=cpt.FC_Price_Scheme
|
|||
|
WHERE cpt.UserId=@UserId
|
|||
|
ORDER BY cpt.Report_Date DESC";
|
|||
|
//当前用户为合同员,显示该合同员的全部CPT
|
|||
|
var user = BLL.Sys_UserService.getUserListByRoleId(BLL.Const.Role_ContractAdministratorId, false);
|
|||
|
if (user != null)
|
|||
|
{
|
|||
|
if (user.FirstOrDefault(x => x.UserId == this.CurrUser.UserId) != null)
|
|||
|
{
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
listStr.Add(new SqlParameter("@UserId", this.CurrUser.UserId));
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
|
|||
|
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
Grid1.RecordCount = dt.Rows.Count;
|
|||
|
var table = this.GetPagedDataTable(Grid1, dt);
|
|||
|
Grid1.DataSource = table;
|
|||
|
Grid1.DataBind();
|
|||
|
}
|
|||
|
}
|
|||
|
//List<CPTList> sesCPTList = new List<CPTList>();
|
|||
|
//Expression<Func<CPTList, bool>> express = PredicateExtensions.True<CPTList>();
|
|||
|
|
|||
|
////当前用户为合同员,显示该合同员的全部CPT
|
|||
|
//var user = BLL.Sys_UserService.getUserListByRoleId(BLL.Const.Role_ContractAdministratorId, false);
|
|||
|
//if (user != null)
|
|||
|
//{
|
|||
|
// if (user.FirstOrDefault(x => x.UserId == this.CurrUser.UserId) != null)
|
|||
|
// {
|
|||
|
// express = express.And(p => p.UserId == this.CurrUser.UserId);
|
|||
|
// sesCPTList = Funs.DB.CPTList.Where(express).OrderByDescending(p => p.Report_Date).ToList();
|
|||
|
// Grid1.RecordCount = sesCPTList.Count;
|
|||
|
// var table = this.GetPagedDataTable(Grid1, sesCPTList);
|
|||
|
// Grid1.DataSource = table;
|
|||
|
// Grid1.DataBind();
|
|||
|
// }
|
|||
|
//}
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 绑定SESList
|
|||
|
/// </summary>
|
|||
|
private void BindGrid1(string CPT_No)
|
|||
|
{
|
|||
|
if (!string.IsNullOrEmpty(CPT_No))
|
|||
|
{
|
|||
|
string strSql = @" SELECT c.* FROM dbo.SESList s
|
|||
|
LEFT JOIN dbo.FC_SESReportToCPT c ON s.SES=c.SES_No
|
|||
|
WHERE s.CPT_No=@CPT_No";
|
|||
|
|
|||
|
List<SqlParameter> listStr = new List<SqlParameter>();
|
|||
|
listStr.Add(new SqlParameter("@CPT_No", CPT_No));
|
|||
|
SqlParameter[] parameter = listStr.ToArray();
|
|||
|
|
|||
|
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
|||
|
Grid2.RecordCount = tb.Rows.Count;
|
|||
|
var table = this.GetPagedDataTable(Grid2, tb);
|
|||
|
Grid2.DataSource = table;
|
|||
|
Grid2.DataBind();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Grid2.DataSource = null;
|
|||
|
Grid2.DataBind();
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 分页、排序
|
|||
|
/// <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 ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
|
|||
|
{
|
|||
|
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 排序
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
|
|||
|
{
|
|||
|
Grid1.SortDirection = e.SortDirection;
|
|||
|
Grid1.SortField = e.SortField;
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 关闭弹出窗口
|
|||
|
/// <summary>
|
|||
|
/// 关闭窗口
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Window1_Close(object sender, EventArgs e)
|
|||
|
{
|
|||
|
BindGrid();
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 查看
|
|||
|
/// <summary>
|
|||
|
/// 查看
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnEdit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInParent("Please select at least one record!");
|
|||
|
return;
|
|||
|
}
|
|||
|
string Id = Grid1.SelectedRowID;
|
|||
|
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("SESReportToCPTEdit.aspx?FO={0}", Id, "编辑 - ")));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 导入
|
|||
|
/// <summary>
|
|||
|
/// 导入
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnAudit_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (this.ddlCtDirector.SelectedValue == BLL.Const._Null)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Please select CT Director!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (this.ddlLastPayment.SelectedValue == "0")
|
|||
|
{
|
|||
|
Alert.ShowInTop("Please select Last payment of this contract!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
|
|||
|
var message = string.Empty;
|
|||
|
errorInfos = string.Empty;
|
|||
|
var fcCptList = new List<FC_SESReportToCPT>();
|
|||
|
var cptList = new List<CPTList>();
|
|||
|
var sesList = new List<SESList>();
|
|||
|
var sesFoList = new List<string>();
|
|||
|
var sesNoList = new List<string>();
|
|||
|
var inCPT_NO = new List<string>();
|
|||
|
var ssrList = Funs.DB.SSR.ToList();//判断当前登录人是否为合同员
|
|||
|
|
|||
|
try
|
|||
|
{
|
|||
|
var user = BLL.Sys_UserService.GetUsersByUserId(this.CurrUser.UserId);
|
|||
|
if (user != null)
|
|||
|
{
|
|||
|
if (user.RoleId != BLL.Const.Role_ContractAdministratorId)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Error in getting Contract Admin!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
if (this.cptAttachUrl.HasFile == false)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Please select Excel file!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
string IsXls = Path.GetExtension(this.cptAttachUrl.FileName).ToString().Trim().ToLower();
|
|||
|
if (IsXls != ".xls" && IsXls != ".xlsx")
|
|||
|
{
|
|||
|
Alert.ShowInTop("Only Excel files can be selected!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
if (!string.IsNullOrEmpty(errorInfos))
|
|||
|
{
|
|||
|
errorInfos = string.Empty;
|
|||
|
}
|
|||
|
var rootPath = Server.MapPath("~/");
|
|||
|
var initFullPath = rootPath + initPath;
|
|||
|
if (!Directory.Exists(initFullPath))
|
|||
|
{
|
|||
|
Directory.CreateDirectory(initFullPath);
|
|||
|
}
|
|||
|
//指定上传文件名称
|
|||
|
this.hidFileName.Text = BLL.Funs.GetNewFileName() + IsXls;
|
|||
|
//上传文件路径
|
|||
|
string filePath = initFullPath + this.hidFileName.Text;
|
|||
|
//文件上传服务器
|
|||
|
this.cptAttachUrl.PostedFile.SaveAs(filePath);
|
|||
|
//文件上传服务器后的名称
|
|||
|
string fileName = rootPath + initPath + this.hidFileName.Text;
|
|||
|
//读取Excel
|
|||
|
DataSet ds = NPOIHelper.ExcelToDataSet(fileName, out errorInfos, true);
|
|||
|
//验证Excel读取是否有误
|
|||
|
if (!string.IsNullOrEmpty(errorInfos))
|
|||
|
{
|
|||
|
ShowNotify(errorInfos, MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
DataRow[] drArr = ds.Tables[0].Select("FO <> ''");
|
|||
|
|
|||
|
DataTable dt = ds.Tables[0].Clone();
|
|||
|
for (int i = 0; i < drArr.Length; i++)
|
|||
|
{
|
|||
|
dt.ImportRow(drArr[i]);
|
|||
|
}
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
{
|
|||
|
string[] cptno = txtCPTNO.Text.Trim().Split('-');
|
|||
|
if (cptno[1] != dt.Rows[0]["FO"].ToString())
|
|||
|
{
|
|||
|
Alert.ShowInTop("The imported contract number is different with the selected CPT number, please check!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
List<string> foList = new List<string>();
|
|||
|
List<string> allSesNoList = new List<string>();
|
|||
|
|
|||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|||
|
{
|
|||
|
foList.Add(dt.Rows[i]["FO"].ToString());
|
|||
|
// 正在做CPT的Ses
|
|||
|
allSesNoList.Add(dt.Rows[i]["SES No."].ToString());
|
|||
|
}
|
|||
|
if (foList.Distinct().Count() > 1)
|
|||
|
{
|
|||
|
Alert.ShowInTop("导入的Excel中存在多个FO(Contractor No), please check!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (this.ddlLastPayment.SelectedValue == "Y")
|
|||
|
{
|
|||
|
string fo = foList[0];
|
|||
|
var sesReport = from y in Funs.DB.FC_SESReport where (y.Accepted == "X" || y.Accepted == "x") && y.FO == fo select y;
|
|||
|
string[] sesReportList = sesReport.Select(p => p.SES_No).ToArray();
|
|||
|
var sesCptList = from y in Funs.DB.SESList where y.CPT_No.Contains(fo) select y;
|
|||
|
// 已做CPT的Ses
|
|||
|
var sesNoDoneCPT = sesCptList.Select(x => x.SES).ToList();
|
|||
|
|
|||
|
// 正在做和已做CPT的SES集合
|
|||
|
allSesNoList.AddRange(sesNoDoneCPT);
|
|||
|
string[] allSesNoArr = allSesNoList.ToArray();
|
|||
|
string[] noSesList = sesReportList.Where(x => !allSesNoArr.Contains(x)).ToArray();
|
|||
|
|
|||
|
if (noSesList.Count() > 0)
|
|||
|
{
|
|||
|
string strSesNo = string.Empty;
|
|||
|
foreach (string ses in noSesList)
|
|||
|
{
|
|||
|
strSesNo = strSesNo + ses + ",";
|
|||
|
}
|
|||
|
strSesNo = strSesNo.Substring(0, strSesNo.Length - 1);
|
|||
|
Alert.ShowInTop("SES Report中的Accepted为 X 的SES(" + strSesNo + ")不存在于已经完成及当前正在做的CPT中, please check!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
//导入数据库
|
|||
|
if (dt.Rows.Count > 0)
|
|||
|
{
|
|||
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|||
|
{
|
|||
|
var fcCptModel = new FC_SESReportToCPT();
|
|||
|
|
|||
|
#region 数据验证和赋值FC_SESReportToCPT
|
|||
|
if (dt.Rows[i]["SES No."] != null && !string.IsNullOrEmpty(dt.Rows[i]["SES No."].ToString()))
|
|||
|
{
|
|||
|
fcCptModel.SES_No = dt.Rows[i]["SES No."].ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [SES No.] is null/empty!";
|
|||
|
}
|
|||
|
|
|||
|
fcCptModel.Short_Descrption = (dt.Rows[i]["Short Descrption"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Short Descrption"].ToString())) ? dt.Rows[i]["Short Descrption"].ToString() : "";
|
|||
|
|
|||
|
if (dt.Rows[i]["Start Date"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Start Date"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["Start Date"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.Start_Date = TimeValue(dt.Rows[i]["Start Date"]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Start Date]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Start Date]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["End Date"] != null && !string.IsNullOrEmpty(dt.Rows[i]["End Date"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["End Date"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.End_Date = TimeValue(dt.Rows[i]["End Date"]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [End Date]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [End Date]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
fcCptModel.Created_by = (dt.Rows[i]["Created by"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Created by"].ToString())) ? dt.Rows[i]["Created by"].ToString() : "";
|
|||
|
if (dt.Rows[i]["Created on"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Created on"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["Created on"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.Created_on = TimeValue(dt.Rows[i]["Created on"]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Created on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Created on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["TECO Date"] != null && !string.IsNullOrEmpty(dt.Rows[i]["TECO Date"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["TECO Date"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.TECO_Date = TimeValue(dt.Rows[i]["TECO Date"]);
|
|||
|
fcCptModel.TECO_Format = fcCptModel.TECO_Date;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [TECO Date]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [TECO Date]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
fcCptModel.Requisitioner = (dt.Rows[i]["Requisitioner"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Requisitioner"].ToString())) ? dt.Rows[i]["Requisitioner"].ToString() : "";
|
|||
|
if (dt.Rows[i]["FO"] != null && !string.IsNullOrEmpty(dt.Rows[i]["FO"].ToString()))
|
|||
|
{
|
|||
|
fcCptModel.FO = dt.Rows[i]["FO"].ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [FO] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Item"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Item"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsWholeNumber(dt.Rows[i]["Item"]))
|
|||
|
{
|
|||
|
fcCptModel.Item = int.Parse(dt.Rows[i]["Item"].ToString());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Item]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Item]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Item] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Vendor Name"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Vendor Name"].ToString()))
|
|||
|
{
|
|||
|
fcCptModel.Vendor_Name = dt.Rows[i]["Vendor Name"].ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Vendor Name] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["SSR budget"] != null && !string.IsNullOrEmpty(dt.Rows[i]["SSR budget"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["SSR budget"]))
|
|||
|
{
|
|||
|
fcCptModel.SSR_budget = DecibelConversion(dt.Rows[i]["SSR budget"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [SSR budget]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [SSR budget]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[SSR budget] is null/empty!</br>";
|
|||
|
}
|
|||
|
fcCptModel.Currency = (dt.Rows[i]["Currency"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Currency"].ToString())) ? dt.Rows[i]["Currency"].ToString() : "";
|
|||
|
if (dt.Rows[i]["Contractor quotation"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Contractor quotation"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Contractor quotation"]))
|
|||
|
{
|
|||
|
fcCptModel.Contractor_quotation = DecibelConversion(dt.Rows[i]["Contractor quotation"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Contractor quotation]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Contractor quotation]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Contractor quotation] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["SSR Actual cost"] != null && !string.IsNullOrEmpty(dt.Rows[i]["SSR Actual cost"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["SSR Actual cost"]))
|
|||
|
{
|
|||
|
fcCptModel.SSR_Actual_cost = DecibelConversion(dt.Rows[i]["SSR Actual cost"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [SSR Actual cost]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [SSR Actual cost]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[SSR Actual cost] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Tax rate"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Tax rate"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Tax rate"].ToString().Replace("%", "")))
|
|||
|
{
|
|||
|
fcCptModel.Tax_rate = DecibelConversion(dt.Rows[i]["Tax rate"].ToString().Replace("%", "").Trim()) / 100;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line Error in getting Tax Rate!</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line Error in getting Tax Rate!</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Tax rate] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Deviation"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Deviation"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Deviation"]))
|
|||
|
{
|
|||
|
fcCptModel.Deviation = DecibelConversion(dt.Rows[i]["Deviation"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Deviation]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Deviation]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Deviation Percentage"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Deviation Percentage"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Deviation Percentage"]))
|
|||
|
{
|
|||
|
fcCptModel.Deviation_Percentage = DecibelConversion(dt.Rows[i]["Deviation Percentage"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Deviation Percentage]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Deviation Percentage]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
fcCptModel.Long_text = (dt.Rows[i]["Long text"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Long text"].ToString())) ? dt.Rows[i]["Long text"].ToString() : "";
|
|||
|
if (dt.Rows[i]["Work Order"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Work Order"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsWholeNumber(dt.Rows[i]["Work Order"]))
|
|||
|
{
|
|||
|
fcCptModel.Work_Order = int.Parse(dt.Rows[i]["Work Order"].ToString());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Work Order]Must be in pure number format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Work Order]Must be in pure number format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
fcCptModel.Function_location = (dt.Rows[i]["Function location"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Function location"].ToString())) ? dt.Rows[i]["Function location"].ToString() : "";
|
|||
|
fcCptModel.Main_work_center = (dt.Rows[i]["Main work center"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Main work center"].ToString())) ? dt.Rows[i]["Main work center"].ToString() : "";
|
|||
|
fcCptModel.Work_Center = (dt.Rows[i]["Work Center"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Work Center"].ToString())) ? dt.Rows[i]["Work Center"].ToString() : "";
|
|||
|
fcCptModel.Cost_center = (dt.Rows[i]["Cost center"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Cost center"].ToString())) ? dt.Rows[i]["Cost center"].ToString() : "";
|
|||
|
fcCptModel.WBS = (dt.Rows[i]["WBS"] != null && !string.IsNullOrEmpty(dt.Rows[i]["WBS"].ToString())) ? dt.Rows[i]["WBS"].ToString() : "";
|
|||
|
fcCptModel.Network = (dt.Rows[i]["Network"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Network"].ToString())) ? dt.Rows[i]["Network"].ToString() : "";
|
|||
|
if (dt.Rows[i]["Claim sheets receive"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Claim sheets receive"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["Claim sheets receive"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.Claim_sheets_receive = TimeValue(dt.Rows[i]["Claim sheets receive"]);
|
|||
|
fcCptModel.CS_REC_Format = fcCptModel.Claim_sheets_receive;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Claim sheets receive]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Claim sheets receive]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Claim sheets receive] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Contractor duration"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Contractor duration"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Contractor duration"]))
|
|||
|
{
|
|||
|
fcCptModel.Contractor_duration = DecibelConversion(dt.Rows[i]["Contractor duration"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Contractor duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Contractor duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Engineer confirmed o"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Engineer confirmed o"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["Engineer confirmed o"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.Engineer_confirmed_o = TimeValue(dt.Rows[i]["Engineer confirmed o"]);
|
|||
|
fcCptModel.ENG_CONF_Format = fcCptModel.Engineer_confirmed_o;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Engineer confirmed o]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Engineer confirmed o]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[Engineer confirmed o] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["BoQ confirmation dur"] != null && !string.IsNullOrEmpty(dt.Rows[i]["BoQ confirmation dur"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["BoQ confirmation dur"]))
|
|||
|
{
|
|||
|
fcCptModel.BoQ_confirmation_dur = DecibelConversion(dt.Rows[i]["BoQ confirmation dur"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [BoQ confirmation dur]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [BoQ confirmation dur]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["SES Confirmed on"] != null && !string.IsNullOrEmpty(dt.Rows[i]["SES Confirmed on"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["SES Confirmed on"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.SES_Confirmed_on = TimeValue(dt.Rows[i]["SES Confirmed on"]);
|
|||
|
fcCptModel.SES_CONF_Format = TimeValue(dt.Rows[i]["SES Confirmed on"]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [SES Confirmed on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [SES Confirmed on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line,[SES Confirmed on] is null/empty!</br>";
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Settlement duration"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Settlement duration"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Settlement duration"]))
|
|||
|
{
|
|||
|
fcCptModel.Settlement_duration = DecibelConversion(dt.Rows[i]["Settlement duration"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Settlement duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Settlement duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Invoiced on"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Invoiced on"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["Invoiced on"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.Invoiced_on = TimeValue(dt.Rows[i]["Invoiced on"]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Invoiced on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Invoiced on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Invoice duration"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Invoice duration"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Invoice duration"]))
|
|||
|
{
|
|||
|
fcCptModel.Invoice_duration = DecibelConversion(dt.Rows[i]["Invoice duration"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Invoice duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Invoice duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Payment made on"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Payment made on"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
message = TimeValidation(dt.Rows[i]["Payment made on"]);
|
|||
|
if (string.IsNullOrEmpty(message))
|
|||
|
{
|
|||
|
fcCptModel.Payment_made_on = TimeValue(dt.Rows[i]["Payment made on"]);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Payment made on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "Line, [Payment made on]" + message + "</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Payment duration"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Payment duration"].ToString()))
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (IsNumber(dt.Rows[i]["Payment duration"]))
|
|||
|
{
|
|||
|
fcCptModel.Payment_duration = DecibelConversion(dt.Rows[i]["Payment duration"].ToString().Trim());
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Payment duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception)
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Payment duration]Must be in numeric format</br>";
|
|||
|
}
|
|||
|
}
|
|||
|
if (dt.Rows[i]["Accepted"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Accepted"].ToString()))
|
|||
|
{
|
|||
|
fcCptModel.Accepted = dt.Rows[i]["Accepted"].ToString();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
errorInfos += (i + 2) + "line, [Accepted] is null/empty!</br>";
|
|||
|
}
|
|||
|
|
|||
|
fcCptModel.Deleted = (dt.Rows[i]["Deleted"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Deleted"].ToString())) ? dt.Rows[i]["Deleted"].ToString() : "";
|
|||
|
fcCptModel.Blocked = (dt.Rows[i]["Blocked"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Blocked"].ToString())) ? dt.Rows[i]["Blocked"].ToString() : "";
|
|||
|
fcCptModel.Changed_by = (dt.Rows[i]["Changed by"] != null && !string.IsNullOrEmpty(dt.Rows[i]["Changed by"].ToString())) ? dt.Rows[i]["Changed by"].ToString() : "";
|
|||
|
fcCptModel.DateIn = DateTime.Now;
|
|||
|
fcCptModel.UserId = CurrUser.UserId;
|
|||
|
fcCptList.Add(fcCptModel);
|
|||
|
#endregion
|
|||
|
|
|||
|
#region SESList
|
|||
|
if (string.IsNullOrEmpty(errorInfos))
|
|||
|
{
|
|||
|
decimal punishment = 0;
|
|||
|
var pun = from x in Funs.DB.EMC_Punishment where x.SES_No == fcCptModel.SES_No select x;
|
|||
|
if (pun.Count() > 0)
|
|||
|
{
|
|||
|
punishment = pun.Sum(x => x.Company != null ? x.Company.Value : 0) + pun.Sum(x => x.Individual != null ? x.Individual.Value : 0);
|
|||
|
}
|
|||
|
|
|||
|
SESList sesModel = new SESList();
|
|||
|
sesModel.SES = fcCptModel.SES_No;
|
|||
|
sesModel.Requistioner = fcCptModel.Requisitioner;
|
|||
|
sesModel.Short_Description = fcCptModel.Short_Descrption;
|
|||
|
if (fcCptModel.Start_Date != null)
|
|||
|
{
|
|||
|
sesModel.Start_Date = fcCptModel.Start_Date;
|
|||
|
}
|
|||
|
if (fcCptModel.End_Date != null)
|
|||
|
{
|
|||
|
sesModel.End_Date = fcCptModel.End_Date;
|
|||
|
}
|
|||
|
sesModel.Budget = fcCptModel.SSR_budget;
|
|||
|
sesModel.Quotation = fcCptModel.Contractor_quotation;
|
|||
|
|
|||
|
sesModel.Punishment = punishment;
|
|||
|
if (fcCptModel.SSR_Actual_cost != null)
|
|||
|
{
|
|||
|
sesModel.Net_Value = fcCptModel.SSR_Actual_cost;
|
|||
|
}
|
|||
|
if (sesModel.Budget != null && sesModel.Net_Value != null)
|
|||
|
{
|
|||
|
decimal pTax = 0;
|
|||
|
if (punishment != 0)
|
|||
|
{
|
|||
|
pTax = (punishment / (1 + fcCptModel.Tax_rate)).Value;
|
|||
|
}
|
|||
|
|
|||
|
sesModel.Deviation = (sesModel.Net_Value + pTax - sesModel.Budget) > 0 ? (sesModel.Net_Value + pTax - sesModel.Budget).Value.ToString("0.00") : "";
|
|||
|
|
|||
|
if ((sesModel.Net_Value + pTax - sesModel.Budget) > 0 && sesModel.Budget != 0)
|
|||
|
{
|
|||
|
decimal? percTax = ((sesModel.Net_Value + pTax - sesModel.Budget) / sesModel.Budget) > 0 ? ((sesModel.Net_Value + pTax - sesModel.Budget) / sesModel.Budget) * 100 : 0;
|
|||
|
sesModel.By_Perc = percTax > 1 ? Math.Round(percTax.Value, 2).ToString() : "";
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sesModel.By_Perc = "";
|
|||
|
}
|
|||
|
}
|
|||
|
if (sesModel.Net_Value != null)
|
|||
|
{
|
|||
|
sesModel.Tax_Value = decimal.Parse((sesModel.Net_Value * (1 + fcCptModel.Tax_rate)).Value.ToString("0.00"));
|
|||
|
|
|||
|
if (sesModel.Quotation != null)
|
|||
|
{
|
|||
|
sesModel.Deduction = (sesModel.Quotation - sesModel.Tax_Value - punishment).Value.ToString("0.00");
|
|||
|
}
|
|||
|
}
|
|||
|
var CompletionDate = ssrList.Count(p => p.SES_No == sesModel.SES) > 0 ? ssrList.Where(p => p.SES_No == sesModel.SES).Select(p => p.CompletionDate).FirstOrDefault() : null;
|
|||
|
//FC_SESReportToCPT表中Claim_sheets_receive - SSR表中CompletionDate
|
|||
|
if (fcCptModel.Claim_sheets_receive != null && CompletionDate != null)
|
|||
|
{
|
|||
|
sesModel.Con_Days = GetTimeSpan(CompletionDate.Value, fcCptModel.Claim_sheets_receive.Value, 1);
|
|||
|
}
|
|||
|
//FC_SESReportToCPT表中Claim_sheets_receive-Engineer_confirmed_o;
|
|||
|
if (fcCptModel.Engineer_confirmed_o != null && fcCptModel.Claim_sheets_receive != null)
|
|||
|
{
|
|||
|
sesModel.BoQ_Days = GetTimeSpan(fcCptModel.Claim_sheets_receive.Value, fcCptModel.Engineer_confirmed_o.Value, 1);
|
|||
|
}
|
|||
|
//FC_SESReportToCPT表中SES_Confirmed_on - Engineer_confirmed_o;
|
|||
|
if (fcCptModel.SES_Confirmed_on != null && fcCptModel.Engineer_confirmed_o != null)
|
|||
|
{
|
|||
|
sesModel.SES_Days = GetTimeSpan(fcCptModel.Engineer_confirmed_o.Value, fcCptModel.SES_Confirmed_on.Value, 1);
|
|||
|
}
|
|||
|
sesModel.Submit_Date = DateTime.Now;
|
|||
|
sesModel.UserId = CurrUser.UserId;
|
|||
|
sesList.Add(sesModel);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
//错误提示
|
|||
|
if (!string.IsNullOrEmpty(errorInfos))
|
|||
|
{
|
|||
|
Alert.ShowInTop(errorInfos, MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
//添加
|
|||
|
if (fcCptList.Count > 0)
|
|||
|
{
|
|||
|
sesFoList = fcCptList.Select(p => p.FO).Distinct().ToList();//导入合同FO集合
|
|||
|
sesNoList = fcCptList.Select(p => p.SES_No).ToList();//导入的SES_NO集合
|
|||
|
var sesRelateList = Funs.DB.FC_SESRelatedData.Where(p => sesFoList.Contains(p.FO_NO));//获取合同信息
|
|||
|
var sesRelateFoList = Funs.DB.View_FC_SESRelatedData.Where(p => sesFoList.Contains(p.FO_NO));//获取合同号信息
|
|||
|
//判断SES是否存在合同中
|
|||
|
var exisNoList = Funs.DB.SESList.Where(p => sesNoList.Contains(p.SES)).ToList();
|
|||
|
//生成CPT_NO
|
|||
|
if (exisNoList.Count > 0)
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
{
|
|||
|
inCPT_NO = exisNoList.Select(p => p.CPT_No).Distinct().ToList();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
inCPT_NO.Add(txtCPTNO.Text.Trim());
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
{
|
|||
|
foreach (var itemCptNo in fcCptList.GroupBy(p => p.FO).Select(p => p.Key).ToList())
|
|||
|
{
|
|||
|
inCPT_NO.Add(SQLHelper.RunProcNewId("SpGetNewCode4", "dbo.CPTList", "CPT_No", "CPT" + "-" + itemCptNo + "-"));
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
inCPT_NO.Add(txtCPTNO.Text.Trim());
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 验证
|
|||
|
//验证BoQ_Days
|
|||
|
//if (sesList.Count(p => p.BoQ_Days == null || p.BoQ_Days <= 0) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("Error in finding the Work Acceptance Date!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
//判断合同号是否是否为空和获取合同号ConstRecords是否为"Y"
|
|||
|
if (sesRelateFoList == null || sesRelateFoList.Count() <= 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Error in getting Contract NO.!", MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
}
|
|||
|
//判断导入的SES_NO的Net value值是否异常
|
|||
|
if (sesList.Count(p => p.Net_Value == null || p.Net_Value <= 0) > 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Net value of SES (" + string.Join(",", sesList.Where(p => p.Net_Value == null || p.Net_Value <= 0).Select(p => p.SES).ToList()) + ") is null/0! Please recheck it!", MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
}
|
|||
|
//判断Con_Day是否存在负数
|
|||
|
//if (sesList.Count(p => p.Con_Days == null) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("CON of (" + string.Join(",", sesList.Where(p => p.Con_Days == null).Select(p => p.SES)) + ") is empty!Please check!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
////判断Con_Day是否存在空或负数
|
|||
|
//if (sesList.Count(p => p.Con_Days < 0) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("CON of (" + string.Join(",", sesList.Where(p => p.Con_Days <= 0).Select(p => p.SES)) + ") is minus!Please check!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
//判断导入的Tax_Rate是否存在多个和Tax_Rate是否在数据库存在
|
|||
|
if (fcCptList.Where(p => p.Tax_rate != null && p.Tax_rate > 0).Select(p => p.Tax_rate).Distinct().Count() > 1)
|
|||
|
{
|
|||
|
Alert.ShowInTop("More than one Tax Rate exist!Please recheck the Tax!", MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
var taxRateisDB = Funs.DB.Base_TaxRate.Count(p => p.TaxRate == fcCptList.FirstOrDefault().Tax_rate);
|
|||
|
if (taxRateisDB <= 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("More than one Tax Rate exist!Please recheck the Tax!", MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
//判断时间进程是否为null和0
|
|||
|
var timeProgress = new List<float>();
|
|||
|
foreach (var item in sesRelateList)
|
|||
|
{
|
|||
|
#region 时间进程
|
|||
|
if ((item.Validate_Date != null && item.Expire_Date != null))
|
|||
|
{
|
|||
|
//开始日期大于结束日期(肯定为数据错误,默认为0)
|
|||
|
if (item.Validate_Date < item.Expire_Date)
|
|||
|
{
|
|||
|
//开始日期大于当前日期,为0
|
|||
|
if (item.Validate_Date > DateTime.Now)
|
|||
|
{
|
|||
|
timeProgress.Add(0);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
//结束日期小于当前日期
|
|||
|
if (item.Expire_Date < DateTime.Now)
|
|||
|
{
|
|||
|
timeProgress.Add(100);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
int nowSpan = GetTimeSpan(item.Validate_Date.Value, DateTime.Now);
|
|||
|
int allSpan = GetTimeSpan(item.Validate_Date.Value, item.Expire_Date.Value);
|
|||
|
timeProgress.Add(nowSpan / allSpan * 100);
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
if (timeProgress.Count == 0)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Error:getting the time span:Wrong time input for this contract!Please recheck it!", MessageBoxIcon.Question);
|
|||
|
return;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
ViewState["sesNoList"] = JsonConvert.SerializeObject(sesNoList);
|
|||
|
ViewState["fcCptList"] = JsonConvert.SerializeObject(fcCptList);
|
|||
|
ViewState["sesRelateFoList"] = JsonConvert.SerializeObject(sesRelateFoList.ToList());
|
|||
|
ViewState["sesList"] = JsonConvert.SerializeObject(sesList);
|
|||
|
ViewState["exisSesList"] = JsonConvert.SerializeObject(exisNoList);
|
|||
|
//var msg = string.Empty;
|
|||
|
var msg1 = string.Empty;
|
|||
|
var msg2 = string.Empty;
|
|||
|
var msg3 = string.Empty;
|
|||
|
var msg4 = string.Empty;
|
|||
|
var msg5 = string.Empty;
|
|||
|
var msg6 = string.Empty;
|
|||
|
var sesStr = string.Empty;
|
|||
|
var cptStr = string.Empty;
|
|||
|
var conDayStr = string.Empty;
|
|||
|
var boqDays = string.Empty;
|
|||
|
var sesDays = string.Empty;
|
|||
|
var budget = string.Empty;
|
|||
|
string del = string.Empty;
|
|||
|
|
|||
|
cptStr = string.Join(",", inCPT_NO);
|
|||
|
var notExisSesList = Funs.DB.SESList.Where(p => p.CPT_No == cptStr && !sesNoList.Contains(p.SES)).ToList();
|
|||
|
var delStr = string.Join(",", notExisSesList.Select(p => p.SES));
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(delStr))
|
|||
|
{
|
|||
|
del = "SES:(" + delStr + ")将会被删除!";
|
|||
|
}
|
|||
|
|
|||
|
//SES合同号已经存在
|
|||
|
if (exisNoList.Count > 0)
|
|||
|
{
|
|||
|
sesStr = string.Join(",", exisNoList.Select(p => p.SES));
|
|||
|
if (string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
{
|
|||
|
msg1 = string.Format("SES:({0}) 已存在于CPT:{1},是否需要覆盖CPT NO:{2}?{3} 确认(覆盖)/取消(退出)", sesStr, cptStr, cptStr, del);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
msg1 = string.Format("SES:({0}) 已存在于CPT:{1},是否删除已存在的SES并且将数据导入CPT NO:{2}? {3} 确认(继续)/取消(退出)", sesStr, cptStr, txtCPTNO.Text.Trim(), del);
|
|||
|
}
|
|||
|
}
|
|||
|
// SES合同号不存在
|
|||
|
else
|
|||
|
{
|
|||
|
if (string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
{
|
|||
|
//cptStr = string.Join(",", inCPT_NO);
|
|||
|
msg1 = string.Format("新的CPT:({0})将会生成?确认 / 取消(退出)", cptStr);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
msg1 = string.Format("是否删除已存在的SES并且将数据导入CPT NO:{0}? {1} 确认(继续)/取消(退出)", txtCPTNO.Text.Trim(), del);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
// 存在空或负数提示BoQ_Days
|
|||
|
if (sesList.Count(p => p.BoQ_Days == null || p.BoQ_Days < 0) > 0)
|
|||
|
{
|
|||
|
boqDays = string.Join(",", sesList.Where(p => p.BoQ_Days == null || p.BoQ_Days <= 0).Select(p => p.SES));
|
|||
|
msg4 = "BoQ_Days of:(" + boqDays + ")是空或负值,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
// Con_Day存在空或负数提示
|
|||
|
if (sesList.Count(p => p.Con_Days == null || p.Con_Days < 0) > 0)
|
|||
|
{
|
|||
|
conDayStr = string.Join(",", sesList.Where(p => p.Con_Days == null || p.Con_Days < 0).Select(p => p.SES));
|
|||
|
msg3 = "CON of:(" + conDayStr + ")是空或负值,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
// Ses_Day存在空或负数提示
|
|||
|
if (sesList.Count(p => p.SES_Days == null || p.SES_Days < 0) > 0)
|
|||
|
{
|
|||
|
sesDays = string.Join(",", sesList.Where(p => p.SES_Days == null || p.SES_Days < 0).Select(p => p.SES));
|
|||
|
msg5 = "Ses_Day of:(" + sesDays + ")是空或负值,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
// Ses_Day存在空或负数提示
|
|||
|
if (sesList.Count(p => p.Budget == 0) > 0)
|
|||
|
{
|
|||
|
budget = string.Join(",", sesList.Where(p => p.Budget == 0).Select(p => p.SES));
|
|||
|
msg6 = "Budget of:(" + budget + ")值为0,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
if (fcCptList.Count(p => p.Tax_rate == null || p.Tax_rate <= 0) > 0)
|
|||
|
{
|
|||
|
msg2 = "The Tax Rate of SES:(" + string.Join(",", fcCptList.Where(p => p.Tax_rate == null || p.Tax_rate <= 0).Select(p => p.SES_No).ToList()) + ") is null/0 ,Is it right?";
|
|||
|
}
|
|||
|
|
|||
|
//msg = msg1;
|
|||
|
|
|||
|
//if (msg2 != string.Empty)
|
|||
|
//{
|
|||
|
// msg = msg + " 和 " + msg2;
|
|||
|
//}
|
|||
|
//if (msg3 != string.Empty)
|
|||
|
//{
|
|||
|
// msg = msg + " 和 " + msg3;
|
|||
|
//}
|
|||
|
//if (msg4 != string.Empty)
|
|||
|
//{
|
|||
|
// msg = msg + " 和 " + msg4;
|
|||
|
//}
|
|||
|
//if (msg5 != string.Empty)
|
|||
|
//{
|
|||
|
// msg = msg + " 和 " + msg5;
|
|||
|
//}
|
|||
|
//if (msg6 != string.Empty)
|
|||
|
//{
|
|||
|
// msg = msg + " 和 " + msg6;
|
|||
|
//}
|
|||
|
|
|||
|
if (msg2 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("2");
|
|||
|
}
|
|||
|
else if (msg3 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("3");
|
|||
|
}
|
|||
|
else if (msg4 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("4");
|
|||
|
}
|
|||
|
else if (msg5 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("5");
|
|||
|
}
|
|||
|
else if (msg6 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("6");
|
|||
|
}
|
|||
|
|
|||
|
if (msg2 == string.Empty && msg3 == string.Empty && msg4 == string.Empty && msg5 == string.Empty && msg6 == string.Empty)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg1,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg1,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK1"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
#region 注释
|
|||
|
//else
|
|||
|
//{
|
|||
|
// if (string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
// {
|
|||
|
// msg2 = "CPT NO " + string.Join(",", inCPT_NO) + " will be generated! If you want to change the CPT NO., Click Cancel), Please Confirm? Confirm the generated CPT NO " + string.Join(", ", inCPT_NO) + "? ";
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// msg2 = "CPT NO " + string.Join(",", txtCPTNO.Text.Trim()) + " will be generated! If you want to change the CPT NO., Click Cancel), Please Confirm? Confirm the generated CPT NO " + string.Join(", ", txtCPTNO.Text.Trim()) + "? ";
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//if (string.IsNullOrEmpty(txtCPTNO.Text.Trim()))//SES已存在其他的CPT,但是并没有选择导入的CPT数据
|
|||
|
//{
|
|||
|
// if (msg1 != string.Empty)
|
|||
|
// {
|
|||
|
// msg = msg1 + " and " + msg2;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// msg = msg2;
|
|||
|
// }
|
|||
|
// //msg = string.Format("SES:({0}) 已存在于CPT NO{1},是否删除已存在的SES?", sesStr, cptStr);
|
|||
|
// PageContext.RegisterStartupScript(Confirm.GetShowReference(msg,
|
|||
|
// String.Empty,
|
|||
|
// MessageBoxIcon.Question,
|
|||
|
// PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
// PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
//}
|
|||
|
//else//SES已存在其他的CPT,选择了导入的CPT
|
|||
|
//{
|
|||
|
// if (msg1 != string.Empty)
|
|||
|
// {
|
|||
|
// msg = msg1 + " and " + msg2;
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// msg = msg2;
|
|||
|
// }
|
|||
|
// // msg = string.Format("SES:({0}) 已存在于CPT NO{1},是否删除已存在的SES并且将数据导入CPT NO{2}", sesStr, cptStr, txtCPTNO.Text.Trim());
|
|||
|
// PageContext.RegisterStartupScript(Confirm.GetShowReference(msg,
|
|||
|
// String.Empty,
|
|||
|
// MessageBoxIcon.Question,
|
|||
|
// PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
// PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
|
|||
|
//}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
////判断合同是否存在
|
|||
|
//var exisNoList = Funs.DB.SESList.Where(p => sesNoList.Contains(p.SES)).ToList();
|
|||
|
////生成CPT_NO
|
|||
|
//if (exisNoList.Count > 0)
|
|||
|
//{
|
|||
|
// inCPT_NO = exisNoList.Select(p => p.CPT_No).Distinct().ToList();
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// foreach (var itemCptNo in fcCptList.GroupBy(p => p.FO).Select(p => p.Key).ToList())
|
|||
|
// {
|
|||
|
// inCPT_NO.Add(SQLHelper.RunProcNewId("SpGetNewCode4", "dbo.CPTList", "CPT_No", "CPT" + "-" + itemCptNo + "-"));
|
|||
|
// }
|
|||
|
//}
|
|||
|
|
|||
|
//#region 验证
|
|||
|
////验证BoQ_Days
|
|||
|
//if (sesList.Count(p => p.BoQ_Days == null || p.BoQ_Days <= 0) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("Error in finding the Work Acceptance Date!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
////判断合同号是否是否为空和获取合同号ConstRecords是否为"Y"
|
|||
|
//if (sesRelateFoList == null || sesRelateFoList.Count() <= 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("Error in getting Contract NO.!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
//////判断SES_NO其他合同于是否添加
|
|||
|
////if (othersSesList.Count > 0)
|
|||
|
////{
|
|||
|
//// Alert.ShowInTop("SES:(" + string.Join(",", othersSesList.Select(p => p.SES)) + ") exists in CPT NO.: !Please recheck it!", MessageBoxIcon.Question);
|
|||
|
//// return;
|
|||
|
////}
|
|||
|
////判断导入的SES_NO的Net value值是否异常
|
|||
|
//if (sesList.Count(p => p.Net_Value == null || p.Net_Value <= 0) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("Net value of SES (" + string.Join(",", sesList.Where(p => p.Net_Value == null || p.Net_Value <= 0).Select(p => p.SES).ToList()) + ") is null/0! Please recheck it!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
////判断Con_Day是否存在负数
|
|||
|
//if (sesList.Count(p => p.Con_Days == null) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("CON of (" + string.Join(",", sesList.Where(p => p.Con_Days == null).Select(p => p.SES)) + ") is empty!Please check!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
////判断Con_Day是否存在空或负数
|
|||
|
//if (sesList.Count(p => p.Con_Days < 0) > 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("CON of (" + string.Join(",", sesList.Where(p => p.Con_Days <= 0).Select(p => p.SES)) + ") is minus!Please check!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
////判断导入的Tax_Rate是否存在多个和Tax_Rate是否在数据库存在
|
|||
|
//if (fcCptList.Where(p => p.Tax_rate != null && p.Tax_rate > 0).Select(p => p.Tax_rate).Distinct().Count() > 1)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("More than one Tax Rate exist!Please recheck the Tax!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// var taxRateisDB = Funs.DB.Base_TaxRate.Count(p => p.TaxRate == fcCptList.FirstOrDefault().Tax_rate);
|
|||
|
// if (taxRateisDB <= 0)
|
|||
|
// {
|
|||
|
// Alert.ShowInTop("More than one Tax Rate exist!Please recheck the Tax!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
// }
|
|||
|
//}
|
|||
|
////判断时间进程是否为null和0
|
|||
|
//var timeProgress = new List<float>();
|
|||
|
//foreach (var item in sesRelateList)
|
|||
|
//{
|
|||
|
// #region 时间进程
|
|||
|
// if ((item.Validate_Date != null && item.Expire_Date != null))
|
|||
|
// {
|
|||
|
// //开始日期大于结束日期(肯定为数据错误,默认为0)
|
|||
|
// if (item.Validate_Date < item.Expire_Date)
|
|||
|
// {
|
|||
|
// //开始日期大于当前日期,为0
|
|||
|
// if (item.Validate_Date > DateTime.Now)
|
|||
|
// {
|
|||
|
// timeProgress.Add(0);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// //结束日期小于当前日期
|
|||
|
// if (item.Expire_Date < DateTime.Now)
|
|||
|
// {
|
|||
|
// timeProgress.Add(100);
|
|||
|
// }
|
|||
|
// else
|
|||
|
// {
|
|||
|
// int nowSpan = GetTimeSpan(DateTime.Now, item.Expire_Date.Value);
|
|||
|
// int allSpan = GetTimeSpan(item.Validate_Date.Value, item.Expire_Date.Value);
|
|||
|
// timeProgress.Add(nowSpan / allSpan * 100);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
//}
|
|||
|
//if (timeProgress.Count == 0)
|
|||
|
//{
|
|||
|
// Alert.ShowInTop("Error:getting the time span:Wrong time input for this contract!Please recheck it!", MessageBoxIcon.Question);
|
|||
|
// return;
|
|||
|
//}
|
|||
|
//#endregion
|
|||
|
|
|||
|
//ViewState["sesNoList"] = JsonConvert.SerializeObject(sesNoList);
|
|||
|
//ViewState["fcCptList"] = JsonConvert.SerializeObject(fcCptList);
|
|||
|
//ViewState["sesRelateFoList"] = JsonConvert.SerializeObject(sesRelateFoList.ToList());
|
|||
|
//ViewState["sesList"] = JsonConvert.SerializeObject(sesList);
|
|||
|
//ViewState["exisSesList"] = JsonConvert.SerializeObject(exisNoList);
|
|||
|
////判断合同号是否已经存在
|
|||
|
//if (exisNoList.Count > 0)
|
|||
|
//{
|
|||
|
// PageContext.RegisterStartupScript(Confirm.GetShowReference("SES:(" + string.Join(",", exisNoList.Select(p => p.SES)) + ") 已存在,是否覆盖?点击确定将覆盖已存在的SES!",
|
|||
|
// String.Empty,
|
|||
|
// MessageBoxIcon.Question,
|
|||
|
// PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
// PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
// return;
|
|||
|
//}
|
|||
|
//if (fcCptList.Count(p => p.Tax_rate == null || p.Tax_rate <= 0) > 0)
|
|||
|
//{
|
|||
|
// PageContext.RegisterStartupScript(Confirm.GetShowReference("The Tax Rate of SES:(" + string.Join(",", fcCptList.Where(p => p.Tax_rate == null || p.Tax_rate <= 0).Select(p => p.SES_No).ToList()) + ") is null/0 ,Is it right?",
|
|||
|
// String.Empty,
|
|||
|
// MessageBoxIcon.Question,
|
|||
|
// PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
// PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// PageContext.RegisterStartupScript(Confirm.GetShowReference("CPT NO " + string.Join(",", inCPT_NO) + " will be generated! If you want to change the CPT NO., Click Cancel), Please Confirm? Confirm the generated CPT NO " + string.Join(", ", inCPT_NO) + "? ",
|
|||
|
// String.Empty,
|
|||
|
// MessageBoxIcon.Question,
|
|||
|
// PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
// PageManager1.GetCustomEventReference("SaveConfirm_Cancel1")));
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Alert.ShowInTop("No data!", MessageBoxIcon.Warning);
|
|||
|
return;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
Alert.ShowInTop("Error in saving SES (" + string.Join(",", sesNoList) + ") to DB!Error in saving " + string.Join(",", cptList.Select(p => p.CPT_No)) + " to DB!", MessageBoxIcon.Warning);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/// <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 uploadfilepath = rootPath + Const.FC_SESReportToCPTTemplateUrl;
|
|||
|
string filePath = Const.FC_SESReportTemplateUrl;
|
|||
|
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();
|
|||
|
}
|
|||
|
else if (e.EventArgument == "SaveConfirm_OK")
|
|||
|
{
|
|||
|
var sesNoList = JsonConvert.DeserializeObject<List<string>>(ViewState["sesNoList"].ToString());
|
|||
|
var fcCptList = JsonConvert.DeserializeObject<List<FC_SESReportToCPT>>(ViewState["fcCptList"].ToString());
|
|||
|
var sesRelateFoList = JsonConvert.DeserializeObject<List<View_FC_SESRelatedData>>(ViewState["sesRelateFoList"].ToString());
|
|||
|
var sesList = JsonConvert.DeserializeObject<List<SESList>>(ViewState["sesList"].ToString());
|
|||
|
var exisSesList = JsonConvert.DeserializeObject<List<SESList>>(ViewState["exisSesList"].ToString());
|
|||
|
isOk(sesNoList, fcCptList, sesRelateFoList, sesList, exisSesList);
|
|||
|
}
|
|||
|
else if (e.EventArgument == "SaveConfirm_OK1")
|
|||
|
{
|
|||
|
string msg = JsonConvert.DeserializeObject<string>(ViewState["msg"].ToString());
|
|||
|
var fcCptList = JsonConvert.DeserializeObject<List<FC_SESReportToCPT>>(ViewState["fcCptList"].ToString());
|
|||
|
var sesList = JsonConvert.DeserializeObject<List<SESList>>(ViewState["sesList"].ToString());
|
|||
|
isOkMsg(fcCptList,sesList,msg);
|
|||
|
}
|
|||
|
else if (e.EventArgument == "SaveConfirm_Cancel")
|
|||
|
{
|
|||
|
//Tax_Rate为空时点击否
|
|||
|
//ShowNotify("Please correct it in SAP, Thanks!Error in getting Tax Rate!");
|
|||
|
|
|||
|
}
|
|||
|
else if (e.EventArgument == "SaveConfirm_Cancel1")
|
|||
|
{
|
|||
|
//ShowNotify("Please change the CPT NO. to continue!");
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
private bool isOkMsg(List<FC_SESReportToCPT> fcCptList, List<SESList> sesList, string msg)
|
|||
|
{
|
|||
|
var msg2 = string.Empty;
|
|||
|
var msg3 = string.Empty;
|
|||
|
var msg4 = string.Empty;
|
|||
|
var msg5 = string.Empty;
|
|||
|
var msg6 = string.Empty;
|
|||
|
var sesStr = string.Empty;
|
|||
|
var cptStr = string.Empty;
|
|||
|
var conDayStr = string.Empty;
|
|||
|
var boqDays = string.Empty;
|
|||
|
var sesDays = string.Empty;
|
|||
|
var budget = string.Empty;
|
|||
|
|
|||
|
if (fcCptList.Count(p => p.Tax_rate == null || p.Tax_rate <= 0) > 0)
|
|||
|
{
|
|||
|
msg2 = "The Tax Rate of SES:(" + string.Join(",", fcCptList.Where(p => p.Tax_rate == null || p.Tax_rate <= 0).Select(p => p.SES_No).ToList()) + ") is null/0 ,Is it right?";
|
|||
|
}
|
|||
|
|
|||
|
// 存在空或负数提示BoQ_Days
|
|||
|
if (sesList.Count(p => p.BoQ_Days == null || p.BoQ_Days < 0) > 0)
|
|||
|
{
|
|||
|
boqDays = string.Join(",", sesList.Where(p => p.BoQ_Days == null || p.BoQ_Days <= 0).Select(p => p.SES));
|
|||
|
msg4 = "BoQ_Days of:(" + boqDays + ")是空或负值,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
// Con_Day存在空或负数提示
|
|||
|
if (sesList.Count(p => p.Con_Days == null || p.Con_Days < 0) > 0)
|
|||
|
{
|
|||
|
conDayStr = string.Join(",", sesList.Where(p => p.Con_Days == null || p.Con_Days < 0).Select(p => p.SES));
|
|||
|
msg3 = "CON of:(" + conDayStr + ")是空或负值,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
// Ses_Day存在空或负数提示
|
|||
|
if (sesList.Count(p => p.SES_Days == null || p.SES_Days < 0) > 0)
|
|||
|
{
|
|||
|
sesDays = string.Join(",", sesList.Where(p => p.SES_Days == null || p.SES_Days < 0).Select(p => p.SES));
|
|||
|
msg5 = "Ses_Day of:(" + sesDays + ")是空或负值,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
|
|||
|
// Ses_Day存在空或负数提示
|
|||
|
if (sesList.Count(p => p.Budget == 0) > 0)
|
|||
|
{
|
|||
|
budget = string.Join(",", sesList.Where(p => p.Budget == 0).Select(p => p.SES));
|
|||
|
msg6 = "Budget of:(" + budget + ")值为0,确定(继续),取消(退出)!";
|
|||
|
}
|
|||
|
if (msg == "2")
|
|||
|
{
|
|||
|
if (msg3 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("3");
|
|||
|
}
|
|||
|
else if (msg4 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("4");
|
|||
|
}
|
|||
|
else if (msg5 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("5");
|
|||
|
}
|
|||
|
else if (msg6 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("6");
|
|||
|
}
|
|||
|
|
|||
|
if (msg3 == string.Empty && msg4 == string.Empty && msg5 == string.Empty && msg6 == string.Empty)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg2,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg2,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK1"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (msg == "3")
|
|||
|
{
|
|||
|
if (msg4 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("4");
|
|||
|
}
|
|||
|
else if (msg5 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("5");
|
|||
|
}
|
|||
|
else if (msg6 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("6");
|
|||
|
}
|
|||
|
|
|||
|
if (msg4 == string.Empty && msg5 == string.Empty && msg6 == string.Empty)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg3,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg3,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK1"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
}
|
|||
|
if (msg == "4")
|
|||
|
{
|
|||
|
if (msg5 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("5");
|
|||
|
}
|
|||
|
else if (msg6 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("6");
|
|||
|
}
|
|||
|
|
|||
|
if (msg5 == string.Empty && msg6 == string.Empty)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg4,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg4,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK1"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
}
|
|||
|
if (msg == "5")
|
|||
|
{
|
|||
|
if (msg6 != string.Empty)
|
|||
|
{
|
|||
|
ViewState["msg"] = JsonConvert.SerializeObject("6");
|
|||
|
}
|
|||
|
|
|||
|
if (msg6 == string.Empty)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg5,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg5,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK1"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
if (msg == "6")
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference(msg6,
|
|||
|
String.Empty,
|
|||
|
MessageBoxIcon.Question,
|
|||
|
PageManager1.GetCustomEventReference(false, "SaveConfirm_OK"),
|
|||
|
PageManager1.GetCustomEventReference("SaveConfirm_Cancel")));
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 保存数据
|
|||
|
/// </summary>
|
|||
|
/// <returns></returns>
|
|||
|
private void isOk(List<string> sesNoList, List<FC_SESReportToCPT> fcCptList, List<View_FC_SESRelatedData> sesRelateFoList, List<SESList> sesList, List<SESList> exisSesList)
|
|||
|
{
|
|||
|
//var isSave = false;
|
|||
|
var cptList = new List<CPTList>();
|
|||
|
//删除已经存在的ses
|
|||
|
if (exisSesList.Count > 0)
|
|||
|
{
|
|||
|
var exisSes = exisSesList.Select(p => p.SES).ToList();
|
|||
|
//删除已经存在的的SESList
|
|||
|
var deleteExisSESList = Funs.DB.SESList.Where(p => exisSes.Contains(p.SES)).ToList();
|
|||
|
//删除已经存在的的FC_SESReportToCPT
|
|||
|
var deleteExisReportCpt = Funs.DB.FC_SESReportToCPT.Where(p => exisSes.Contains(p.SES_No)).ToList();
|
|||
|
//删除
|
|||
|
if (deleteExisSESList.Count > 0) Funs.DB.SESList.DeleteAllOnSubmit(deleteExisSESList);
|
|||
|
if (deleteExisReportCpt.Count > 0) Funs.DB.FC_SESReportToCPT.DeleteAllOnSubmit(deleteExisReportCpt);
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
}
|
|||
|
|
|||
|
string updateCptNo = string.Empty;
|
|||
|
|
|||
|
//数据处理
|
|||
|
if (!string.IsNullOrEmpty(txtCPTNO.Text.Trim()) || exisSesList.Count > 0)
|
|||
|
{
|
|||
|
|
|||
|
if (!string.IsNullOrEmpty(txtCPTNO.Text.Trim()))
|
|||
|
{
|
|||
|
updateCptNo = txtCPTNO.Text.Trim();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
updateCptNo = exisSesList.Select(p => p.CPT_No).Distinct().FirstOrDefault().ToString();
|
|||
|
}
|
|||
|
|
|||
|
var updateCptList = Funs.DB.CPTList.Where(p => p.CPT_No == updateCptNo).ToList();
|
|||
|
if (updateCptList.Count > 0)
|
|||
|
{
|
|||
|
foreach (var item in updateCptList)
|
|||
|
{
|
|||
|
//修改cptlist
|
|||
|
var sesMainModel = fcCptList.FirstOrDefault(p => p.FO == item.Contract_No);
|
|||
|
var sesDataModel = sesRelateFoList.FirstOrDefault(p => p.FO_NO == item.Contract_No);
|
|||
|
if (sesDataModel != null)
|
|||
|
{
|
|||
|
item.Contract_No = sesDataModel.FO_NO;
|
|||
|
item.CA = sesDataModel.Contract_Admin;
|
|||
|
item.Contractor = sesDataModel.ContractorId;
|
|||
|
item.ContractorEng = sesDataModel.Contractor_Eng;
|
|||
|
item.ContractorCN = sesDataModel.Contraor_CN;
|
|||
|
item.FC_Desctription = sesDataModel.Discipline;
|
|||
|
item.FC_Price_Scheme = sesDataModel.Pricing_SchemeId;
|
|||
|
item.FC_Start_Date = sesDataModel.Validate_Date;
|
|||
|
item.FC_End_Date = sesDataModel.Expire_Date;
|
|||
|
}
|
|||
|
if (sesMainModel != null)
|
|||
|
{
|
|||
|
item.Tax = sesMainModel.Tax_rate;
|
|||
|
item.Currency = sesMainModel.Currency;
|
|||
|
}
|
|||
|
item.Net_Amount = sesList.Where(p => p.Net_Value != null).Sum(p => p.Net_Value);
|
|||
|
item.Tax_Amount = sesList.Where(p => p.Tax_Value != null).Sum(p => p.Tax_Value).ToString();
|
|||
|
item.CT_Director = ddlCtDirector.SelectedValue;
|
|||
|
item.CT_GM = hidCTGM.Text;
|
|||
|
var commList = fcCptList.Where(p => (sesNoList.Contains(p.SES_No) && !string.IsNullOrEmpty(p.FO) && !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network))).Select(p => p.FO).ToList();
|
|||
|
if (commList.Count > 0)
|
|||
|
{
|
|||
|
item.Comment = string.Join("/", commList);
|
|||
|
}
|
|||
|
item.Report_Date = DateTime.Now;
|
|||
|
item.UserId = CurrUser.UserId;
|
|||
|
item.Last_Payment = ddlLastPayment.SelectedValue;
|
|||
|
cptList.Add(item);
|
|||
|
|
|||
|
//删除关联的SESList
|
|||
|
var deleteSESList = Funs.DB.SESList.Where(p => p.CPT_No == item.CPT_No).ToList();
|
|||
|
//删除关联的FC_SESReportToCPT
|
|||
|
var deleteSesNo = deleteSESList.Select(p => p.SES).ToList();
|
|||
|
var deleteReportCpt = Funs.DB.FC_SESReportToCPT.Where(p => deleteSesNo.Contains(p.SES_No)).ToList();
|
|||
|
//删除
|
|||
|
Funs.DB.SESList.DeleteAllOnSubmit(deleteSESList);
|
|||
|
Funs.DB.FC_SESReportToCPT.DeleteAllOnSubmit(deleteReportCpt);
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
#region CPTList
|
|||
|
var mainGroupList = fcCptList.GroupBy(p => p.FO).Select(p => p.Key).ToList();
|
|||
|
var sesDataList = sesRelateFoList.Where(p => mainGroupList.Contains(p.FO_NO)).ToList();
|
|||
|
if (mainGroupList.Count > 0)
|
|||
|
{
|
|||
|
foreach (var item in mainGroupList)
|
|||
|
{
|
|||
|
var sesMainModel = fcCptList.FirstOrDefault(p => p.FO == item);
|
|||
|
var sesDataModel = sesDataList.FirstOrDefault(p => p.FO_NO == item);
|
|||
|
CPTList cptListModel = new CPTList();
|
|||
|
cptListModel.Contract_No = item;
|
|||
|
updateCptNo = BLL.SQLHelper.RunProcNewId("SpGetNewCode4", "dbo.CPTList", "CPT_No", "CPT" + "-" + item + "-");
|
|||
|
cptListModel.CPT_No = updateCptNo;
|
|||
|
|
|||
|
if (sesDataModel != null)
|
|||
|
{
|
|||
|
cptListModel.CA = sesDataModel.Contract_Admin;
|
|||
|
cptListModel.Contractor = sesDataModel.ContractorId;
|
|||
|
cptListModel.ContractorEng = sesDataModel.Contractor_Eng;
|
|||
|
cptListModel.ContractorCN = sesDataModel.Contraor_CN;
|
|||
|
cptListModel.FC_Desctription = sesDataModel.Discipline;
|
|||
|
cptListModel.FC_Price_Scheme = sesDataModel.Pricing_SchemeId;
|
|||
|
cptListModel.FC_Start_Date = sesDataModel.Validate_Date;
|
|||
|
cptListModel.FC_End_Date = sesDataModel.Expire_Date;
|
|||
|
}
|
|||
|
if (sesMainModel != null)
|
|||
|
{
|
|||
|
cptListModel.Tax = sesMainModel.Tax_rate;
|
|||
|
cptListModel.Currency = sesMainModel.Currency;
|
|||
|
}
|
|||
|
cptListModel.Net_Amount = sesList.Where(p => p.Net_Value != null).Sum(p => p.Net_Value);
|
|||
|
cptListModel.Tax_Amount = sesList.Where(p => p.Tax_Value != null).Sum(p => p.Tax_Value).ToString();
|
|||
|
cptListModel.CT_Director = ddlCtDirector.SelectedValue;
|
|||
|
cptListModel.CT_GM = hidCTGM.Text;
|
|||
|
var commList = fcCptList.Where(p => (p.SES_No == item && !string.IsNullOrEmpty(p.FO) && !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network))).Select(p => p.FO).ToList();
|
|||
|
if (commList.Count > 0)
|
|||
|
{
|
|||
|
cptListModel.Comment = string.Join("/", commList);
|
|||
|
}
|
|||
|
cptListModel.Report_Date = DateTime.Now;
|
|||
|
cptListModel.UserId = CurrUser.UserId;
|
|||
|
cptListModel.Last_Payment = ddlLastPayment.SelectedValue;
|
|||
|
cptList.Add(cptListModel);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
//添加CPTList
|
|||
|
if (cptList.Count > 0)
|
|||
|
{
|
|||
|
Funs.DB.CPTList.InsertAllOnSubmit(cptList);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
#region 注释
|
|||
|
//if (exisSesList.Count > 0)
|
|||
|
//{
|
|||
|
// var updateCptNo = exisSesList.Select(p => p.CPT_No).ToList();
|
|||
|
// var updateCptList = Funs.DB.CPTList.Where(p => updateCptNo.Contains(p.CPT_No)).ToList();
|
|||
|
// if (updateCptList.Count > 0)
|
|||
|
// {
|
|||
|
// foreach (var item in updateCptList)
|
|||
|
// {
|
|||
|
// //修改cptlist
|
|||
|
// var sesMainModel = fcCptList.FirstOrDefault(p => p.FO == item.Contract_No);
|
|||
|
// var sesDataModel = sesRelateFoList.FirstOrDefault(p => p.FO_NO == item.Contract_No);
|
|||
|
// if (sesDataModel != null)
|
|||
|
// {
|
|||
|
// item.Contract_No = sesDataModel.FO_NO;
|
|||
|
// item.CA = sesDataModel.Contract_Admin;
|
|||
|
// item.Contractor = sesDataModel.ContractorId;
|
|||
|
// item.FC_Desctription = sesDataModel.Discipline;
|
|||
|
// item.FC_Price_Scheme = sesDataModel.Pricing_SchemeId;
|
|||
|
// }
|
|||
|
// if (sesMainModel.Start_Date != null)
|
|||
|
// {
|
|||
|
// item.FC_Start_Date = sesMainModel.Start_Date;
|
|||
|
// }
|
|||
|
// if (sesMainModel.End_Date != null)
|
|||
|
// {
|
|||
|
// item.FC_End_Date = sesMainModel.End_Date;
|
|||
|
// }
|
|||
|
// item.Net_Amount = sesList.Where(p => p.Net_Value != null).Sum(p => p.Net_Value);
|
|||
|
// item.Tax_Amount = sesList.Where(p => p.Tax_Value != null).Sum(p => p.Tax_Value).ToString();
|
|||
|
// item.Tax = sesMainModel.Tax_rate;
|
|||
|
// item.Currency = sesMainModel.Currency;
|
|||
|
// item.CT_Director = ddlCtDirector.SelectedValue;
|
|||
|
// item.CT_GM = hidCTGM.Text;
|
|||
|
// var commList = fcCptList.Where(p => (sesNoList.Contains(p.SES_No) && !string.IsNullOrEmpty(p.FO) && !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network))).Select(p => p.FO).ToList();
|
|||
|
// if (commList.Count > 0)
|
|||
|
// {
|
|||
|
// item.Comment = string.Join("/", commList);
|
|||
|
// }
|
|||
|
// item.Report_Date = DateTime.Now;
|
|||
|
// item.UserId = CurrUser.UserId;
|
|||
|
// item.Last_Payment = ddlLastPayment.SelectedValue;
|
|||
|
// cptList.Add(item);
|
|||
|
|
|||
|
// //删除关联的SESList
|
|||
|
// var deleteSESList = Funs.DB.SESList.Where(p => p.CPT_No == item.CPT_No).ToList();
|
|||
|
// //删除关联的FC_SESReportToCPT
|
|||
|
// var deleteSesNo = deleteSESList.Select(p => p.SES).ToList();
|
|||
|
// var deleteReportCpt = Funs.DB.FC_SESReportToCPT.Where(p => deleteSesNo.Contains(p.SES_No)).ToList();
|
|||
|
// //删除
|
|||
|
// Funs.DB.SESList.DeleteAllOnSubmit(deleteSESList);
|
|||
|
// Funs.DB.FC_SESReportToCPT.DeleteAllOnSubmit(deleteReportCpt);
|
|||
|
// Funs.DB.SubmitChanges();
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|
|||
|
//else
|
|||
|
//{
|
|||
|
// #region CPTList
|
|||
|
// var mainGroupList = fcCptList.GroupBy(p => p.FO).Select(p => p.Key).ToList();
|
|||
|
// var sesDataList = sesRelateFoList.Where(p => mainGroupList.Contains(p.FO_NO)).ToList();
|
|||
|
// if (mainGroupList.Count > 0)
|
|||
|
// {
|
|||
|
// foreach (var item in mainGroupList)
|
|||
|
// {
|
|||
|
// var sesMainModel = fcCptList.FirstOrDefault(p => p.FO == item);
|
|||
|
// var sesDataModel = sesDataList.FirstOrDefault(p => p.FO_NO == item);
|
|||
|
// CPTList cptListModel = new CPTList();
|
|||
|
// cptListModel.Contract_No = item;
|
|||
|
// cptListModel.CPT_No = BLL.SQLHelper.RunProcNewId("SpGetNewCode4", "dbo.CPTList", "CPT_No", "CPT" + "-" + item + "-");
|
|||
|
// if (sesDataModel != null)
|
|||
|
// {
|
|||
|
// cptListModel.CA = sesDataModel.Contract_Admin;
|
|||
|
// cptListModel.Contractor = sesDataModel.ContractorId;
|
|||
|
// cptListModel.FC_Desctription = sesDataModel.Discipline;
|
|||
|
// cptListModel.FC_Price_Scheme = sesDataModel.Pricing_SchemeId;
|
|||
|
// }
|
|||
|
// if (sesMainModel.Start_Date != null)
|
|||
|
// {
|
|||
|
// cptListModel.FC_Start_Date = sesMainModel.Start_Date;
|
|||
|
// }
|
|||
|
// if (sesMainModel.End_Date != null)
|
|||
|
// {
|
|||
|
// cptListModel.FC_End_Date = sesMainModel.End_Date;
|
|||
|
// }
|
|||
|
// cptListModel.Net_Amount = sesList.Where(p => p.Net_Value != null).Sum(p => p.Net_Value);
|
|||
|
// cptListModel.Tax_Amount = sesList.Where(p => p.Tax_Value != null).Sum(p => p.Tax_Value).ToString();
|
|||
|
// cptListModel.Tax = sesMainModel.Tax_rate;
|
|||
|
// cptListModel.Currency = sesMainModel.Currency;
|
|||
|
// cptListModel.CT_Director = ddlCtDirector.SelectedValue;
|
|||
|
// cptListModel.CT_GM = hidCTGM.Text;
|
|||
|
// var commList = fcCptList.Where(p => (p.SES_No == item && !string.IsNullOrEmpty(p.FO) && !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network))).Select(p => p.FO).ToList();
|
|||
|
// if (commList.Count > 0)
|
|||
|
// {
|
|||
|
// cptListModel.Comment = string.Join("/", commList);
|
|||
|
// }
|
|||
|
// cptListModel.Report_Date = DateTime.Now;
|
|||
|
// cptListModel.UserId = CurrUser.UserId;
|
|||
|
// cptListModel.Last_Payment = ddlLastPayment.SelectedValue;
|
|||
|
// cptList.Add(cptListModel);
|
|||
|
// }
|
|||
|
// }
|
|||
|
// #endregion
|
|||
|
|
|||
|
// //添加CPTList
|
|||
|
// if (cptList.Count > 0)
|
|||
|
// {
|
|||
|
// Funs.DB.CPTList.InsertAllOnSubmit(cptList);
|
|||
|
// }
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
//添加FC_SESReportToCPT
|
|||
|
Funs.DB.FC_SESReportToCPT.InsertAllOnSubmit(fcCptList);
|
|||
|
//添加SESList
|
|||
|
if (sesList.Count > 0)
|
|||
|
{
|
|||
|
for (int i = 0; i < fcCptList.Count; i++)
|
|||
|
{
|
|||
|
var sesModel = sesList.FirstOrDefault(p => p.SES == fcCptList[i].SES_No);
|
|||
|
var cptModel = cptList.FirstOrDefault(p => p.Contract_No == fcCptList[i].FO);
|
|||
|
if (cptModel != null)
|
|||
|
{
|
|||
|
sesModel.CPT_No = cptModel.CPT_No;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
sesModel.CPT_No = txtCPTNO.Text.Trim();
|
|||
|
}
|
|||
|
}
|
|||
|
Funs.DB.SESList.InsertAllOnSubmit(sesList);
|
|||
|
}
|
|||
|
Funs.DB.SubmitChanges();
|
|||
|
|
|||
|
// 绑定数据
|
|||
|
ddlPageSize.SelectedValue = Grid1.PageSize.ToString();
|
|||
|
BindGrid();
|
|||
|
Grid1.SelectedRowID = updateCptNo;
|
|||
|
BindGrid1(updateCptNo);
|
|||
|
|
|||
|
ShowNotify("Saved SES (" + string.Join(",", sesNoList) + ") into DB!<br/> Saved CPT " + string.Join(",", cptList.Select(p => p.CPT_No)) + " into DB!", MessageBoxIcon.Success);
|
|||
|
// 导出
|
|||
|
//ExportExcel(updateCptNo);
|
|||
|
//Response.Redirect("SESReportToCPT.aspx");
|
|||
|
|
|||
|
//return isSave;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 下载模板
|
|||
|
/// <summary>
|
|||
|
/// 下载模板
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void btnDownLoad_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
PageContext.RegisterStartupScript(Confirm.GetShowReference("Are you sure to download the import template?", String.Empty, MessageBoxIcon.Question, PageManager1.GetCustomEventReference(false, "Confirm_OK"), PageManager1.GetCustomEventReference("Confirm_Cancel")));
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 格式验证
|
|||
|
/// <summary>
|
|||
|
/// 时间格式验证
|
|||
|
/// </summary>
|
|||
|
/// <param name="time"></param>
|
|||
|
/// <returns></returns>
|
|||
|
private static string TimeValidation(object time)
|
|||
|
{
|
|||
|
string message = string.Empty;
|
|||
|
try
|
|||
|
{
|
|||
|
if (time.ToString().Contains("."))
|
|||
|
{
|
|||
|
DateTime.ParseExact(time.ToString(), "dd.MM.yyyy", CultureInfo.InvariantCulture);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
Convert.ToDateTime(time);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{
|
|||
|
message = "Please enter a valid time format!";
|
|||
|
}
|
|||
|
return message;
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 带小数的数字验证
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool IsNumber(object input)
|
|||
|
{
|
|||
|
string pattern = "^-?\\d+$|^(-?\\d+)(\\.\\d+)?$";
|
|||
|
Regex regex = new Regex(pattern);
|
|||
|
string value = input != null ? DecibelConversion(input.ToString()).ToString() : "";
|
|||
|
return regex.IsMatch(value.Trim());
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 整数
|
|||
|
/// </summary>
|
|||
|
/// <param name="strNumber"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static bool IsWholeNumber(object input)
|
|||
|
{
|
|||
|
Regex g = new Regex(@"^[-]?[0-9]\d*$");
|
|||
|
string value = input != null ? input.ToString() : "";
|
|||
|
return g.IsMatch(value);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 千分位转换
|
|||
|
/// </summary>
|
|||
|
/// <param name="input"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static decimal DecibelConversion(string input)
|
|||
|
{
|
|||
|
var inputValue = string.Empty;
|
|||
|
if (input.Contains(',') && input.Contains('.'))
|
|||
|
{
|
|||
|
var inputstr = input.Replace(".", "").Split(',');
|
|||
|
if (inputstr.Length > 0)
|
|||
|
{
|
|||
|
for (int i = 0; i < inputstr.Length; i++)
|
|||
|
{
|
|||
|
inputValue += i < (inputstr.Length - 1) ? inputstr[i] : "." + inputstr[i];
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
else if (input.Contains(','))
|
|||
|
{
|
|||
|
inputValue = input.Replace(",", ".");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
inputValue = input;
|
|||
|
}
|
|||
|
inputValue = inputValue.Length > 18 ? inputValue.Substring(0, 17) : inputValue;
|
|||
|
if (string.IsNullOrEmpty(inputValue))
|
|||
|
{
|
|||
|
inputValue = "0";
|
|||
|
}
|
|||
|
return decimal.Parse(inputValue);
|
|||
|
}
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 时间格式转换
|
|||
|
/// </summary>
|
|||
|
/// <param name="value"></param>
|
|||
|
/// <returns></returns>
|
|||
|
public static DateTime TimeValue(object value)
|
|||
|
{
|
|||
|
string dateValue = string.Empty;
|
|||
|
if (value != null)
|
|||
|
{
|
|||
|
if (value.ToString().Contains("."))
|
|||
|
{
|
|||
|
dateValue = DateTime.ParseExact(value.ToString(), "dd.MM.yyyy", CultureInfo.InvariantCulture).ToString("yyyy-MM-dd");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
dateValue = DateTime.Parse(value.ToString()).ToString("yyyy-MM-dd");
|
|||
|
}
|
|||
|
}
|
|||
|
return DateTime.Parse(dateValue);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 时间间隔
|
|||
|
/// <summary>
|
|||
|
/// 时间间隔
|
|||
|
/// </summary>
|
|||
|
/// <param name="startTime">开始时间</param>
|
|||
|
/// <param name="endTime">结束时间</param>
|
|||
|
/// <param name="timeType">返回类型1:天2:小时3:分钟4:秒数</param>
|
|||
|
/// <returns></returns>
|
|||
|
public int GetTimeSpan(DateTime startTime, DateTime endTime, int timeType = 1)
|
|||
|
{
|
|||
|
if (startTime > endTime)
|
|||
|
{
|
|||
|
return 0;
|
|||
|
}
|
|||
|
TimeSpan ts = endTime - startTime;
|
|||
|
return timeType == 1 ? ts.Days : timeType == 2 ? ts.Hours : timeType == 3 ? ts.Minutes : ts.Seconds;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Grid1点击行事件
|
|||
|
/// <summary>
|
|||
|
/// Grid1点击行时间
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
protected void Grid1_RowClick(object sender, GridRowClickEventArgs e)
|
|||
|
{
|
|||
|
BindGrid1(this.Grid1.SelectedRowID);
|
|||
|
txtCPTNO.Text = this.Grid1.SelectedRowID;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
protected void btnCancel_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
txtCPTNO.Text = string.Empty;
|
|||
|
}
|
|||
|
|
|||
|
#region 打印
|
|||
|
/// <summary>
|
|||
|
/// 打印
|
|||
|
/// </summary>
|
|||
|
/// <param name="sender"></param>
|
|||
|
/// <param name="e"></param>
|
|||
|
//protected void btnPrint_Click(object sender, EventArgs e)
|
|||
|
//{
|
|||
|
// if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
// {
|
|||
|
// Alert.ShowInParent("Please select at least one record!");
|
|||
|
// return;
|
|||
|
// }
|
|||
|
// string No = Grid1.SelectedRowID;
|
|||
|
// PageContext.RegisterStartupScript(Window2.GetShowReference(String.Format("../Report/ReportPrint.aspx?report=3&CptNo=" + No + "", "Print - ")));
|
|||
|
//}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 格式化字符串
|
|||
|
/// <summary>
|
|||
|
/// 承包商
|
|||
|
/// </summary>
|
|||
|
/// <param name="con"></param>
|
|||
|
/// <returns></returns>
|
|||
|
protected string ConvertContract(object con)
|
|||
|
{
|
|||
|
if (con != null)
|
|||
|
{
|
|||
|
var contractor = BLL.ContractorService.GetContractorById(con.ToString());
|
|||
|
if (contractor != null)
|
|||
|
{
|
|||
|
return contractor.Contractor + contractor.ContractorCN;
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
|
|||
|
protected string ConvertPriceScheme(object ps)
|
|||
|
{
|
|||
|
if (ps != null)
|
|||
|
{
|
|||
|
var priceScheme = BLL.PriceSchemeService.GetPriceSchemeById(ps.ToString());
|
|||
|
if (priceScheme != null)
|
|||
|
{
|
|||
|
return priceScheme.PriceScheme;
|
|||
|
}
|
|||
|
}
|
|||
|
return null;
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 导出
|
|||
|
/// <summary>
|
|||
|
/// 导出
|
|||
|
/// </summary>
|
|||
|
protected void btnExport_Click(object sender, EventArgs e)
|
|||
|
{
|
|||
|
if (Grid1.SelectedRowIndexArray.Length == 0)
|
|||
|
{
|
|||
|
Alert.ShowInParent("Please select at least one record!");
|
|||
|
return;
|
|||
|
}
|
|||
|
string ctpNo = Grid1.SelectedRowID;
|
|||
|
ExportExcel(ctpNo);
|
|||
|
}
|
|||
|
|
|||
|
private void ExportExcel(string cptNo)
|
|||
|
{
|
|||
|
string rootPath = Server.MapPath("~/") + Const.ExcelUrl;
|
|||
|
//模板文件
|
|||
|
string TempletFileName = rootPath + "CPTReport.xlsx";
|
|||
|
//导出文件
|
|||
|
string filePath = rootPath + DateTime.Now.ToString("yyyyMMddhhmmss") + "\\";
|
|||
|
if (!Directory.Exists(filePath))
|
|||
|
{
|
|||
|
Directory.CreateDirectory(filePath);
|
|||
|
}
|
|||
|
string ReportFileName = filePath + "out.xls";
|
|||
|
FileStream file = new FileStream(TempletFileName, FileMode.Open, FileAccess.Read);
|
|||
|
XSSFWorkbook hssfworkbook = new XSSFWorkbook(file);
|
|||
|
XSSFSheet ws = (XSSFSheet)hssfworkbook.GetSheetAt(0);
|
|||
|
var cptModel = Funs.DB.CPTList.FirstOrDefault(p => p.CPT_No == cptNo);
|
|||
|
if (cptModel != null)
|
|||
|
{
|
|||
|
//CTE/D_Manager经理
|
|||
|
var CTED_List = from a in Funs.DB.Sys_User
|
|||
|
join b in Funs.DB.Sys_Role
|
|||
|
on a.RoleId equals b.RoleId
|
|||
|
where a.IsPost == true && b.RoleName.Contains("CTE/D Manager")
|
|||
|
select new { a.UserName, a.ChineseName };
|
|||
|
var CT_Director = from x in Funs.DB.Sys_User
|
|||
|
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
|||
|
where x.UserId == cptModel.CT_Director
|
|||
|
select new { x.UserName, x.ChineseName };
|
|||
|
var CT_GM = from x in Funs.DB.Sys_User
|
|||
|
join y in Funs.DB.Sys_Role on x.RoleId equals y.RoleId
|
|||
|
where x.IsPost == true && y.RoleName.Contains("CT GM")
|
|||
|
select new { x.UserName, x.ChineseName };
|
|||
|
var basePriceScheme = Funs.DB.Base_PriceScheme.FirstOrDefault(p => p.PriceSchemeId == cptModel.FC_Price_Scheme);
|
|||
|
var cptMainModel = Funs.DB.FC_SESReportToCPT.Where(p => p.FO == cptModel.Contract_No).ToList();
|
|||
|
var sesData = Funs.DB.FC_SESRelatedData.FirstOrDefault(p => p.FO_NO == cptModel.Contract_No);
|
|||
|
var UserSESRelatedData = Funs.DB.View_FC_SESRelatedData.FirstOrDefault(p => p.FO_NO == cptModel.Contract_No);
|
|||
|
var conUser = BLL.Sys_UserService.GetUsersByUserId(cptModel.UserId);
|
|||
|
|
|||
|
#region 左边
|
|||
|
//创建时间
|
|||
|
if (ws.GetRow(1).GetCell(0) == null) ws.GetRow(1).CreateCell(0);
|
|||
|
ws.GetRow(1).GetCell(0).SetCellValue(string.Format("{0:yyyy/MM/dd HH:mm:ss}", cptModel.Report_Date));
|
|||
|
//CPT_No
|
|||
|
if (ws.GetRow(0).GetCell(14) == null) ws.GetRow(0).CreateCell(14);
|
|||
|
ws.GetRow(0).GetCell(14).SetCellValue("CPT No. " + cptModel.CPT_No);
|
|||
|
//Contract No.合同号
|
|||
|
if (ws.GetRow(6).GetCell(3) == null) ws.GetRow(6).CreateCell(3);
|
|||
|
ws.GetRow(6).GetCell(3).SetCellValue(cptModel.Contract_No);
|
|||
|
//Contractor 承包商
|
|||
|
if (ws.GetRow(10).GetCell(3) == null) ws.GetRow(10).CreateCell(3);
|
|||
|
ws.GetRow(10).GetCell(3).SetCellValue(cptModel.ContractorEng + "\n" + cptModel.ContractorCN);
|
|||
|
//FC Description 框架合同描
|
|||
|
if (ws.GetRow(14).GetCell(3) == null) ws.GetRow(14).CreateCell(3);
|
|||
|
ws.GetRow(14).GetCell(3).SetCellValue(UserSESRelatedData.Discipline_Eng + "\n" + UserSESRelatedData.Discipline_CN);
|
|||
|
//FC Price scheme 承包商价格方案
|
|||
|
if (ws.GetRow(18).GetCell(3) == null) ws.GetRow(18).CreateCell(3);
|
|||
|
ws.GetRow(18).GetCell(3).SetCellValue(UserSESRelatedData.Pricing_Scheme);
|
|||
|
//FC Valid period 框架合同有效期开始日期
|
|||
|
if (ws.GetRow(22).GetCell(3) == null) ws.GetRow(22).CreateCell(3);
|
|||
|
ws.GetRow(22).GetCell(3).SetCellValue(UserSESRelatedData.Validate_Date.HasValue ? string.Format("{0:yyyy-MM-dd}", UserSESRelatedData.Validate_Date) : "");
|
|||
|
//结束日期
|
|||
|
if (ws.GetRow(22).GetCell(7) == null) ws.GetRow(22).CreateCell(7);
|
|||
|
ws.GetRow(22).GetCell(7).SetCellValue(UserSESRelatedData.Expire_Date.HasValue ? string.Format("{0:yyyy-MM-dd}", UserSESRelatedData.Expire_Date) : "");
|
|||
|
//Amount to be paid (Net) 应付净额
|
|||
|
if (ws.GetRow(34).GetCell(0) == null) ws.GetRow(34).CreateCell(0);
|
|||
|
ws.GetRow(34).GetCell(0).SetCellValue(cptModel.Net_Amount != null ? string.Format("{0:N}", cptModel.Net_Amount.Value) : "0");//cptModel.Net_Amount.Value.ToString("0.##") : "0");
|
|||
|
//Amount to be paid (Including tax)应付含税额
|
|||
|
if (ws.GetRow(34).GetCell(3) == null) ws.GetRow(34).CreateCell(3);
|
|||
|
decimal? taxAmount = Funs.GetNewDecimal(cptModel.Tax_Amount);
|
|||
|
ws.GetRow(34).GetCell(3).SetCellValue(taxAmount != null ? string.Format("{0:N}", taxAmount) : "0");//(cptModel.Tax_Amount);
|
|||
|
//Tax税率
|
|||
|
if (ws.GetRow(34).GetCell(7) == null) ws.GetRow(34).CreateCell(7);
|
|||
|
ws.GetRow(34).GetCell(7).SetCellValue(cptModel.Tax != null ? (cptModel.Tax.Value * 100).ToString("0.##") + "%" : "0");
|
|||
|
//Currency币种
|
|||
|
if (ws.GetRow(34).GetCell(8) == null) ws.GetRow(34).CreateCell(8);
|
|||
|
ws.GetRow(34).GetCell(8).SetCellValue(cptModel.Currency);
|
|||
|
//Last Payment of This Contract本合同最后一笔付款Y/N
|
|||
|
if (ws.GetRow(38).GetCell(7) == null) ws.GetRow(38).CreateCell(7);
|
|||
|
ws.GetRow(38).GetCell(7).SetCellValue(cptModel.Last_Payment);
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 右边
|
|||
|
//Contract Administrator合同员
|
|||
|
if (ws.GetRow(10).GetCell(12) == null) ws.GetRow(10).CreateCell(12);
|
|||
|
ws.GetRow(10).GetCell(12).SetCellValue(conUser != null ? conUser.UserName + "\n" + conUser.ChineseName : "");
|
|||
|
//ws.GetRow(10).GetCell(12).SetCellValue(UserSESRelatedData != null ? UserSESRelatedData.Contract_Admin + "\n" + UserSESRelatedData.ChineseName : "");
|
|||
|
//CTE/D Manager CTE/D 经理
|
|||
|
if (ws.GetRow(14).GetCell(12) == null) ws.GetRow(14).CreateCell(12);
|
|||
|
ws.GetRow(14).GetCell(12).SetCellValue(CTED_List != null && CTED_List.Count() > 0 ? CTED_List.FirstOrDefault().UserName + "\n" + CTED_List.FirstOrDefault().ChineseName : "");
|
|||
|
//时间进程,费用进程
|
|||
|
if (sesData != null)
|
|||
|
{
|
|||
|
bool timebool = true;
|
|||
|
float timeProgress = 0f;
|
|||
|
|
|||
|
#region 时间进程
|
|||
|
if ((sesData.Validate_Date != null && sesData.Expire_Date != null))
|
|||
|
{
|
|||
|
//开始日期大于结束日期(肯定为数据错误,默认为0)
|
|||
|
if (sesData.Validate_Date < sesData.Expire_Date)
|
|||
|
{
|
|||
|
//开始日期大于当前日期,为0
|
|||
|
if (sesData.Validate_Date > DateTime.Now)
|
|||
|
{
|
|||
|
timebool = false;
|
|||
|
timeProgress = 0;
|
|||
|
}
|
|||
|
//结束日期小于当前日期
|
|||
|
if (sesData.Expire_Date < DateTime.Now)
|
|||
|
{
|
|||
|
timebool = false;
|
|||
|
timeProgress = 1;
|
|||
|
}
|
|||
|
if (timebool)
|
|||
|
{
|
|||
|
float nowSpan = GetTimeSpan(sesData.Validate_Date.Value, DateTime.Now);
|
|||
|
float allSpan = GetTimeSpan(sesData.Validate_Date.Value, sesData.Expire_Date.Value);
|
|||
|
timeProgress = nowSpan / allSpan;
|
|||
|
}
|
|||
|
//Time Progress 时间进程
|
|||
|
if (ws.GetRow(19).GetCell(12) == null) ws.GetRow(19).CreateCell(12);
|
|||
|
ws.GetRow(19).GetCell(12).SetCellValue(timeProgress);
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 费用进程
|
|||
|
float coseProgress = 0f;
|
|||
|
decimal? actualNet = BLL.CPTListService.getSumNetValueByFo(cptModel.Contract_No);
|
|||
|
if (sesData.Actual_Budget != null && actualNet != null)
|
|||
|
{
|
|||
|
|
|||
|
float actual = (float)actualNet;
|
|||
|
float total = (float)sesData.Actual_Budget;
|
|||
|
coseProgress = actual / total;
|
|||
|
//Cost Progres 费用进程
|
|||
|
if (ws.GetRow(12).GetCell(13) == null) ws.GetRow(23).CreateCell(12);
|
|||
|
ws.GetRow(23).GetCell(12).SetCellValue(coseProgress);
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
//CT Director CT总监 打印体姓名
|
|||
|
if (ws.GetRow(34).GetCell(12) == null) ws.GetRow(34).CreateCell(12);
|
|||
|
ws.GetRow(34).GetCell(12).SetCellValue(CT_Director != null && CT_Director.Count() > 0 ? CT_Director.FirstOrDefault().UserName + "\n" + CT_Director.FirstOrDefault().ChineseName : "");
|
|||
|
//CT GM CT总经理 打印体姓名
|
|||
|
if (ws.GetRow(38).GetCell(12) == null) ws.GetRow(38).CreateCell(12);
|
|||
|
ws.GetRow(38).GetCell(12).SetCellValue(CT_GM != null && CT_GM.Count() > 0 ? CT_GM.FirstOrDefault().UserName + "\n" + CT_GM.FirstOrDefault().ChineseName : "N/A");
|
|||
|
//CT Director CT总监 签字 CT GM CT总经理 签字
|
|||
|
if (taxAmount != null && taxAmount <= 300000)
|
|||
|
{
|
|||
|
if (ws.GetRow(34).GetCell(14) == null) ws.GetRow(38).CreateCell(14);
|
|||
|
ws.GetRow(34).GetCell(14).SetCellValue("N/A");
|
|||
|
if (ws.GetRow(38).GetCell(14) == null) ws.GetRow(38).CreateCell(14);
|
|||
|
ws.GetRow(38).GetCell(14).SetCellValue("N/A");
|
|||
|
}
|
|||
|
else if (taxAmount != null && taxAmount <= 500000)
|
|||
|
{
|
|||
|
if (ws.GetRow(38).GetCell(14) == null) ws.GetRow(38).CreateCell(14);
|
|||
|
ws.GetRow(38).GetCell(14).SetCellValue("N/A");
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region Remark 备注
|
|||
|
|
|||
|
if (ws.GetRow(43).GetCell(0) == null) ws.GetRow(43).CreateCell(0);
|
|||
|
ws.GetRow(43).GetCell(0).SetCellValue("Remark 备注:" + " \n\n\n\n\n\n\n\n\n\n ");
|
|||
|
if (cptMainModel.Count > 0)
|
|||
|
{
|
|||
|
if (cptMainModel.Count(p => !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network)) > 0)
|
|||
|
{
|
|||
|
//var webOrNetWork = from x in cptMainModel
|
|||
|
// join y in Funs.DB.FC_SESRelatedData on x.FO equals y.FO_NO
|
|||
|
// where (!string.IsNullOrEmpty(x.WBS) || !string.IsNullOrEmpty(x.Network))
|
|||
|
// && y.ConstRecords == "Y"
|
|||
|
// select x;
|
|||
|
|
|||
|
var webOrNetWork = from x in Funs.DB.SESList
|
|||
|
join y in Funs.DB.FC_SESReportToCPT on x.SES equals y.SES_No
|
|||
|
join z in Funs.DB.FC_SESRelatedData on y.FO equals z.FO_NO
|
|||
|
where x.CPT_No == cptNo && z.ConstRecords == "Y"
|
|||
|
&& ((y.WBS != null && y.WBS != "") || (y.Network != null && y.Network != ""))
|
|||
|
select x;
|
|||
|
|
|||
|
if (webOrNetWork.Count() > 0)
|
|||
|
{
|
|||
|
var q = from x in webOrNetWork select x.SES;
|
|||
|
//var webOrNetWork = cptMainModel.Where(p => !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network)).Select(p => p.SES_No).ToList();
|
|||
|
|
|||
|
ws.GetRow(43).GetCell(0).SetCellValue("Remark 备注:Construction records possibly needed /可能需要交工资料的:\n" + string.Join("/", q) + " \n\n\n\n\n\n\n\n Please refer to the “Confirmation of Construction Records Submission” enclosed for the status of submission.交工资料提交情况请见后附的“交工资料提交确认”。");
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 表格
|
|||
|
if (ws.GetRow(61).GetCell(14) == null) ws.GetRow(61).CreateCell(14);
|
|||
|
ws.GetRow(61).GetCell(14).SetCellValue("CPT No. " + cptModel.CPT_No);
|
|||
|
var sesSESList = Funs.DB.SESList.Where(p => p.CPT_No == cptNo).ToList();
|
|||
|
int i = 1;
|
|||
|
int rowindex = 65;
|
|||
|
//全局边框靠右
|
|||
|
ICellStyle style = hssfworkbook.CreateCellStyle();
|
|||
|
style.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style.VerticalAlignment = VerticalAlignment.Center;
|
|||
|
style.Alignment = HorizontalAlignment.Right;
|
|||
|
//全局边框靠左
|
|||
|
ICellStyle style1 = hssfworkbook.CreateCellStyle();
|
|||
|
style1.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style1.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style1.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style1.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
style1.VerticalAlignment = VerticalAlignment.Center;
|
|||
|
style1.Alignment = HorizontalAlignment.Left;
|
|||
|
//全局边框靠右千分位
|
|||
|
IDataFormat dataformat = hssfworkbook.CreateDataFormat();
|
|||
|
ICellStyle styleQfw = hssfworkbook.CreateCellStyle();
|
|||
|
styleQfw.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
styleQfw.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
styleQfw.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
styleQfw.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
styleQfw.VerticalAlignment = VerticalAlignment.Center;
|
|||
|
styleQfw.Alignment = HorizontalAlignment.Right;
|
|||
|
styleQfw.DataFormat = dataformat.GetFormat("#,##0.00");
|
|||
|
|
|||
|
#region 头部
|
|||
|
//列头边框
|
|||
|
ICellStyle titleStyle = hssfworkbook.CreateCellStyle();
|
|||
|
titleStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle.Alignment = HorizontalAlignment.Left;
|
|||
|
//字体
|
|||
|
IFont font = hssfworkbook.CreateFont();
|
|||
|
font.FontHeightInPoints = 10;
|
|||
|
font.IsBold = false;
|
|||
|
font.FontName = "Arial";
|
|||
|
titleStyle.SetFont(font);
|
|||
|
//背景色
|
|||
|
titleStyle.FillPattern = FillPattern.SolidForeground;
|
|||
|
titleStyle.FillForegroundColor = HSSFColor.LightYellow.Index;
|
|||
|
|
|||
|
//列头边框1
|
|||
|
ICellStyle titleStyle1 = hssfworkbook.CreateCellStyle();
|
|||
|
titleStyle1.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle1.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle1.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle1.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle1.Alignment = HorizontalAlignment.Left;
|
|||
|
//字体
|
|||
|
IFont font1 = hssfworkbook.CreateFont();
|
|||
|
font1.FontHeightInPoints = 10;
|
|||
|
font1.IsBold = true;
|
|||
|
font1.FontName = "Arial";
|
|||
|
titleStyle1.SetFont(font1);
|
|||
|
|
|||
|
//列头边框2
|
|||
|
ICellStyle titleStyle2 = hssfworkbook.CreateCellStyle();
|
|||
|
titleStyle2.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle2.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle2.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle2.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
titleStyle2.Alignment = HorizontalAlignment.Left;
|
|||
|
//字体
|
|||
|
IFont font2 = hssfworkbook.CreateFont();
|
|||
|
font2.FontHeightInPoints = 10;
|
|||
|
font2.IsBold = false;
|
|||
|
font2.FontName = "Arial";
|
|||
|
titleStyle2.SetFont(font2);
|
|||
|
//背景色
|
|||
|
titleStyle2.FillPattern = FillPattern.SolidForeground;
|
|||
|
titleStyle2.FillForegroundColor = HSSFColor.Grey50Percent.Index;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
foreach (var itemSes in sesSESList)
|
|||
|
{
|
|||
|
ws.CreateRow(rowindex);
|
|||
|
ws.GetRow(rowindex).HeightInPoints = 19.8f;
|
|||
|
|
|||
|
//添加表头
|
|||
|
if (i % 33 == 0)
|
|||
|
{
|
|||
|
if (ws.GetRow(rowindex) == null) ws.CreateRow(rowindex);
|
|||
|
if (ws.GetRow(rowindex + 1) == null) ws.CreateRow(rowindex + 1);
|
|||
|
ws.GetRow(rowindex + 1).HeightInPoints = 19.8f;
|
|||
|
if (ws.GetRow(rowindex + 2) == null) ws.CreateRow(rowindex + 2);
|
|||
|
ws.GetRow(rowindex + 2).HeightInPoints = 19.8f;
|
|||
|
if (ws.GetRow(rowindex + 3) == null) ws.CreateRow(rowindex + 3);
|
|||
|
ws.GetRow(rowindex + 3).HeightInPoints = 19.8f;
|
|||
|
if (ws.GetRow(rowindex + 4) == null) ws.CreateRow(rowindex + 4);
|
|||
|
ws.GetRow(rowindex + 4).HeightInPoints = 19.8f;
|
|||
|
if (i == 33)
|
|||
|
{
|
|||
|
if (ws.GetRow(rowindex + 5) == null) ws.CreateRow(rowindex + 5);
|
|||
|
ws.GetRow(rowindex + 5).HeightInPoints = 19.8f;
|
|||
|
rowindex = rowindex + 6;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
rowindex = rowindex + 5;
|
|||
|
}
|
|||
|
|
|||
|
#region cpt标题
|
|||
|
|
|||
|
//字体
|
|||
|
ICellStyle cptStyle1 = hssfworkbook.CreateCellStyle();
|
|||
|
cptStyle1.BorderBottom = NPOI.SS.UserModel.BorderStyle.None;
|
|||
|
cptStyle1.BorderLeft = NPOI.SS.UserModel.BorderStyle.None;
|
|||
|
cptStyle1.BorderRight = NPOI.SS.UserModel.BorderStyle.None;
|
|||
|
cptStyle1.BorderTop = NPOI.SS.UserModel.BorderStyle.None;
|
|||
|
cptStyle1.VerticalAlignment = VerticalAlignment.Center;
|
|||
|
cptStyle1.Alignment = HorizontalAlignment.Right;
|
|||
|
//字体
|
|||
|
IFont cptfont = hssfworkbook.CreateFont();
|
|||
|
cptfont.FontHeightInPoints = 14;
|
|||
|
cptfont.IsBold = false;
|
|||
|
cptfont.FontName = "Arial";
|
|||
|
cptStyle1.SetFont(cptfont);
|
|||
|
//创建
|
|||
|
ws.CreateRow(rowindex - 1);
|
|||
|
ws.CreateRow(rowindex - 2);
|
|||
|
ws.GetRow(rowindex - 1).HeightInPoints = ws.GetRow(rowindex - 2).HeightInPoints = 19.8f;
|
|||
|
//赋值
|
|||
|
var regiont = new CellRangeAddress(rowindex - 2, rowindex - 1, 14, 18);
|
|||
|
ws.AddMergedRegion(regiont);
|
|||
|
if (ws.GetRow(rowindex - 2).GetCell(14) == null) ws.GetRow(rowindex - 2).CreateCell(14);
|
|||
|
ws.GetRow(rowindex - 2).GetCell(14).SetCellValue("CPT No. " + cptModel.CPT_No);
|
|||
|
ws.GetRow(rowindex - 2).GetCell(14).CellStyle = cptStyle1;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 头1
|
|||
|
//列1
|
|||
|
if (ws.GetRow(rowindex) == null) ws.CreateRow(rowindex);
|
|||
|
if (ws.GetRow(rowindex).GetCell(0) == null) ws.GetRow(rowindex).CreateCell(0);
|
|||
|
ws.GetRow(rowindex).GetCell(0).SetCellValue("");
|
|||
|
ws.GetRow(rowindex).GetCell(0).CellStyle = titleStyle;
|
|||
|
//列2
|
|||
|
if (ws.GetRow(rowindex).GetCell(1) == null) ws.GetRow(rowindex).CreateCell(1);
|
|||
|
if (ws.GetRow(rowindex).GetCell(2) == null) ws.GetRow(rowindex).CreateCell(2);
|
|||
|
if (ws.GetRow(rowindex).GetCell(3) == null) ws.GetRow(rowindex).CreateCell(3);
|
|||
|
if (ws.GetRow(rowindex).GetCell(4) == null) ws.GetRow(rowindex).CreateCell(4);
|
|||
|
if (ws.GetRow(rowindex).GetCell(5) == null) ws.GetRow(rowindex).CreateCell(5);
|
|||
|
if (ws.GetRow(rowindex).GetCell(6) == null) ws.GetRow(rowindex).CreateCell(6);
|
|||
|
if (ws.GetRow(rowindex).GetCell(7) == null) ws.GetRow(rowindex).CreateCell(7);
|
|||
|
regiont = new CellRangeAddress(rowindex, rowindex, 1, 7);
|
|||
|
ws.AddMergedRegion(regiont);
|
|||
|
ws.GetRow(rowindex).GetCell(1).SetCellValue("Basic information");
|
|||
|
ws.GetRow(rowindex).GetCell(1).CellStyle = ws.GetRow(rowindex).GetCell(2).CellStyle = ws.GetRow(rowindex).GetCell(3).CellStyle = ws.GetRow(rowindex).GetCell(4).CellStyle = ws.GetRow(rowindex).GetCell(5).CellStyle = ws.GetRow(rowindex).GetCell(6).CellStyle = ws.GetRow(rowindex).GetCell(7).CellStyle = titleStyle;
|
|||
|
//列3
|
|||
|
//if (ws.GetRow(rowindex).GetCell(7) == null) ws.GetRow(rowindex).CreateCell(7);
|
|||
|
//if (ws.GetRow(rowindex).GetCell(8) == null) ws.GetRow(rowindex).CreateCell(8);
|
|||
|
//regiont = new CellRangeAddress(rowindex, rowindex, 7, 8);
|
|||
|
//ws.AddMergedRegion(regiont);
|
|||
|
//ws.GetRow(rowindex).GetCell(7).SetCellValue("Work plan");
|
|||
|
//ws.GetRow(rowindex).GetCell(7).CellStyle = ws.GetRow(rowindex).GetCell(8).CellStyle = titleStyle;
|
|||
|
|
|||
|
//列3
|
|||
|
if (ws.GetRow(rowindex).GetCell(8) == null) ws.GetRow(rowindex).CreateCell(8);
|
|||
|
if (ws.GetRow(rowindex).GetCell(9) == null) ws.GetRow(rowindex).CreateCell(9);
|
|||
|
if (ws.GetRow(rowindex).GetCell(10) == null) ws.GetRow(rowindex).CreateCell(10);
|
|||
|
if (ws.GetRow(rowindex).GetCell(11) == null) ws.GetRow(rowindex).CreateCell(11);
|
|||
|
if (ws.GetRow(rowindex).GetCell(12) == null) ws.GetRow(rowindex).CreateCell(12);
|
|||
|
regiont = new CellRangeAddress(rowindex, rowindex, 8, 12);
|
|||
|
ws.AddMergedRegion(regiont);
|
|||
|
ws.GetRow(rowindex).GetCell(8).SetCellValue("Value info");
|
|||
|
ws.GetRow(rowindex).GetCell(8).CellStyle= ws.GetRow(rowindex).GetCell(9).CellStyle = ws.GetRow(rowindex).GetCell(10).CellStyle = ws.GetRow(rowindex).GetCell(11).CellStyle = ws.GetRow(rowindex).GetCell(12).CellStyle = titleStyle2;
|
|||
|
//列4
|
|||
|
if (ws.GetRow(rowindex).GetCell(13) == null) ws.GetRow(rowindex).CreateCell(13);
|
|||
|
if (ws.GetRow(rowindex).GetCell(14) == null) ws.GetRow(rowindex).CreateCell(14);
|
|||
|
regiont = new CellRangeAddress(rowindex, rowindex, 13, 14);
|
|||
|
ws.AddMergedRegion(regiont);
|
|||
|
ws.GetRow(rowindex).GetCell(13).SetCellValue("Budget management");
|
|||
|
ws.GetRow(rowindex).GetCell(13).CellStyle = ws.GetRow(rowindex).GetCell(14).CellStyle = titleStyle;
|
|||
|
//列5
|
|||
|
if (ws.GetRow(rowindex).GetCell(15) == null) ws.GetRow(rowindex).CreateCell(15);
|
|||
|
ws.GetRow(rowindex).GetCell(15).SetCellValue("Deduction");
|
|||
|
ws.GetRow(rowindex).GetCell(15).CellStyle = titleStyle2;
|
|||
|
//列6
|
|||
|
if (ws.GetRow(rowindex).GetCell(16) == null) ws.GetRow(rowindex).CreateCell(16);
|
|||
|
if (ws.GetRow(rowindex).GetCell(17) == null) ws.GetRow(rowindex).CreateCell(17);
|
|||
|
if (ws.GetRow(rowindex).GetCell(18) == null) ws.GetRow(rowindex).CreateCell(18);
|
|||
|
regiont = new CellRangeAddress(rowindex, rowindex, 16, 18);
|
|||
|
ws.AddMergedRegion(regiont);
|
|||
|
ws.GetRow(rowindex).GetCell(16).SetCellValue("Duration(Days)");
|
|||
|
ws.GetRow(rowindex).GetCell(16).CellStyle = ws.GetRow(rowindex).GetCell(17).CellStyle = ws.GetRow(rowindex).GetCell(18).CellStyle = titleStyle;
|
|||
|
#endregion
|
|||
|
|
|||
|
#region 头2
|
|||
|
if (ws.GetRow(rowindex + 1) == null) ws.CreateRow(rowindex + 1);
|
|||
|
ws.GetRow(rowindex + 1).HeightInPoints = 19.8f;
|
|||
|
//No.
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(0) == null) ws.GetRow(rowindex + 1).CreateCell(0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(0).SetCellValue("No.");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(0).CellStyle = titleStyle1;
|
|||
|
//SES No.
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(1) == null) ws.GetRow(rowindex + 1).CreateCell(1);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(1).SetCellValue("SES No.");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(1).CellStyle = titleStyle1;
|
|||
|
//Short Description
|
|||
|
regiont = new CellRangeAddress(rowindex + 1, rowindex + 1, 2, 7);
|
|||
|
ws.AddMergedRegion(regiont);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(2) == null) ws.GetRow(rowindex + 1).CreateCell(2);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(2).SetCellValue("Short Description");
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(3) == null) ws.GetRow(rowindex + 1).CreateCell(3);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(4) == null) ws.GetRow(rowindex + 1).CreateCell(4);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(5) == null) ws.GetRow(rowindex + 1).CreateCell(5);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(6) == null) ws.GetRow(rowindex + 1).CreateCell(6);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(7) == null) ws.GetRow(rowindex + 1).CreateCell(7);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(2).CellStyle = ws.GetRow(rowindex + 1).GetCell(3).CellStyle = ws.GetRow(rowindex + 1).GetCell(4).CellStyle = ws.GetRow(rowindex + 1).GetCell(5).CellStyle = ws.GetRow(rowindex + 1).GetCell(6).CellStyle = ws.GetRow(rowindex + 1).GetCell(7).CellStyle = titleStyle1;
|
|||
|
|
|||
|
//Start
|
|||
|
//if (ws.GetRow(rowindex + 1).GetCell(7) == null) ws.GetRow(rowindex + 1).CreateCell(7);
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(7).SetCellValue("Start");
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(7).CellStyle = titleStyle1;
|
|||
|
//End
|
|||
|
//if (ws.GetRow(rowindex + 1).GetCell(8) == null) ws.GetRow(rowindex + 1).CreateCell(8);
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(8).SetCellValue("End");
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(8).CellStyle = titleStyle1;
|
|||
|
|
|||
|
//Budget(B)
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(8) == null) ws.GetRow(rowindex + 1).CreateCell(8);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(8).SetCellValue("Budget(B)");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(8).CellStyle = titleStyle1;
|
|||
|
//Quotation(Q)
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(9) == null) ws.GetRow(rowindex + 1).CreateCell(9);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(9).SetCellValue("Quotation(Q)");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(9).CellStyle = titleStyle1;
|
|||
|
//Net value(N)
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(10) == null) ws.GetRow(rowindex + 1).CreateCell(10);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(10).SetCellValue("Net value(N)");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(10).CellStyle = titleStyle1;
|
|||
|
//Incl. Tax(V)
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(11) == null) ws.GetRow(rowindex + 1).CreateCell(11);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(11).SetCellValue("Incl. Tax(V)");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(11).CellStyle = titleStyle1;
|
|||
|
|
|||
|
//Punishment(P)
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(12) == null) ws.GetRow(rowindex + 1).CreateCell(12);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(12).SetCellValue("Punishment(P)");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(12).CellStyle = titleStyle1;
|
|||
|
|
|||
|
//Deviation(N-B)改为:Deviation(N+P/(1+Tax))-B
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(13) == null) ws.GetRow(rowindex + 1).CreateCell(13);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(13).SetCellValue("Deviation");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(13).CellStyle = titleStyle1;
|
|||
|
//By perc.(N-B)/B改为:By perc.(N+P/(1+Tax)-B)/B
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(14) == null) ws.GetRow(rowindex + 1).CreateCell(14);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(14).SetCellValue("By perc.");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(14).CellStyle = titleStyle1;
|
|||
|
//Deduction(Q-V)
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(15) == null) ws.GetRow(rowindex + 1).CreateCell(15);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(15).SetCellValue("Deduction(Q-(V+P))");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(15).CellStyle = titleStyle1;
|
|||
|
//Con
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(16) == null) ws.GetRow(rowindex + 1).CreateCell(16);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(16).SetCellValue("Con");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(16).CellStyle = titleStyle1;
|
|||
|
//BoQ
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(17) == null) ws.GetRow(rowindex + 1).CreateCell(17);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(17).SetCellValue("BoQ");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(17).CellStyle = titleStyle1;
|
|||
|
//SES
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(18) == null) ws.GetRow(rowindex + 1).CreateCell(18);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(18).SetCellValue("SES");
|
|||
|
ws.GetRow(rowindex + 1).GetCell(18).CellStyle = titleStyle1;
|
|||
|
#endregion
|
|||
|
|
|||
|
rowindex = rowindex + 2;
|
|||
|
}
|
|||
|
|
|||
|
if (ws.GetRow(rowindex) == null) ws.CreateRow(rowindex);
|
|||
|
ws.GetRow(rowindex).HeightInPoints = 19.8f;
|
|||
|
//No.
|
|||
|
if (ws.GetRow(rowindex).GetCell(0) == null) ws.GetRow(rowindex).CreateCell(0);
|
|||
|
ws.GetRow(rowindex).GetCell(0).SetCellValue(i);
|
|||
|
ws.GetRow(rowindex).GetCell(0).CellStyle = style;
|
|||
|
//SES No.
|
|||
|
if (ws.GetRow(rowindex).GetCell(1) == null) ws.GetRow(rowindex).CreateCell(1);
|
|||
|
ws.GetRow(rowindex).GetCell(1).SetCellValue(itemSes.SES);
|
|||
|
ws.GetRow(rowindex).GetCell(1).CellStyle = style;
|
|||
|
|
|||
|
//Short Description
|
|||
|
CellRangeAddress regiond = new CellRangeAddress(rowindex, rowindex, 2, 7);
|
|||
|
ws.AddMergedRegion(regiond);
|
|||
|
|
|||
|
if (ws.GetRow(rowindex).GetCell(2) == null) ws.GetRow(rowindex).CreateCell(2);
|
|||
|
ws.GetRow(rowindex).GetCell(2).SetCellValue(itemSes.Short_Description);
|
|||
|
if (ws.GetRow(rowindex).GetCell(3) == null) ws.GetRow(rowindex).CreateCell(3);
|
|||
|
if (ws.GetRow(rowindex).GetCell(4) == null) ws.GetRow(rowindex).CreateCell(4);
|
|||
|
if (ws.GetRow(rowindex).GetCell(5) == null) ws.GetRow(rowindex).CreateCell(5);
|
|||
|
if (ws.GetRow(rowindex).GetCell(6) == null) ws.GetRow(rowindex).CreateCell(6);
|
|||
|
if (ws.GetRow(rowindex).GetCell(7) == null) ws.GetRow(rowindex).CreateCell(7);
|
|||
|
ws.GetRow(rowindex).GetCell(2).CellStyle = ws.GetRow(rowindex).GetCell(3).CellStyle = ws.GetRow(rowindex).GetCell(4).CellStyle = ws.GetRow(rowindex).GetCell(5).CellStyle = ws.GetRow(rowindex).GetCell(6).CellStyle = ws.GetRow(rowindex).GetCell(7).CellStyle = style1;
|
|||
|
//Start
|
|||
|
//if (ws.GetRow(rowindex).GetCell(7) == null) ws.GetRow(rowindex).CreateCell(7);
|
|||
|
//ws.GetRow(rowindex).GetCell(7).SetCellValue(itemSes.Start_Date != null ? itemSes.Start_Date.Value.ToString("dd.MM.yyyy") : "");
|
|||
|
//ws.GetRow(rowindex).GetCell(7).CellStyle = style;
|
|||
|
//End
|
|||
|
//if (ws.GetRow(rowindex).GetCell(8) == null) ws.GetRow(rowindex).CreateCell(8);
|
|||
|
//ws.GetRow(rowindex).GetCell(8).SetCellValue(itemSes.End_Date != null ? itemSes.End_Date.Value.ToString("dd.MM.yyyy") : "");
|
|||
|
//ws.GetRow(rowindex).GetCell(8).CellStyle = style;
|
|||
|
//Budget(B)
|
|||
|
if (ws.GetRow(rowindex).GetCell(8) == null) ws.GetRow(rowindex).CreateCell(8);
|
|||
|
ws.GetRow(rowindex).GetCell(8).SetCellValue(itemSes.Budget != null ? (double)itemSes.Budget.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(8).CellStyle = styleQfw;
|
|||
|
//Quotation(Q)
|
|||
|
if (ws.GetRow(rowindex).GetCell(9) == null) ws.GetRow(rowindex).CreateCell(9);
|
|||
|
ws.GetRow(rowindex).GetCell(9).SetCellValue(itemSes.Quotation != null ? (double)itemSes.Quotation.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(9).CellStyle = styleQfw;
|
|||
|
//Net value(N)
|
|||
|
if (ws.GetRow(rowindex).GetCell(10) == null) ws.GetRow(rowindex).CreateCell(10);
|
|||
|
ws.GetRow(rowindex).GetCell(10).SetCellValue(itemSes.Net_Value != null ? (double)itemSes.Net_Value.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(10).CellStyle = styleQfw;
|
|||
|
//Incl. Tax(V)
|
|||
|
if (ws.GetRow(rowindex).GetCell(11) == null) ws.GetRow(rowindex).CreateCell(11);
|
|||
|
ws.GetRow(rowindex).GetCell(11).SetCellValue(itemSes.Tax_Value != null ? (double)itemSes.Tax_Value.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(11).CellStyle = styleQfw;
|
|||
|
|
|||
|
//Punishment(P)
|
|||
|
if (ws.GetRow(rowindex).GetCell(12) == null) ws.GetRow(rowindex).CreateCell(12);
|
|||
|
ws.GetRow(rowindex).GetCell(12).SetCellValue(itemSes.Punishment != null ? (double)itemSes.Punishment.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(12).CellStyle = styleQfw;
|
|||
|
|
|||
|
//Deviation(N-B)
|
|||
|
if (ws.GetRow(rowindex).GetCell(13) == null) ws.GetRow(rowindex).CreateCell(13);
|
|||
|
decimal? dev = Funs.GetNewDecimal(itemSes.Deviation);
|
|||
|
decimal? perc = Funs.GetNewDecimal(itemSes.By_Perc);
|
|||
|
if (dev != null && dev >= 5000 && perc >= 30)
|
|||
|
{
|
|||
|
ws.GetRow(rowindex).GetCell(13).SetCellValue((double)dev);
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ws.GetRow(rowindex).GetCell(13).SetCellValue("");
|
|||
|
}
|
|||
|
//ws.GetRow(rowindex).GetCell(14).SetCellValue(dev != null ? (double)dev : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(13).CellStyle = styleQfw;
|
|||
|
//By perc.(N-B)/B
|
|||
|
if (ws.GetRow(rowindex).GetCell(14) == null) ws.GetRow(rowindex).CreateCell(14);
|
|||
|
|
|||
|
if (perc != null && dev >= 5000 && perc >= 30)
|
|||
|
{
|
|||
|
ws.GetRow(rowindex).GetCell(14).SetCellValue(string.Format("{0:N}", perc) + "%");
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ws.GetRow(rowindex).GetCell(14).SetCellValue("");
|
|||
|
}
|
|||
|
//ws.GetRow(rowindex).GetCell(15).SetCellValue(perc != null ? string.Format("{0:N}", perc * 100) + "%" : "");
|
|||
|
ws.GetRow(rowindex).GetCell(14).CellStyle = styleQfw;
|
|||
|
//Deduction(Q-V)
|
|||
|
if (ws.GetRow(rowindex).GetCell(15) == null) ws.GetRow(rowindex).CreateCell(15);
|
|||
|
decimal? dedu = Funs.GetNewDecimal(itemSes.Deduction);
|
|||
|
ws.GetRow(rowindex).GetCell(15).SetCellValue(dedu != null ? (double)dedu : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(15).CellStyle = styleQfw;
|
|||
|
//Con
|
|||
|
if (ws.GetRow(rowindex).GetCell(16) == null) ws.GetRow(rowindex).CreateCell(16);
|
|||
|
ws.GetRow(rowindex).GetCell(16).SetCellValue(itemSes.Con_Days != null ? itemSes.Con_Days.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(16).CellStyle = style;
|
|||
|
//BoQ
|
|||
|
if (ws.GetRow(rowindex).GetCell(17) == null) ws.GetRow(rowindex).CreateCell(17);
|
|||
|
ws.GetRow(rowindex).GetCell(17).SetCellValue(itemSes.BoQ_Days != null ? itemSes.BoQ_Days.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(17).CellStyle = style;
|
|||
|
//SES
|
|||
|
if (ws.GetRow(rowindex).GetCell(18) == null) ws.GetRow(rowindex).CreateCell(18);
|
|||
|
ws.GetRow(rowindex).GetCell(18).SetCellValue(itemSes.SES_Days != null ? itemSes.SES_Days.Value : 0);
|
|||
|
ws.GetRow(rowindex).GetCell(18).CellStyle = style;
|
|||
|
i++;
|
|||
|
rowindex++;
|
|||
|
}
|
|||
|
|
|||
|
//边框
|
|||
|
ICellStyle bankStyle = hssfworkbook.CreateCellStyle();
|
|||
|
bankStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
bankStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
bankStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
bankStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Thin;
|
|||
|
bankStyle.Alignment = HorizontalAlignment.Left;
|
|||
|
bankStyle.VerticalAlignment = VerticalAlignment.Center;
|
|||
|
//背景色
|
|||
|
bankStyle.FillPattern = FillPattern.SolidForeground;
|
|||
|
bankStyle.FillForegroundColor = 23;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex) == null) ws.CreateRow(rowindex);
|
|||
|
if (ws.GetRow(rowindex + 1) == null) ws.CreateRow(rowindex + 1);
|
|||
|
ws.GetRow(rowindex).HeightInPoints = 19.8f;
|
|||
|
ws.GetRow(rowindex + 1).HeightInPoints = 19.8f;
|
|||
|
|
|||
|
CellRangeAddress region = new CellRangeAddress(rowindex, rowindex, 2, 7);
|
|||
|
ws.AddMergedRegion(region);
|
|||
|
region = new CellRangeAddress(rowindex + 1, rowindex + 1, 2, 7);
|
|||
|
ws.AddMergedRegion(region);
|
|||
|
//region = new CellRangeAddress(rowindex, rowindex, 7, 8);
|
|||
|
//ws.AddMergedRegion(region);
|
|||
|
//region = new CellRangeAddress(rowindex + 1, rowindex + 1, 8, 9);
|
|||
|
//ws.AddMergedRegion(region);
|
|||
|
if (ws.GetRow(rowindex).GetCell(0) == null) ws.GetRow(rowindex).CreateCell(0);
|
|||
|
if (ws.GetRow(rowindex).GetCell(1) == null) ws.GetRow(rowindex).CreateCell(1);
|
|||
|
if (ws.GetRow(rowindex).GetCell(2) == null) ws.GetRow(rowindex).CreateCell(2);
|
|||
|
if (ws.GetRow(rowindex).GetCell(3) == null) ws.GetRow(rowindex).CreateCell(3);
|
|||
|
if (ws.GetRow(rowindex).GetCell(4) == null) ws.GetRow(rowindex).CreateCell(4);
|
|||
|
if (ws.GetRow(rowindex).GetCell(5) == null) ws.GetRow(rowindex).CreateCell(5);
|
|||
|
if (ws.GetRow(rowindex).GetCell(6) == null) ws.GetRow(rowindex).CreateCell(6);
|
|||
|
if (ws.GetRow(rowindex).GetCell(7) == null) ws.GetRow(rowindex).CreateCell(7);
|
|||
|
ws.GetRow(rowindex).GetCell(0).CellStyle = ws.GetRow(rowindex).GetCell(1).CellStyle = ws.GetRow(rowindex).GetCell(2).CellStyle = ws.GetRow(rowindex).GetCell(3).CellStyle = ws.GetRow(rowindex).GetCell(4).CellStyle = ws.GetRow(rowindex).GetCell(5).CellStyle = ws.GetRow(rowindex).GetCell(6).CellStyle = ws.GetRow(rowindex).GetCell(7).CellStyle = style;
|
|||
|
|
|||
|
//if (ws.GetRow(rowindex).GetCell(8) == null) ws.GetRow(rowindex).CreateCell(8);
|
|||
|
//ws.GetRow(rowindex).GetCell(8).SetCellValue("Total Period");
|
|||
|
//ws.GetRow(rowindex).GetCell(8).CellStyle = bankStyle;
|
|||
|
|
|||
|
//if (ws.GetRow(rowindex + 1).GetCell(7) == null) ws.GetRow(rowindex + 1).CreateCell(7);
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(7).SetCellValue(sesSESList.Min(p => p.Start_Date) != null ? sesSESList.Min(p => p.Start_Date).Value.ToString("dd.MM.yyyy") : "");
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(7).CellStyle = style;
|
|||
|
|
|||
|
//if (ws.GetRow(rowindex + 1).GetCell(8) == null) ws.GetRow(rowindex + 1).CreateCell(8);
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(8).SetCellValue(sesSESList.Max(p => p.End_Date) != null ? sesSESList.Max(p => p.End_Date).Value.ToString("dd.MM.yyyy") : "");
|
|||
|
//ws.GetRow(rowindex + 1).GetCell(8).CellStyle = style;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(0) == null) ws.GetRow(rowindex + 1).CreateCell(0);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(1) == null) ws.GetRow(rowindex + 1).CreateCell(1);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(2) == null) ws.GetRow(rowindex + 1).CreateCell(2);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(3) == null) ws.GetRow(rowindex + 1).CreateCell(3);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(4) == null) ws.GetRow(rowindex + 1).CreateCell(4);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(5) == null) ws.GetRow(rowindex + 1).CreateCell(5);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(6) == null) ws.GetRow(rowindex + 1).CreateCell(6);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(7) == null) ws.GetRow(rowindex + 1).CreateCell(7);
|
|||
|
//if (ws.GetRow(rowindex + 1).GetCell(8) == null) ws.GetRow(rowindex + 1).CreateCell(8);
|
|||
|
//if (ws.GetRow(rowindex + 1).GetCell(9) == null) ws.GetRow(rowindex + 1).CreateCell(9);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(0).CellStyle = ws.GetRow(rowindex + 1).GetCell(1).CellStyle = ws.GetRow(rowindex + 1).GetCell(2).CellStyle = ws.GetRow(rowindex + 1).GetCell(3).CellStyle = ws.GetRow(rowindex + 1).GetCell(4).CellStyle = ws.GetRow(rowindex + 1).GetCell(5).CellStyle = ws.GetRow(rowindex + 1).GetCell(6).CellStyle = ws.GetRow(rowindex + 1).GetCell(7).CellStyle = style;
|
|||
|
|
|||
|
region = new CellRangeAddress(rowindex, rowindex, 8, 12);
|
|||
|
ws.AddMergedRegion(region);
|
|||
|
if (ws.GetRow(rowindex).GetCell(8) == null) ws.GetRow(rowindex).CreateCell(8);
|
|||
|
ws.GetRow(rowindex).GetCell(8).SetCellValue("Total:");
|
|||
|
ws.GetRow(rowindex).GetCell(8).CellStyle = bankStyle;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(8) == null) ws.GetRow(rowindex + 1).CreateCell(8);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(8).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? (double)sesSESList.Sum(p => p.Budget).Value : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(8).CellStyle = styleQfw;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(9) == null) ws.GetRow(rowindex + 1).CreateCell(9);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(9).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? (double)sesSESList.Sum(p => p.Quotation).Value : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(9).CellStyle = styleQfw;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(10) == null) ws.GetRow(rowindex + 1).CreateCell(10);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(10).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? (double)sesSESList.Sum(p => p.Net_Value).Value : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(10).CellStyle = styleQfw;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(11) == null) ws.GetRow(rowindex + 1).CreateCell(11);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(11).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? (double)sesSESList.Sum(p => p.Tax_Value).Value : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(11).CellStyle = styleQfw;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(12) == null) ws.GetRow(rowindex + 1).CreateCell(12);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(12).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? (double)sesSESList.Sum(p => p.Punishment).Value : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(12).CellStyle = styleQfw;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex).GetCell(13) == null) ws.GetRow(rowindex).CreateCell(13);
|
|||
|
if (ws.GetRow(rowindex).GetCell(14) == null) ws.GetRow(rowindex).CreateCell(14);
|
|||
|
ws.GetRow(rowindex).GetCell(13).CellStyle = ws.GetRow(rowindex).GetCell(14).CellStyle = bankStyle;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex).GetCell(15) == null) ws.GetRow(rowindex).CreateCell(15);
|
|||
|
ws.GetRow(rowindex).GetCell(15).SetCellValue("Total:");
|
|||
|
ws.GetRow(rowindex).GetCell(15).CellStyle = bankStyle;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(13) == null) ws.GetRow(rowindex + 1).CreateCell(13);
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(14) == null) ws.GetRow(rowindex + 1).CreateCell(14);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(13).CellStyle = ws.GetRow(rowindex + 1).GetCell(14).CellStyle = style;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(15) == null) ws.GetRow(rowindex + 1).CreateCell(15);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(15).SetCellValue((double)sesSESList.Sum(p => double.Parse(p.Deduction)));
|
|||
|
ws.GetRow(rowindex + 1).GetCell(15).CellStyle = styleQfw;
|
|||
|
|
|||
|
region = new CellRangeAddress(rowindex, rowindex, 16, 18);
|
|||
|
ws.AddMergedRegion(region);
|
|||
|
if (ws.GetRow(rowindex).GetCell(16) == null) ws.GetRow(rowindex).CreateCell(16);
|
|||
|
ws.GetRow(rowindex).GetCell(16).SetCellValue("Average:");
|
|||
|
ws.GetRow(rowindex).GetCell(16).CellStyle = bankStyle;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(16) == null) ws.GetRow(rowindex + 1).CreateCell(16);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(16).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? Math.Round(sesSESList.Average(p => p.Con_Days != null && p.Con_Days >= 0 ? p.Con_Days : 0).Value, 0) : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(16).CellStyle = style;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(17) == null) ws.GetRow(rowindex + 1).CreateCell(17);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(17).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? Math.Round(sesSESList.Average(p => p.BoQ_Days != null && p.BoQ_Days >= 0 ? p.BoQ_Days : 0).Value, 0) : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(17).CellStyle = style;
|
|||
|
|
|||
|
if (ws.GetRow(rowindex + 1).GetCell(18) == null) ws.GetRow(rowindex + 1).CreateCell(18);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(18).SetCellValue(sesSESList != null && sesSESList.Count() > 0 ? Math.Round(sesSESList.Average(p => p.SES_Days != null && p.SES_Days >= 0 ? p.SES_Days : 0).Value, 0) : 0);
|
|||
|
ws.GetRow(rowindex + 1).GetCell(18).CellStyle = style;
|
|||
|
|
|||
|
#endregion
|
|||
|
|
|||
|
ws.ForceFormulaRecalculation = true;
|
|||
|
using (FileStream filess = File.OpenWrite(ReportFileName))
|
|||
|
{
|
|||
|
hssfworkbook.Write(filess);
|
|||
|
}
|
|||
|
FileInfo filet = new FileInfo(ReportFileName);
|
|||
|
Response.Clear();
|
|||
|
Response.Charset = "GB2312";
|
|||
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|||
|
// 添加头信息,为"文件下载/另存为"对话框指定默认文件名
|
|||
|
Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(cptNo) + ".xlsx");
|
|||
|
// 添加头信息,指定文件大小,让浏览器能够显示下载进度
|
|||
|
Response.AddHeader("Content-Length", filet.Length.ToString());
|
|||
|
// 指定返回的是一个不能被客户端读取的流,必须被下载
|
|||
|
Response.ContentType = "application/ms-excel";
|
|||
|
// 把文件流发送到客户端
|
|||
|
Response.WriteFile(filet.FullName);
|
|||
|
// 停止页面的执行
|
|||
|
Response.End();
|
|||
|
}
|
|||
|
}
|
|||
|
#endregion
|
|||
|
}
|
|||
|
}
|