250 lines
9.2 KiB
C#
250 lines
9.2 KiB
C#
using BLL;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI.WebControls;
|
|
using AspNet = System.Web.UI.WebControls;
|
|
|
|
namespace FineUIPro.Web.CQMS.PersonManage
|
|
{
|
|
public partial class TestPlanEdit : PageBase
|
|
{
|
|
/// <summary>
|
|
/// 主键
|
|
/// </summary>
|
|
public string TestPlanId
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["TestPlanId"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["TestPlanId"] = value;
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 办理类型
|
|
/// </summary>
|
|
public string State
|
|
{
|
|
get
|
|
{
|
|
return (string)ViewState["State"];
|
|
}
|
|
set
|
|
{
|
|
ViewState["State"] = value;
|
|
}
|
|
}
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
this.drpWelder.DataTextField = "PersonName";
|
|
this.drpWelder.DataValueField = "PersonId";
|
|
this.drpWelder.DataSource = (from x in Funs.DB.SitePerson_Person where x.ProjectId == this.CurrUser.LoginProjectId && x.WorkPostId == Const.WorkPost_Welder && x.States == Const.ProjectPersonStates_1 && x.IsWeldAudit == true && x.IsWeldOK == null select x).ToList();
|
|
this.drpWelder.DataBind();
|
|
Funs.FineUIPleaseSelect(this.drpWelder);
|
|
TestPlanId = Request.Params["TestPlanId"];
|
|
if (!string.IsNullOrEmpty(TestPlanId))
|
|
{
|
|
Model.Welder_TestPlan TestPlan = BLL.CQMS_TestPlanService.GetTestPlanByTestPlanId(TestPlanId);
|
|
txtTestPlanCode.Text = TestPlan.TestPlanCode;
|
|
if (TestPlan.PlanTestDate != null)
|
|
{
|
|
txtPlanTestDate.Text = string.Format("{0:yyyy-MM-dd}", TestPlan.PlanTestDate);
|
|
}
|
|
var list = BLL.CQMS_TestPlanDetailService.getListData(this.TestPlanId);
|
|
List<string> strs = BLL.CQMS_TestPlanDetailService.getPersonIdList(this.TestPlanId);
|
|
if (strs.Count > 0)
|
|
{
|
|
this.drpWelder.SelectedValueArray = strs.ToArray();
|
|
}
|
|
Grid1.DataSource = list;
|
|
Grid1.DataBind();
|
|
}
|
|
else
|
|
{
|
|
string prefix = BLL.ProjectService.GetProjectCodeByProjectId(this.CurrUser.LoginProjectId) + "-HGKS-";
|
|
txtTestPlanCode.Text = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "Welder_TestPlan", "TestPlanCode", this.CurrUser.LoginProjectId, prefix);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void Grid1_Sort(object sender, GridSortEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
protected void WindowAtt_Close(object sender, WindowCloseEventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 时间转换
|
|
/// </summary>
|
|
/// <param name="date"></param>
|
|
/// <returns></returns>
|
|
public string ConvertDate(object date)
|
|
{
|
|
if (date != null)
|
|
{
|
|
return string.Format("{0:yyyy-MM-dd}", Convert.ToDateTime(date));
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
protected void btnSave_Click(object sender, EventArgs e)
|
|
{
|
|
if (validate())
|
|
{
|
|
Saveinspection("save");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 保存
|
|
/// </summary>
|
|
public void Saveinspection(string saveType)
|
|
{
|
|
Model.Welder_TestPlan TestPlan = new Model.Welder_TestPlan();
|
|
TestPlan.ProjectId = this.CurrUser.LoginProjectId;
|
|
TestPlan.TestPlanCode = this.txtTestPlanCode.Text.Trim();
|
|
TestPlan.PlanTestDate = Funs.GetNewDateTime(this.txtPlanTestDate.Text.Trim());
|
|
if (!string.IsNullOrEmpty(this.TestPlanId))
|
|
{
|
|
TestPlan.TestPlanId = this.TestPlanId;
|
|
CQMS_TestPlanService.UpdateTestPlan(TestPlan);
|
|
LogService.AddSys_Log(CurrUser, TestPlan.TestPlanCode, TestPlan.TestPlanId, Const.CQMSWelderTestPlanMenuId, "修改焊工考试计划");
|
|
CQMS_TestPlanDetailService.DeleteTestPlanDetailsByTestPlanId(TestPlan.TestPlanId);
|
|
}
|
|
else
|
|
{
|
|
TestPlan.TestPlanId = SQLHelper.GetNewID();
|
|
TestPlan.CompileMan = this.CurrUser.PersonId;
|
|
TestPlan.CompileDate = DateTime.Now;
|
|
CQMS_TestPlanService.AddTestPlan(TestPlan);
|
|
LogService.AddSys_Log(CurrUser, TestPlan.TestPlanCode, TestPlan.TestPlanId, Const.CQMSWelderTestPlanMenuId, "增加焊工考试计划");
|
|
}
|
|
var list = addGvList();
|
|
foreach (var item in list)
|
|
{
|
|
Model.Welder_TestPlanDetail detail = new Model.Welder_TestPlanDetail();
|
|
detail.TestPlanDetailId = SQLHelper.GetNewID();
|
|
detail.TestPlanId = TestPlan.TestPlanId;
|
|
detail.PersonId = item.PersonId;
|
|
detail.QualifiedItem = item.QualifiedItem;
|
|
detail.TestItem = item.TestItem;
|
|
BLL.CQMS_TestPlanDetailService.AddTestPlanDetail(detail);
|
|
}
|
|
PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 表格数据验证
|
|
/// </summary>
|
|
private bool validate()
|
|
{
|
|
bool res = false;
|
|
string err = string.Empty;
|
|
if (this.Grid1.Rows.Count == 0)
|
|
{
|
|
err += "请选择考试焊工!";
|
|
}
|
|
//var att = BLL.AttachFileService.GetAttachFileByToKeyId(this.TestPlanId);
|
|
//if (att == null)
|
|
//{
|
|
// err += "请上传质量证明文件!";
|
|
//}
|
|
if (!string.IsNullOrWhiteSpace(err))
|
|
{
|
|
Alert.ShowInTop(err, MessageBoxIcon.Warning);
|
|
}
|
|
else
|
|
{
|
|
res = true;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 绑定表格保存到数据使用
|
|
/// </summary>
|
|
protected List<Model.Welder_TestPlanDetail> addGvList()
|
|
{
|
|
List<Model.Welder_TestPlanDetail> details = new List<Model.Welder_TestPlanDetail>();
|
|
foreach (JObject mergedRow in Grid1.GetMergedData())
|
|
{
|
|
Model.Welder_TestPlanDetail detail = new Model.Welder_TestPlanDetail();
|
|
int i = mergedRow.Value<int>("index");
|
|
JObject values = mergedRow.Value<JObject>("values");
|
|
string PersonId = values.Value<string>("PersonId");
|
|
string QualifiedItem = values.Value<string>("QualifiedItem");
|
|
string TestItem = values.Value<string>("TestItem");
|
|
detail.PersonId = PersonId;
|
|
detail.QualifiedItem = QualifiedItem;
|
|
detail.TestItem = TestItem;
|
|
details.Add(detail);
|
|
}
|
|
return details;
|
|
}
|
|
|
|
private string GetStringByArray(string[] array)
|
|
{
|
|
string str = string.Empty;
|
|
foreach (var item in array)
|
|
{
|
|
if (item != BLL.Const._Null)
|
|
{
|
|
str += item + ",";
|
|
}
|
|
}
|
|
if (!string.IsNullOrEmpty(str))
|
|
{
|
|
str = str.Substring(0, str.LastIndexOf(","));
|
|
}
|
|
return str;
|
|
}
|
|
|
|
protected void drpWelder_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
var totalWelderQualifys = from x in Funs.DB.View_Welder_WelderQualify select x;
|
|
List<Model.Welder_TestPlanDetail> details = new List<Model.Welder_TestPlanDetail>();
|
|
foreach (var item in this.drpWelder.SelectedValueArray)
|
|
{
|
|
if (item != BLL.Const._Null)
|
|
{
|
|
var welder = BLL.SitePerson_PersonService.GetSitePersonByProjectIdPersonId(this.CurrUser.LoginProjectId, item);
|
|
Model.Welder_TestPlanDetail detail = new Model.Welder_TestPlanDetail();
|
|
detail.PersonId = item;
|
|
var welderQualifys = totalWelderQualifys.Where(x => x.WelderId == item);
|
|
string qualifiedItem = string.Empty;
|
|
int i = 1;
|
|
foreach (var welderQualify in welderQualifys)
|
|
{
|
|
qualifiedItem += i + "." + welderQualify.QualificationItem + "<br/>";
|
|
i++;
|
|
}
|
|
if (!string.IsNullOrEmpty(qualifiedItem))
|
|
{
|
|
qualifiedItem = qualifiedItem.Substring(0, qualifiedItem.Length - 5);
|
|
}
|
|
detail.QualifiedItem = qualifiedItem;
|
|
details.Add(detail);
|
|
}
|
|
}
|
|
this.Grid1.DataSource = details;
|
|
this.Grid1.DataBind();
|
|
}
|
|
}
|
|
} |