private void UpdatetData(CS_ItemsAnalysisParameters IAP) { try { conn.Open(); string sql = @"UPDATE CS_ItemsAnalysisParameters SET " + $" UoM = '{ IAP.UoM }' " + $",Parameter = '{ IAP.Parameter }' " + $",AnalysisMethod = '{ IAP.AnalysisMethod }' " + $",AnalysisArea = { IAP.AnalysisArea } " + $",UpperBound = '{ IAP.UpperBound }' " + $",LowerBound = '{ IAP.LowerBound }' " + $",DetectableBound = '{ IAP.DetectableBound }' " + $",ExpectedNumResult = { IAP.ExpectedNumResult } " + $",ExpectedResult = '{ IAP.ExpectedResult }' " + $",Revision = { IAP.Revision } " + $",InsertionDate = '{ IAP.InsertionDate }' " + $",TBCreated = '{ DateTime.Now }' " + $",TBModified = '{ DateTime.Now }' WHERE IdSimulation = { IAP.IdSimulation } AND Item = '{ IAP.Item }' AND Line = { IAP.Line }"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { conn.Close(); throw ex; } }
public List <CS_ItemsAnalysisParameters> GetAll(int idsimulation, string item) { try { bool hasRow = HasRowsQualityTB(); if (hasRow) { List <CS_ItemsAnalysisParameters> list = new List <CS_ItemsAnalysisParameters>(); conn.Open(); string sql = $"SELECT * FROM CS_ItemsAnalysisParameters WHERE IdSimulation = { idsimulation } AND Item = '{ item }'"; SqlCommand cmd = new SqlCommand(sql, conn); SqlDataReader reader = cmd.ExecuteReader(); if (reader.HasRows) { while (reader.Read()) { CS_ItemsAnalysisParameters iap = new CS_ItemsAnalysisParameters(); iap.Item = reader["Item"].ToString().Trim(); iap.Line = (short)Convert.ToInt32(reader["Line"]); iap.Parameter = reader["Parameter"].ToString().Trim(); iap.UoM = reader["UoM"].ToString().Trim(); iap.ExpectedNumResult = Convert.ToDouble(reader["ExpectedNumResult"]); iap.AnalysisMethod = reader["AnalysisMethod"].ToString().Trim(); iap.AnalysisArea = Convert.ToInt32(reader["AnalysisArea"]); iap.LowerBound = reader["LowerBound"].ToString().Trim(); iap.UpperBound = reader["UpperBound"].ToString().Trim(); iap.DetectableBound = reader["DetectableBound"].ToString().Trim(); iap.Revision = Convert.ToDouble(reader["Revision"]); iap.IdSimulation = Convert.ToInt32(reader["IdSimulation"]); iap.InsertionDate = Convert.ToDateTime(reader["InsertionDate"]); list.Add(iap); } conn.Close(); return(list); } else { return(null); } } else { conn.Close(); return(null); } } catch (Exception ex) { conn.Close(); throw ex; } }
private void InsertData(CS_ItemsAnalysisParameters IAP) { try { int line = GetMaxLineQA(); conn.Open(); string sql = @"INSERT INTO CS_ItemsAnalysisParameters (Item ,Line ,UoM ,Parameter ,AnalysisMethod ,AnalysisArea ,UpperBound ,LowerBound ,DetectableBound ,ExpectedNumResult ,ExpectedResult ,ToBePrinted ,Revision ,DisabledDate ,InsertionDate ,Customer ,Notes ,Disabled ,IdSimulation ,TBCreated ,TBModified ,TBCreatedID ,TBModifiedID ,TBGuid) " + $"VALUES ('{ IAP.Item }'," + $"{ line }," + $"'{ IAP.UoM }'," + $"'{ IAP.Parameter }'," + $"'{ IAP.AnalysisMethod }'," + $"{ IAP.AnalysisArea }," + $"'{ IAP.UpperBound }'," + $"'{ IAP.LowerBound }'," + $"'{ IAP.DetectableBound }'," + $"{ IAP.ExpectedNumResult.ToString().Replace(",", ".") }," + $"'{ IAP.ExpectedResult }'," + $"'{ IAP.ToBePrinted }'," + $"{ IAP.Revision.ToString().Replace(",", ".") }," + $"'{ IAP.DisabledDate }'," + $"'{ IAP.InsertionDate }'," + $"'{ IAP.Customer }'," + $"'{ IAP.Notes }'," + $"'{ IAP.Disabled }'," + $"{ IAP.IdSimulation }," + $"'{ DateTime.Now }'," + $"'{ DateTime.Now }'," + $"{ 1 }," + $"{ 1 }," + $"'{ Guid.NewGuid() }')"; SqlCommand cmd = new SqlCommand(sql, conn); cmd.ExecuteNonQuery(); conn.Close(); } catch (Exception ex) { conn.Close(); throw ex; } }