public string Delete(Contractor oContractor, int nUserID) { string sReturnMessage = ""; Connection.Open(); Command.CommandText = ContractorDA.IUD(oContractor, EnumDBOperation.Delete, nUserID); try { Command.ExecuteNonQuery(); } catch (Exception e) { sReturnMessage = e.Message.Split('~')[0]; } Connection.Close(); return(sReturnMessage); }
public Contractor IUD(Contractor oContractor, int nUserID) { Connection.Open(); if (oContractor.ContractorID == 0) { Command.CommandText = ContractorDA.IUD(oContractor, EnumDBOperation.Insert, nUserID); } else { Command.CommandText = ContractorDA.IUD(oContractor, EnumDBOperation.Update, nUserID); } SqlDataReader reader = Command.ExecuteReader(); Contractor _oContractor = new Contractor(); if (reader.HasRows) { _oContractor = MakeObject(reader); } reader.Close(); Connection.Close(); return(_oContractor); }