예제 #1
0
파일: ShiftsBLL.cs 프로젝트: shulemg/SPG
        public bool UpdateShift(int?id, string name)
        {
            SPG.ShiftsDataTable shifts = Adapter.GetShiftByID(id.Value);

            if (shifts.Count() == 0)
            {
                //It is a new Product
                return(InsertShift(name));
            }

            SPG.ShiftsRow shift = shifts[0];

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

            object[] originalRecord = shift.ItemArray;

            shift.ShiftName = name;

            if (!(originalRecord == null))
            {
                UpdateAuditTrail(shift, originalRecord);
            }

            int rowsAffected = Adapter.Update(shift);

            return(rowsAffected == 1);
        }
예제 #2
0
파일: ShiftsBLL.cs 프로젝트: shulemg/SPG
        public bool InsertShift(string name)
        {
            SPG.ShiftsDataTable shifts = new SPG.ShiftsDataTable();
            SPG.ShiftsRow       shift  = shifts.NewShiftsRow();

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

            shift.ShiftName = name;

            shifts.AddShiftsRow(shift);
            int rowsAffected = Adapter.Update(shifts);

            return(rowsAffected == 1);
        }
예제 #3
0
파일: ShiftsBLL.cs 프로젝트: shulemg/SPG
        public bool DeleteShift(int id)
        {
            SPG.ShiftsDataTable shifts = Adapter.GetShiftByID(id);
            int rowsAffected           = 0;

            if (shifts.Count() == 1)
            {
                SPG.ShiftsRow shift = (SPG.ShiftsRow)shifts.Rows[0];
                if ((new ProductionBLL()).GetProductionByShift(id).Count != 0)
                {
                    MessageBox.Show("You can't delete this shift there are other records associated to it");
                    return(true);
                }
                rowsAffected = Adapter.Delete(id, shift.ts);
            }

            //Return true if precisely one row was deleted, otherwise return false.
            return(rowsAffected == 1);
        }