public bool Save(Lotto item) { string save = ""; if (this.GetData(item.Id, String.Empty, String.Empty).Count > 0) { // update save += "update lotto "; save += " set Dt = @dt"; save += " , Num1 = @num1"; save += " , Num2 = @num2"; save += " , Num3 = @num3"; save += " , Num4 = @num4"; save += " , Num5 = @num5"; save += " , Num6 = @num6"; save += " , NumBonus = @numBonus"; save += " where Id = @id"; } else { // insert save += "insert into lotto ("; save += " Id"; save += " , Dt"; save += " , Num1"; save += " , Num2"; save += " , Num3"; save += " , Num4"; save += " , Num5"; save += " , Num6"; save += " , NumBonus"; save += " ) "; save += " values "; save += " ( @id"; save += " , @dt"; save += " , @num1"; save += " , @num2"; save += " , @num3"; save += " , @num4"; save += " , @num5"; save += " , @num6"; save += " , @numBonus"; save += " )"; } ParameterCollection parameters = new ParameterCollection(); parameters.Add("@id", item.Id); parameters.Add("@dt", item.Dt); parameters.Add("@num1", item.Num1); parameters.Add("@num2", item.Num2); parameters.Add("@num3", item.Num3); parameters.Add("@num4", item.Num4); parameters.Add("@num5", item.Num5); parameters.Add("@num6", item.Num6); parameters.Add("@numBonus", item.NumBonus); DataService dao = new DataService(); dao.SetConnectionString(this.GetConnectionString()); dao.AddRequestService(CommandType.Text, save, parameters, ExecuteType.ExecuteNonQuery); List<ResponseService> responses = dao.Execute(); if (dao.HasError) { Logger.Error(dao.GetType(), dao.ErrorMessage); DebugHelper.WriteLine(dao.ErrorMessage); return false; } else { return true; } }
public bool Delete(Lotto item) { string delete = ""; if (this.GetData(item.Id, String.Empty, String.Empty).Count > 0) { // update delete += "delete from lotto "; delete += " where Id = @id"; } else { return false; } ParameterCollection parameters = new ParameterCollection(); parameters.Add("@id", item.Id); //parameters.Add("@dt", item.Dt); //parameters.Add("@num1", item.Num1); //parameters.Add("@num1", item.Num2); //parameters.Add("@num1", item.Num3); //parameters.Add("@num1", item.Num4); //parameters.Add("@num1", item.Num5); //parameters.Add("@num1", item.Num6); DataService dao = new DataService(); dao.SetConnectionString(this.GetConnectionString()); dao.AddRequestService(CommandType.Text, delete, parameters, ExecuteType.ExecuteNonQuery); List<ResponseService> responses = dao.Execute(); if (dao.HasError) { Logger.Error(dao.GetType(), dao.ErrorMessage); DebugHelper.WriteLine(dao.ErrorMessage); return false; } else { return true; } }