Basf_TCC7/HJGL/BLL/WeldingProcess/DataIn/DataInTempService.cs

193 lines
8.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Linq;
namespace BLL
{
/// <summary>
/// 导入临时表
/// </summary>
public static class DataInTempService
{
/// <summary>
/// 根据主键获取导入临时表信息
/// </summary>
/// <param name="tempId">Id</param>
/// <returns></returns>
public static Model.Sys_DataInTemp GetDataInTempByTempId(string tempId)
{
return Funs.DB.Sys_DataInTemp.FirstOrDefault(x => x.TempId == tempId);
}
/// <summary>
/// 增加导入临时表记录
/// </summary>
/// <param name="dataInTemp">委托实体</param>
public static void AddDataInTemp(Model.Sys_DataInTemp dataInTemp)
{
Model.HJGLDB db = Funs.DB;
Model.Sys_DataInTemp newDataInTemp = new Model.Sys_DataInTemp();
newDataInTemp.TempId = dataInTemp.TempId;
newDataInTemp.ProjectId = dataInTemp.ProjectId;
newDataInTemp.UserId = dataInTemp.UserId;
newDataInTemp.Time = dataInTemp.Time;
newDataInTemp.RowNo = dataInTemp.RowNo;
newDataInTemp.Value1 = dataInTemp.Value1;
newDataInTemp.Value2 = dataInTemp.Value2;
newDataInTemp.Value3 = dataInTemp.Value3;
newDataInTemp.Value4 = dataInTemp.Value4;
newDataInTemp.Value5 = dataInTemp.Value5;
newDataInTemp.Value6 = dataInTemp.Value6;
newDataInTemp.Value7 = dataInTemp.Value7;
newDataInTemp.Value8 = dataInTemp.Value8;
newDataInTemp.Value9 = dataInTemp.Value9;
newDataInTemp.Value10 = dataInTemp.Value10;
newDataInTemp.Value11 = dataInTemp.Value11;
newDataInTemp.Value12 = dataInTemp.Value12;
newDataInTemp.Value13 = dataInTemp.Value13;
newDataInTemp.Value14 = dataInTemp.Value14;
newDataInTemp.Value15 = dataInTemp.Value15;
newDataInTemp.Value16 = dataInTemp.Value16;
newDataInTemp.Value17 = dataInTemp.Value17;
newDataInTemp.Value18 = dataInTemp.Value18;
newDataInTemp.Value19 = dataInTemp.Value19;
newDataInTemp.Value20 = dataInTemp.Value20;
newDataInTemp.Value21 = dataInTemp.Value21;
newDataInTemp.Value22 = dataInTemp.Value22;
newDataInTemp.Value23 = dataInTemp.Value23;
newDataInTemp.Value24 = dataInTemp.Value24;
newDataInTemp.Value25 = dataInTemp.Value25;
newDataInTemp.Value26 = dataInTemp.Value26;
newDataInTemp.Value27 = dataInTemp.Value27;
newDataInTemp.Value28 = dataInTemp.Value28;
newDataInTemp.Value29 = dataInTemp.Value29;
newDataInTemp.Value30 = dataInTemp.Value30;
newDataInTemp.Value31 = dataInTemp.Value31;
newDataInTemp.Value32 = dataInTemp.Value32;
newDataInTemp.Value33 = dataInTemp.Value33;
newDataInTemp.Value34 = dataInTemp.Value34;
newDataInTemp.Value35 = dataInTemp.Value35;
newDataInTemp.Value36 = dataInTemp.Value36;
newDataInTemp.Value37 = dataInTemp.Value37;
newDataInTemp.Value38 = dataInTemp.Value38;
newDataInTemp.ToopValue = dataInTemp.ToopValue;
db.Sys_DataInTemp.InsertOnSubmit(newDataInTemp);
db.SubmitChanges();
}
/// <summary>
/// 修改导入临时表记录
/// </summary>
/// <param name="weldReport">焊接实体</param>
public static void UpdateDataInTemp(Model.Sys_DataInTemp dataInTemp)
{
Model.HJGLDB db = Funs.DB;
Model.Sys_DataInTemp newDataInTemp = db.Sys_DataInTemp.FirstOrDefault(e => e.TempId == dataInTemp.TempId);
if (newDataInTemp != null)
{
newDataInTemp.UserId = dataInTemp.UserId;
newDataInTemp.Time = dataInTemp.Time;
newDataInTemp.Value1 = dataInTemp.Value1;
newDataInTemp.Value2 = dataInTemp.Value2;
newDataInTemp.Value3 = dataInTemp.Value3;
newDataInTemp.Value4 = dataInTemp.Value4;
newDataInTemp.Value5 = dataInTemp.Value5;
newDataInTemp.Value6 = dataInTemp.Value6;
newDataInTemp.Value7 = dataInTemp.Value7;
newDataInTemp.Value8 = dataInTemp.Value8;
newDataInTemp.Value9 = dataInTemp.Value9;
newDataInTemp.Value10 = dataInTemp.Value10;
newDataInTemp.Value11 = dataInTemp.Value11;
newDataInTemp.Value12 = dataInTemp.Value12;
newDataInTemp.Value13 = dataInTemp.Value13;
newDataInTemp.Value14 = dataInTemp.Value14;
newDataInTemp.Value15 = dataInTemp.Value15;
newDataInTemp.Value16 = dataInTemp.Value16;
newDataInTemp.Value17 = dataInTemp.Value17;
newDataInTemp.Value18 = dataInTemp.Value18;
newDataInTemp.Value19 = dataInTemp.Value19;
newDataInTemp.Value20 = dataInTemp.Value20;
newDataInTemp.Value21 = dataInTemp.Value21;
newDataInTemp.Value22 = dataInTemp.Value22;
newDataInTemp.Value23 = dataInTemp.Value23;
newDataInTemp.Value24 = dataInTemp.Value24;
newDataInTemp.Value25 = dataInTemp.Value25;
newDataInTemp.Value26 = dataInTemp.Value26;
newDataInTemp.Value27 = dataInTemp.Value27;
newDataInTemp.Value28 = dataInTemp.Value28;
newDataInTemp.Value29 = dataInTemp.Value29;
newDataInTemp.Value30 = dataInTemp.Value30;
newDataInTemp.Value31 = dataInTemp.Value31;
newDataInTemp.Value32 = dataInTemp.Value32;
newDataInTemp.Value33 = dataInTemp.Value33;
newDataInTemp.Value34 = dataInTemp.Value34;
newDataInTemp.Value35 = dataInTemp.Value35;
newDataInTemp.Value36 = dataInTemp.Value36;
newDataInTemp.Value37 = dataInTemp.Value37;
newDataInTemp.Value38 = dataInTemp.Value38;
newDataInTemp.ToopValue = dataInTemp.ToopValue;
try
{
db.SubmitChanges(System.Data.Linq.ConflictMode.ContinueOnConflict);
}
catch (System.Data.Linq.ChangeConflictException ex)
{
foreach (System.Data.Linq.ObjectChangeConflict occ in db.ChangeConflicts)
{
// 使用Linq缓存中实体对象的值覆盖当前数据库中的值
occ.Resolve(System.Data.Linq.RefreshMode.KeepCurrentValues);
}
// 这个地方要注意Catch方法中我们前面只是指明了怎样来解决冲突这个地方还需要再次提交更新这样的话值 //才会提交到数据库。
db.SubmitChanges();
}
}
}
/// <summary>
/// 根据主键删除导入临时表记录
/// </summary>
/// <param name="tempId">委托主键</param>
public static void DeleteDataInTempByDataInTempID(string tempId)
{
Model.HJGLDB db = Funs.DB;
Model.Sys_DataInTemp dataInTemp = db.Sys_DataInTemp.FirstOrDefault(e => e.TempId == tempId);
if (dataInTemp != null)
{
db.Sys_DataInTemp.DeleteOnSubmit(dataInTemp);
db.SubmitChanges();
}
}
/// <summary>
/// 根据项目用户主键删除导入临时表记录
/// </summary>
/// <param name="projectId"></param>
/// <param name="userId"></param>
public static void DeleteDataInTempByProjectIdAndUserId(string projectId,string userId)
{
Model.HJGLDB db = Funs.DB;
var dataInTemp = from x in db.Sys_DataInTemp where x.ProjectId == projectId && x.UserId == userId select x;
if (dataInTemp.Count() > 0)
{
db.Sys_DataInTemp.DeleteAllOnSubmit(dataInTemp);
db.SubmitChanges();
}
}
/// <summary>
/// 删除当前用户区域导入的数据
/// </summary>
/// <param name="projectId">项目</param>
/// <param name="userId">用户</param>
/// <param name="area">区域</param>
public static void DeleteDataInTemp(string projectId, string userId,string area)
{
Model.HJGLDB db = Funs.DB;
var dataInTemp = from x in db.Sys_DataInTemp where x.ProjectId == projectId && x.UserId == userId && x.Value2==area select x;
if (dataInTemp.Count() > 0)
{
db.Sys_DataInTemp.DeleteAllOnSubmit(dataInTemp);
db.SubmitChanges();
}
}
}
}