public void Save(TestingPointType testingPoint) { string sql = "INSERT INTO TestingPointType (TypeName, Description) VALUES (@TypeName, @Description) SELECT @@identity"; using (SqlCommand cm = new SqlCommand(sql, DefaultConnection)) { SetTestingPoint(cm, testingPoint); testingPoint.Id = int.Parse(cm.ExecuteScalar().ToString()); } }
public void Update(TestingPointType testingPoint) { string sql = "Update TestingPointType SET TypeName = @TypeName, Description = @Description where Id = @testingPointId"; using (SqlCommand cm = new SqlCommand(sql, DefaultConnection)) { DatabaseHelper.InsertInt32Param("@testingPointId", cm, testingPoint.Id); SetTestingPoint(cm, testingPoint); cm.ExecuteNonQuery(); } }
private static TestingPointType GetTestingPoint(SqlDataReader dr) { TestingPointType testingPoint = new TestingPointType { Id = DatabaseHelper.GetInt32("Id", dr), Name = DatabaseHelper.GetString("TypeName", dr), Description = DatabaseHelper.GetString("Description", dr), }; return(testingPoint); }
private static void SetTestingPoint(SqlCommand cm, TestingPointType testingPoint) { DatabaseHelper.InsertStringNVarCharParam("@TypeName", cm, testingPoint.Name); DatabaseHelper.InsertStringNVarCharParam("@Description", cm, testingPoint.Description); }