public string AddFixtureRetrun(Fixture_Return_MDTO dto) { Fixture_Return_M fixM = new Fixture_Return_M(); fixM.Fixture_Totake_M_UID = dto.Fixture_Totake_M_UID; fixM.Return_NO = dto.Return_NO; fixM.Return_User = dto.Return_User; fixM.Return_Name = dto.Return_Name; fixM.Return_Date = dto.Return_Date; fixM.Created_UID = dto.Created_UID; fixM.Plant_Organization_UID = dto.Plant_Organization_UID; fixM.BG_Organization_UID = dto.BG_Organization_UID; fixM.FunPlant_Organization_UID = dto.FunPlant_Organization_UID; fixM.Modified_UID = dto.Created_UID; fixM.Modified_Date = DateTime.Now; fixM.Created_Date = DateTime.Now; DataContext.Fixture_Return_M.Add(fixM); var entities = DataContext.Fixture_Totake_D.Where(x => x.Fixture_Totake_D_UID == dto.Fixture_Totake_D_UID).ToList(); foreach (var entity in entities) { entity.IS_Return = 1; } DataContext.SaveChanges(); var ret = fixM.Fixture_Return_M_UID.ToString(); return(ret); }
public int FixtureReturnUpdatePost(Fixture_Return_MDTO dto) { var list = DataContext.Fixture_Return_M.Where(x => x.Fixture_Return_M_UID == dto.Fixture_Return_M_UID).ToList(); foreach (var item in list) { item.Return_User = dto.Return_User; item.Return_User = dto.Return_Name; } return(DataContext.SaveChanges()); }
public string UpdateFixtureRetrun(Fixture_Return_MDTO dto) { var entities = DataContext.Fixture_Return_M.Where(x => x.Fixture_Return_M_UID == dto.Fixture_Return_M_UID).ToList(); foreach (var entity in entities) { entity.Return_User = dto.Return_User; entity.Return_Name = dto.Return_Name; entity.Modified_UID = dto.Modified_UID; entity.Modified_Date = dto.Modified_Date; } var ret = DataContext.SaveChanges(); return(ret + ""); }
public List <Fixture_Return_Index> ExportFixtrueReturn2Excel(Fixture_Return_MDTO searchModel) { #region 导出Excel StringBuilder sql = new StringBuilder(); sql.Append(@";With BG_Info AS ( select Organization_UID as BG_Organization_UID, Organization_Name AS OP_TYPES from System_Organization where Organization_ID LIKE'20%'), FunPlant AS( SELECT DISTINCT t2.Organization_Name as FunPlantName, one.ParentOrg_UID as BG_Organization_UID, t2.Organization_UID as FunPlant_Organization_UID FROM ( SELECT * FROM dbo.System_OrganizationBOM ) one INNER JOIN dbo.System_OrganizationBOM t1 ON one.ChildOrg_UID=t1.ParentOrg_UID INNER JOIN dbo.System_Organization t2 ON t1.ChildOrg_UID=t2.Organization_UID INNER JOIN dbo.System_Organization t3 ON t1.ParentOrg_UID=t3.Organization_UID WHERE t3.Organization_Name='OP') select distinct A.Fixture_Return_M_UID, B.Fixture_Totake_M_UID, A.Return_NO, B.Totake_NO as Taken_NO, F.Organization_Name as Plant, BG_Info.OP_TYPES as BG, FunPlant.FunPlantName as FunPlant, isnull(A.Return_User,'') as Return_User, isnull(A.Return_Name,'') as Return_Name, B.Totake_Date, A.Modified_UID, A.Modified_Date, G.Machine_ID, U.User_Name as Modified_UserName, D.Fixture_Return_D_UID from Fixture_Return_M A inner join Fixture_Totake_M B on A.Fixture_Totake_M_UID=B.Fixture_Totake_M_UID inner join Fixture_Totake_D C on B.Fixture_Totake_M_UID=C.Fixture_Totake_M_UID left join Fixture_Return_D D on D.Fixture_Return_M_UID=A.Fixture_Return_M_UID inner join Fixture_M E on E.Fixture_M_UID=C.Fixture_M_UID inner join System_Organization F on F.Organization_UID=A.Plant_Organization_UID left join Fixture_Machine G on G.Fixture_Machine_UID=E.Fixture_Machine_UID left join Production_Line P on G.Production_Line_UID=P.Production_Line_UID left join Process_Info Q on Q.Process_Info_UID=P.Process_Info_UID left join WorkStation R on R.WorkStation_UID=P.Workstation_UID left join Workshop S on S.Workshop_UID=P.Workshop_UID inner join BG_Info on BG_Info.BG_Organization_UID=A.BG_Organization_UID left join FunPlant on FunPlant.BG_Organization_UID=A.BG_Organization_UID and FunPlant.FunPlant_Organization_UID=A.FunPlant_Organization_UID left join System_Users U on U.Account_UID=A.Modified_UID where 1=1"); if (!(searchModel.Plant_Organization_UID == 0)) { sql.Append($" and A.Plant_Organization_UID = {searchModel.Plant_Organization_UID}"); } if (!(searchModel.BG_Organization_UID == 0)) { sql.Append($" and A.BG_Organization_UID = {searchModel.BG_Organization_UID}"); } if (!(searchModel.FunPlant_Organization_UID == 0) && !(searchModel.FunPlant_Organization_UID == null)) { sql.Append($" and A.FunPlant_Organization_UID = {searchModel.FunPlant_Organization_UID}"); } if (!string.IsNullOrEmpty(searchModel.Return_NO)) { sql.Append($" and A.Return_NO = '{searchModel.Return_NO}'"); } if (!string.IsNullOrEmpty(searchModel.Return_User)) { sql.Append($" and A.Return_User = '******'"); } if (!(searchModel.Modified_Date_from == DateTime.MinValue)) { sql.Append($" and A.Modified_Date > '{searchModel.Modified_Date_from}'"); } if (!(searchModel.Modified_Date_to == DateTime.MinValue)) { sql.Append($" and A.Modified_Date < '{searchModel.Modified_Date_to}'"); } //and A.Plant_Organization_UID = 1 //and A.BG_Organization_UID = 3 //and A.FunPlant_Organization_UID = 29 //and A.Return_NO = '' //and A.Return_User = '' //and A.Modified_Date > '' if (!string.IsNullOrEmpty(searchModel.Taken_NO)) { sql.Append($" and B.Totake_NO = '{searchModel.Taken_NO}'"); } //and B.Totake_NO = '' if (!string.IsNullOrEmpty(searchModel.Line_NO)) { sql.Append($" and P.Line_Name = N'{searchModel.Line_NO}'"); } //and P.Line_Name = '' if (!string.IsNullOrEmpty(searchModel.Fixture_NO)) { sql.Append($" and E.Fixture_NO = '{searchModel.Fixture_NO}'"); } if (!string.IsNullOrEmpty(searchModel.Fixture_Unique_ID)) { sql.Append($" and E.Fixture_Unique_ID = '{searchModel.Fixture_Unique_ID}'"); } if (!string.IsNullOrEmpty(searchModel.ShortCode)) { sql.Append($" and E.ShortCode = '{searchModel.ShortCode}'"); } //and E.Fixture_NO = '' //and E.Fixture_Unique_ID = '' //and E.ShortCode = '' if (!string.IsNullOrEmpty(searchModel.Machine_ID)) { sql.Append($" and G.Machine_ID = N'{searchModel.Machine_ID}'"); } //and G.Machine_ID = '' if (!string.IsNullOrEmpty(searchModel.Process_Name)) { sql.Append($" and Q.Process_Name = N'{searchModel.Process_Name}'"); } //and Q.Process_Name = '' if (!string.IsNullOrEmpty(searchModel.WorkStation_Name)) { sql.Append($" and R.WorkStation_Name = N'{searchModel.WorkStation_Name}'"); } //and R.WorkStation_Name = '' if (!string.IsNullOrEmpty(searchModel.Workshop_Name)) { sql.Append($" and S.Workshop_Name = N'{searchModel.Workshop_Name}'"); } //and S.Workshop_Name = '' if (!string.IsNullOrEmpty(searchModel.Modified_UserNTID)) { sql.Append($" and U.User_NTID = '{searchModel.Modified_UserNTID}'"); } //and U.User_NTID = '' sql.Append($@" order by A.Fixture_Return_M_UID desc"); #endregion var dbList = DataContext.Database.SqlQuery <Fixture_Return_Index>(sql.ToString()).ToList(); return(dbList); }