public bool UpdateMachineLine(int?id, string name) { SPG.MachineLinesDataTable machineLines = Adapter.GetMachineLineByID(id.Value); if (machineLines.Count() == 0) { //It is a new Product return(InsertMachineLine(name)); } SPG.MachineLinesRow machineLine = machineLines[0]; if (string.IsNullOrEmpty(name)) { throw new ApplicationException("You must provide Machine Line Name."); } object[] originalRecord = machineLine.ItemArray; machineLine.MachineLineName = name; if (!(originalRecord == null)) { UpdateAuditTrail(machineLine, originalRecord); } int rowsAffected = Adapter.Update(machineLine); return(rowsAffected == 1); }
public bool DeleteMachineLine(int id) { SPG.MachineLinesDataTable machineLines = Adapter.GetMachineLineByID(id); int rowsAffected = 0; if (machineLines.Count() == 1) { SPG.MachineLinesRow machineLine = (SPG.MachineLinesRow)machineLines.Rows[0]; if ((new ProductionBLL()).GetProductionByMachine(id).Count != 0) { MessageBox.Show("You can't delete this machineLine there are other records associated to it"); return(true); } rowsAffected = Adapter.Delete(id, machineLine.ts); } //Return true if precisely one row was deleted, otherwise return false. return(rowsAffected == 1); }