126 lines
6.1 KiB
C#
126 lines
6.1 KiB
C#
using BLL;
|
||
using Model;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Linq.Expressions;
|
||
using System.Web.UI.WebControls;
|
||
|
||
namespace FineUIPro.Web.CPT
|
||
{
|
||
public partial class SESReportToCPTEdit : PageBase
|
||
{
|
||
public static Model.FCLDB db = Funs.DB;
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
string ID = Request.Params["ID"].ToString();
|
||
if (!string.IsNullOrEmpty(ID))
|
||
{
|
||
int cptid = int.Parse(ID);
|
||
var cptModel = db.CPTList.FirstOrDefault(p => p.ID == cptid);
|
||
if (cptModel != null)
|
||
{
|
||
var cptMainModel = db.FC_SESReportToCPT.Where(p => p.FO == cptModel.Contract_No).ToList();
|
||
var sesData = db.FC_SESRelatedData.FirstOrDefault(p => p.FO_NO == cptModel.Contract_No);
|
||
|
||
lblContract_No.Text = cptModel.Contract_No;
|
||
lblContractor.Text = cptModel.Contractor;
|
||
lblFC_Description.Text = cptModel.FC_Desctription;
|
||
lblFC_Price_scheme.Text = cptModel.FC_Price_Scheme;
|
||
lblFC_Start_Date.Text = cptModel.FC_Start_Date.Value != null ? cptModel.FC_Start_Date.Value.ToString("yyyy-MM-dd") : "";
|
||
lblFC_End_Date.Text = cptModel.FC_End_Date.Value != null ? cptModel.FC_End_Date.Value.ToString("yyyy-MM-dd") : "";
|
||
|
||
lblAmount_tobe_NET.Text = cptModel.Net_Amount != null ? cptModel.Net_Amount.Value.ToString("0.##") : "0";
|
||
lblAmount_tobe_Includingtax.Text = cptModel.Tax_Amount;
|
||
lblTax.Text = cptModel.Tax.ToString();
|
||
lblCurrency.Text = cptModel.Currency;
|
||
|
||
|
||
if (cptMainModel.Count > 0)
|
||
{
|
||
lblSESs.Text = string.Join("/", cptMainModel.Select(p => p.SES_No).ToList());
|
||
if (cptMainModel.Count(p => !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network)) > 0)
|
||
{
|
||
var webOrNetWork = cptMainModel.Where(p => !string.IsNullOrEmpty(p.WBS) || !string.IsNullOrEmpty(p.Network)).Select(p => p.SES_No).ToList();
|
||
lblRemark.Text = string.Join("/", webOrNetWork);
|
||
}
|
||
}
|
||
bool timebool = true;
|
||
float timeProgress = 0f;
|
||
if (sesData != null)
|
||
{
|
||
#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 = 100;
|
||
}
|
||
if (timebool)
|
||
{
|
||
int nowSpan = GetTimeSpan(DateTime.Now, sesData.Expire_Date.Value);
|
||
int allSpan = GetTimeSpan(sesData.Validate_Date.Value, sesData.Expire_Date.Value);
|
||
timeProgress = nowSpan / allSpan * 100;
|
||
}
|
||
lblTime_Progress.Text = timeProgress.ToString("0.##") + "%";
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 费用进程
|
||
decimal coseProgress = 0;
|
||
if (sesData.Actual_Budget != null && sesData.Total_Budget != null)
|
||
{
|
||
coseProgress =sesData.Actual_Budget.Value / Convert.ToDecimal(100.0*sesData.Total_Budget.Value);
|
||
lblCost_Progress.Text = coseProgress.ToString("0.##") + "%";
|
||
}
|
||
|
||
#endregion
|
||
}
|
||
|
||
//SESList
|
||
List<SESList> sesSESList = new List<SESList>();
|
||
Expression<Func<SESList, bool>> express = PredicateExtensions.True<SESList>();
|
||
var cptId = cptModel.ID.ToString();
|
||
express = express.And(p => p.CPT_No == cptId);
|
||
sesSESList = db.SESList.Where(express).ToList();
|
||
Repeater_list.DataSource = sesSESList;
|
||
Repeater_list.DataBind();
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#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
|
||
}
|
||
} |