提交代码
This commit is contained in:
@@ -0,0 +1,315 @@
|
||||
using BLL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.SqlClient;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using Model;
|
||||
using System.Collections;
|
||||
using Apache.NMS.ActiveMQ.Threads;
|
||||
using FineUIPro.Web.DataShow;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Aspose.Words.Lists;
|
||||
using System.Web.UI.DataVisualization.Charting;
|
||||
|
||||
namespace FineUIPro.Web.TestRun.Report
|
||||
{
|
||||
public partial class ScheduleSetUp : PageBase
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
TabStrip1.ActiveTabIndex = 0;
|
||||
DataBridYsc();
|
||||
}
|
||||
}
|
||||
|
||||
#region 预试车
|
||||
|
||||
/// <summary>
|
||||
/// 预试车绑定
|
||||
/// </summary>
|
||||
public void DataBridYsc()
|
||||
{
|
||||
if (Funs.DB.Run_ScheduleSetUp.Count(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 1) > 0)
|
||||
{
|
||||
var query = from a in Funs.DB.Run_ScheduleSetUp
|
||||
join b in Funs.DB.PreRun_WorkPackage on a.WorkPackId equals b.WorkPackId
|
||||
where a.States == 1 && a.ProjectId == this.CurrUser.LoginProjectId
|
||||
orderby b.Sort ascending
|
||||
select new Run_ScheduleSetUpDto
|
||||
{
|
||||
ScheduleId = a.ScheduleId,
|
||||
WorkPackId = a.WorkPackId,
|
||||
WorkPackName = b.WorkPackName,
|
||||
ProjectId = a.ProjectId,
|
||||
States = a.States,
|
||||
AllNum = a.AllNum,
|
||||
ProgressNum = a.ProgressNum,
|
||||
CompleteNum = a.CompleteNum,
|
||||
CompleteRate = a.CompleteRate,
|
||||
AddUser = a.AddUser,
|
||||
AddTime = a.AddTime,
|
||||
Sort = a.Sort
|
||||
};
|
||||
GridYsc.DataSource = query.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new List<Run_ScheduleSetUpDto>();
|
||||
string strSql = @"select a.WorkPackId,a.WorkPackName,(select COUNT(1) from PreRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId) as AllNum,(select COUNT(1) from PreRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=0) as ProgressNum,(select COUNT(1) from PreRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=1) as CompleteNum from PreRun_WorkPackage as a order by a.Sort"; List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
int i = 1;
|
||||
foreach (DataRow row in tb.Rows)
|
||||
{
|
||||
var model = new Run_ScheduleSetUpDto();
|
||||
model.ScheduleId = Guid.NewGuid().ToString();
|
||||
model.WorkPackId = row["WorkPackId"].ToString();
|
||||
model.WorkPackName = row["WorkPackName"].ToString();
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.States = 1;
|
||||
model.AllNum = int.Parse(row["AllNum"].ToString());
|
||||
model.ProgressNum = int.Parse(row["ProgressNum"].ToString());
|
||||
model.CompleteNum = int.Parse(row["CompleteNum"].ToString());
|
||||
var rate = model.CompleteNum > 0 ? (decimal)Math.Round((float)model.CompleteNum / (float)model.AllNum * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (rate > 100) rate = 100;
|
||||
model.CompleteRate = rate;
|
||||
model.AddUser = this.CurrUser.UserId;
|
||||
model.AddTime = DateTime.Now;
|
||||
model.Sort = i;
|
||||
result.Add(model);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
GridYsc.DataSource = result;
|
||||
}
|
||||
TabStrip1.ActiveTabIndex = 0;
|
||||
GridYsc.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预试车重置
|
||||
/// </summary>
|
||||
protected void btnYscReset_Click(object sender, EventArgs e)
|
||||
{
|
||||
var list = Funs.DB.Run_ScheduleSetUp.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 1);
|
||||
if (list.Count() > 0)
|
||||
{
|
||||
Funs.DB.Run_ScheduleSetUp.DeleteAllOnSubmit(list);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
DataBridYsc();
|
||||
ShowNotify("重置成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预试车保存
|
||||
/// </summary>
|
||||
protected void btnYscSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var deletelist = Funs.DB.Run_ScheduleSetUp.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 1);
|
||||
Funs.DB.Run_ScheduleSetUp.DeleteAllOnSubmit(deletelist);
|
||||
Funs.DB.SubmitChanges();
|
||||
var addList = new List<Run_ScheduleSetUp>();
|
||||
JArray mergedData = GridYsc.GetMergedData();
|
||||
foreach (JObject mergedRow in mergedData)
|
||||
{
|
||||
string status = mergedRow.Value<string>("status");
|
||||
JObject values = mergedRow.Value<JObject>("values");
|
||||
int i = mergedRow.Value<int>("index");
|
||||
var model = new Run_ScheduleSetUp();
|
||||
model.ScheduleId = this.GridYsc.Rows[i].DataKeys[0].ToString();
|
||||
model.WorkPackId = this.GridYsc.Rows[i].DataKeys[1].ToString();
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.States = 1;
|
||||
model.AllNum = !string.IsNullOrWhiteSpace(values.Value<string>("AllNum")) ? int.Parse(values.Value<string>("AllNum")) : 0;
|
||||
model.ProgressNum = !string.IsNullOrWhiteSpace(values.Value<string>("ProgressNum")) ? int.Parse(values.Value<string>("ProgressNum")) : 0;
|
||||
model.CompleteNum = !string.IsNullOrWhiteSpace(values.Value<string>("CompleteNum")) ? int.Parse(values.Value<string>("CompleteNum")) : 0;
|
||||
var rate = model.CompleteNum > 0 ? (decimal)Math.Round((float)model.CompleteNum / (float)model.AllNum * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (rate > 100) rate = 100;
|
||||
model.CompleteRate = rate;
|
||||
model.AddUser = this.CurrUser.UserId;
|
||||
model.AddTime = DateTime.Now;
|
||||
model.Sort = i;
|
||||
addList.Add(model);
|
||||
}
|
||||
|
||||
Funs.DB.Run_ScheduleSetUp.InsertAllOnSubmit(addList);
|
||||
Funs.DB.SubmitChanges();
|
||||
DataBridYsc();
|
||||
ShowNotify("保存成功!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotify(ex.Message, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 试车
|
||||
|
||||
/// <summary>
|
||||
/// 试车绑定
|
||||
/// </summary>
|
||||
public void DataBridSc()
|
||||
{
|
||||
if (Funs.DB.Run_ScheduleSetUp.Count(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 2) > 0)
|
||||
{
|
||||
var query = from a in Funs.DB.Run_ScheduleSetUp
|
||||
join b in Funs.DB.TestRun_WorkPackage on a.WorkPackId equals b.WorkPackId
|
||||
where a.States == 2 && a.ProjectId == this.CurrUser.LoginProjectId
|
||||
orderby b.Sort ascending
|
||||
select new Run_ScheduleSetUpDto
|
||||
{
|
||||
ScheduleId = a.ScheduleId,
|
||||
WorkPackId = a.WorkPackId,
|
||||
WorkPackName = b.WorkPackName,
|
||||
ProjectId = a.ProjectId,
|
||||
States = a.States,
|
||||
AllNum = a.AllNum,
|
||||
ProgressNum = a.ProgressNum,
|
||||
CompleteNum = a.CompleteNum,
|
||||
CompleteRate = a.CompleteRate,
|
||||
AddUser = a.AddUser,
|
||||
AddTime = a.AddTime,
|
||||
Sort = a.Sort
|
||||
};
|
||||
GridSc.DataSource = query.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = new List<Run_ScheduleSetUpDto>();
|
||||
string strSql = @"select a.WorkPackId,a.WorkPackName,(select COUNT(1) from TestRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId) as AllNum,(select COUNT(1) from TestRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=0) as ProgressNum,(select COUNT(1) from TestRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=1) as CompleteNum from TestRun_WorkPackage as a order by a.Sort"; List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (tb.Rows.Count > 0)
|
||||
{
|
||||
int i = 1;
|
||||
foreach (DataRow row in tb.Rows)
|
||||
{
|
||||
var model = new Run_ScheduleSetUpDto();
|
||||
model.ScheduleId = Guid.NewGuid().ToString();
|
||||
model.WorkPackId = row["WorkPackId"].ToString();
|
||||
model.WorkPackName = row["WorkPackName"].ToString();
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.States = 2;
|
||||
model.AllNum = int.Parse(row["AllNum"].ToString());
|
||||
model.ProgressNum = int.Parse(row["ProgressNum"].ToString());
|
||||
model.CompleteNum = int.Parse(row["CompleteNum"].ToString());
|
||||
model.CompleteRate = model.CompleteNum > 0 ? (decimal)Math.Round((float)model.CompleteNum / (float)model.AllNum, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
model.AddUser = this.CurrUser.UserId;
|
||||
model.AddTime = DateTime.Now;
|
||||
model.Sort = i;
|
||||
result.Add(model);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
GridSc.DataSource = result;
|
||||
}
|
||||
TabStrip1.ActiveTabIndex = 1;
|
||||
GridSc.DataBind();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 试车重置
|
||||
/// </summary>
|
||||
protected void btnScReset_Click(object sender, EventArgs e)
|
||||
{
|
||||
var list = Funs.DB.Run_ScheduleSetUp.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 2);
|
||||
if (list.Count() > 0)
|
||||
{
|
||||
Funs.DB.Run_ScheduleSetUp.DeleteAllOnSubmit(list);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
DataBridSc();
|
||||
ShowNotify("重置成功!", MessageBoxIcon.Success);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 试车保存
|
||||
/// </summary>
|
||||
protected void btnScSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
var deletelist = Funs.DB.Run_ScheduleSetUp.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 2);
|
||||
Funs.DB.Run_ScheduleSetUp.DeleteAllOnSubmit(deletelist);
|
||||
Funs.DB.SubmitChanges();
|
||||
var addList = new List<Run_ScheduleSetUp>();
|
||||
JArray mergedData = GridSc.GetMergedData();
|
||||
foreach (JObject mergedRow in mergedData)
|
||||
{
|
||||
string status = mergedRow.Value<string>("status");
|
||||
JObject values = mergedRow.Value<JObject>("values");
|
||||
int i = mergedRow.Value<int>("index");
|
||||
var model = new Run_ScheduleSetUp();
|
||||
model.ScheduleId = this.GridSc.Rows[i].DataKeys[0].ToString();
|
||||
model.WorkPackId = this.GridSc.Rows[i].DataKeys[1].ToString();
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.States = 2;
|
||||
model.AllNum = !string.IsNullOrWhiteSpace(values.Value<string>("AllNum")) ? int.Parse(values.Value<string>("AllNum")) : 0;
|
||||
model.ProgressNum = !string.IsNullOrWhiteSpace(values.Value<string>("ProgressNum")) ? int.Parse(values.Value<string>("ProgressNum")) : 0;
|
||||
model.CompleteNum = !string.IsNullOrWhiteSpace(values.Value<string>("CompleteNum")) ? int.Parse(values.Value<string>("CompleteNum")) : 0;
|
||||
model.CompleteRate = model.CompleteNum > 0 ? (decimal)Math.Round((float)model.CompleteNum / (float)model.AllNum, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
model.AddUser = this.CurrUser.UserId;
|
||||
model.AddTime = DateTime.Now;
|
||||
model.Sort = i;
|
||||
addList.Add(model);
|
||||
}
|
||||
|
||||
Funs.DB.Run_ScheduleSetUp.InsertAllOnSubmit(addList);
|
||||
Funs.DB.SubmitChanges();
|
||||
DataBridSc();
|
||||
ShowNotify("保存成功!");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ShowNotify(ex.Message, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 私有方法
|
||||
|
||||
/// <summary>
|
||||
/// 私有方法
|
||||
/// </summary>
|
||||
protected void TabStrip1_TabIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (TabStrip1.ActiveTabIndex == 0)
|
||||
{
|
||||
//预试车
|
||||
DataBridYsc();
|
||||
}
|
||||
else if (TabStrip1.ActiveTabIndex == 1)
|
||||
{
|
||||
//试车
|
||||
DataBridSc();
|
||||
}
|
||||
}
|
||||
|
||||
public class Run_ScheduleSetUpDto : Run_ScheduleSetUp
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user