Пример #1
0
        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);
        }
Пример #2
0
        public bool InsertMachineLine(string name)
        {
            SPG.MachineLinesDataTable machineLines = new SPG.MachineLinesDataTable();
            SPG.MachineLinesRow       machineLine  = machineLines.NewMachineLinesRow();

            if (string.IsNullOrEmpty(name))
            {
                throw new ApplicationException("You must provide Machine Line Name.");
            }

            machineLine.MachineLineName = name;

            machineLines.AddMachineLinesRow(machineLine);
            int rowsAffected = Adapter.Update(machineLines);

            return(rowsAffected == 1);
        }
Пример #3
0
        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);
        }