CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/CQMS/Comprehensive/DesignDrawingsDataInNewEdit...

249 lines
11 KiB
C#

using BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.Comprehensive
{
public partial class DesignDrawingsDataInNewEdit : PageBase
{
#region
/// <summary>
/// 临时表主键
/// </summary>
public string TempId
{
get
{
return (string)ViewState["TempId"];
}
set
{
ViewState["TempId"] = value;
}
}
#endregion
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.TempId = Request.Params["TempId"];
this.txtValue1.Focus();
var dataInTemp = BLL.Sys_CQMS_DataInTempService.GetDataInTempByTempId(this.TempId);
if (dataInTemp != null)
{
this.txtValue1.Text = dataInTemp.Value1;
this.txtValue2.Text = dataInTemp.Value2;
this.txtValue3.Text = dataInTemp.Value3;
this.txtValue4.Text = dataInTemp.Value4;
this.txtValue5.Text = dataInTemp.Value5;
this.txtValue6.Text = dataInTemp.Value6;
this.txtValue7.Text = dataInTemp.Value7;
this.txtValue8.Text = dataInTemp.Value8;
this.txtValue9.Text = dataInTemp.Value9;
this.txtValue10.Text = dataInTemp.Value10;
this.txtValue11.Text = dataInTemp.Value11;
this.txtValue12.Text = dataInTemp.Value12;
this.lbErrCout.Text = dataInTemp.ToopValue;
}
}
}
#endregion
#region
/// <summary>
/// 保存按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnSave_Click(object sender, EventArgs e)
{
var dataInTemp = BLL.Sys_CQMS_DataInTempService.GetDataInTempByTempId(this.TempId);
if (this.ckAll.Checked)
{
var allDataInTemp = from x in Funs.DB.Sys_CQMS_DataInTemp where x.ProjectId == this.CurrUser.LoginProjectId && x.UserId == this.CurrUser.UserId && x.Type == "DesignDrawings" select x;
if (dataInTemp.Value1 != this.txtValue1.Text.Trim())
{
var tempValue1 = allDataInTemp.Where(x => x.Value1 == dataInTemp.Value1 || (x.Value1 == null && dataInTemp.Value1 == null));
if (tempValue1 != null)
{
foreach (var item in tempValue1)
{
item.Value1 = this.txtValue1.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value2 != this.txtValue2.Text.Trim())
{
var tempValue2 = allDataInTemp.Where(x => x.Value2 == dataInTemp.Value2 || (x.Value2 == null && dataInTemp.Value2 == null));
if (tempValue2 != null)
{
foreach (var item in tempValue2)
{
item.Value2 = this.txtValue2.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value3 != this.txtValue3.Text.Trim())
{
var tempValue3 = allDataInTemp.Where(x => x.Value3 == dataInTemp.Value3 || (x.Value3 == null && dataInTemp.Value3 == null));
if (tempValue3 != null)
{
foreach (var item in tempValue3)
{
item.Value3 = this.txtValue3.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value5 != this.txtValue5.Text.Trim())
{
var tempValue5 = allDataInTemp.Where(x => x.Value5 == dataInTemp.Value5 || (x.Value5 == null && dataInTemp.Value5 == null));
if (tempValue5 != null)
{
foreach (var item in tempValue5)
{
item.Value5 = this.txtValue5.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value6 != this.txtValue6.Text.Trim())
{
var tempValue6 = allDataInTemp.Where(x => x.Value6 == dataInTemp.Value6 || (x.Value6 == null && dataInTemp.Value6 == null));
if (tempValue6 != null)
{
foreach (var item in tempValue6)
{
item.Value6 = this.txtValue6.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value7 != this.txtValue7.Text.Trim())
{
var tempValue7 = allDataInTemp.Where(x => x.Value7 == dataInTemp.Value7 || (x.Value7 == null && dataInTemp.Value7 == null));
if (tempValue7 != null)
{
foreach (var item in tempValue7)
{
item.Value7 = this.txtValue7.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value8 != this.txtValue8.Text.Trim())
{
var tempValue8 = allDataInTemp.Where(x => x.Value8 == dataInTemp.Value8 || (x.Value8 == null && dataInTemp.Value8 == null));
if (tempValue8 != null)
{
foreach (var item in tempValue8)
{
item.Value8 = this.txtValue8.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value9 != this.txtValue9.Text.Trim())
{
var tempValue9 = allDataInTemp.Where(x => x.Value9 == dataInTemp.Value9 || (x.Value9 == null && dataInTemp.Value9 == null));
if (tempValue9 != null)
{
foreach (var item in tempValue9)
{
item.Value9 = this.txtValue9.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value10 != this.txtValue10.Text.Trim())
{
var tempValue10 = allDataInTemp.Where(x => x.Value10 == dataInTemp.Value10 || (x.Value10 == null && dataInTemp.Value10 == null));
if (tempValue10 != null)
{
foreach (var item in tempValue10)
{
item.Value10 = this.txtValue10.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value11 != this.txtValue11.Text.Trim())
{
var tempValue11 = allDataInTemp.Where(x => x.Value11 == dataInTemp.Value11 || (x.Value11 == null && dataInTemp.Value11 == null));
if (tempValue11 != null)
{
foreach (var item in tempValue11)
{
item.Value11 = this.txtValue11.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
if (dataInTemp.Value12 != this.txtValue12.Text.Trim())
{
var tempValue12 = allDataInTemp.Where(x => x.Value12 == dataInTemp.Value12 || (x.Value12 == null && dataInTemp.Value12 == null));
if (tempValue12 != null)
{
foreach (var item in tempValue12)
{
item.Value12 = this.txtValue12.Text.Trim();
Funs.DB.SubmitChanges();
}
}
}
var toopValue = allDataInTemp.Where(x => x.ToopValue == dataInTemp.ToopValue);
if (toopValue != null)
{
foreach (var item in toopValue)
{
item.ToopValue = null;
Funs.DB.SubmitChanges();
}
}
}
else
{
Model.Sys_CQMS_DataInTemp newDataInTemp = new Model.Sys_CQMS_DataInTemp();
newDataInTemp.ProjectId = this.CurrUser.LoginProjectId;
newDataInTemp.UserId = this.CurrUser.UserId;
newDataInTemp.Time = System.DateTime.Now;
newDataInTemp.Type = "DesignDrawings";
newDataInTemp.Value1 = this.txtValue1.Text.Trim();
newDataInTemp.Value2 = this.txtValue2.Text.Trim();
newDataInTemp.Value3 = this.txtValue3.Text.Trim();
newDataInTemp.Value4 = this.txtValue4.Text.Trim();
newDataInTemp.Value5 = this.txtValue5.Text.Trim();
newDataInTemp.Value6 = this.txtValue6.Text.Trim();
newDataInTemp.Value7 = this.txtValue7.Text.Trim();
newDataInTemp.Value8 = this.txtValue8.Text.Trim();
newDataInTemp.Value9 = this.txtValue9.Text.Trim();
newDataInTemp.Value10 = this.txtValue10.Text.Trim();
newDataInTemp.Value11 = this.txtValue11.Text.Trim();
newDataInTemp.Value12 = this.txtValue12.Text.Trim();
if (!string.IsNullOrEmpty(this.TempId))
{
newDataInTemp.TempId = this.TempId;
newDataInTemp.ToopValue = null;
BLL.Sys_CQMS_DataInTempService.UpdateDataInTemp(newDataInTemp);
}
}
ShowNotify("信息修改完成!", MessageBoxIcon.Success);
PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
}
#endregion
}
}