Exemplo n.º 1
0
        public void DeleteDepartment(VinaGerman.Entity.BusinessEntity.DepartmentEntity newEntity)
        {
            VinaGerman.Entity.BusinessEntity.DepartmentEntity oldEntity = DepartmentList.FirstOrDefault <VinaGerman.Entity.BusinessEntity.DepartmentEntity>(p => p.DepartmentId == newEntity.DepartmentId);

            if (oldEntity != null)
            {
                DepartmentList.Remove(oldEntity);
            }

            DepartmentList = new List <VinaGerman.Entity.BusinessEntity.DepartmentEntity>(_departmentList);
        }
        protected void gviewDepartments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            //Grab the department FIS code from the datakey
            Department dept = new Department();

            dept.DepartmentFIS = (string)gviewDepartments.DataKeys[e.RowIndex]["DepartmentFIS"];

            //Remove the corresponding department from the DepartmentList
            DepartmentList.Remove(dept);

            gviewDepartments.DataSource = DepartmentList;
            gviewDepartments.DataBind();

            e.Cancel = true;
        }
Exemplo n.º 3
0
        public void AddOrUpdateDepartment(VinaGerman.Entity.BusinessEntity.DepartmentEntity newEntity)
        {
            VinaGerman.Entity.BusinessEntity.DepartmentEntity oldEntity = DepartmentList.FirstOrDefault <VinaGerman.Entity.BusinessEntity.DepartmentEntity>(p => p.Description == newEntity.Description);

            if (oldEntity == null)
            {
                DepartmentList.Insert(0, newEntity);
            }
            else
            {
                int index = DepartmentList.IndexOf(oldEntity);
                DepartmentList.Remove(oldEntity);
                DepartmentList.Insert(index, newEntity);
            }

            DepartmentList = new List <VinaGerman.Entity.BusinessEntity.DepartmentEntity>(_departmentList);
        }
Exemplo n.º 4
0
        public int DepartmenRemove(Department deparment)
        {
            var res = databaseServiceSoapClient.DepartmenRemove(deparment);

            if (res > 0)
            {
                for (int i = MainWindow.ContactList.Count - 1; i >= 0; i--)
                {
                    if (MainWindow.ContactList[i].Category.Id == deparment.Id)
                    {
                        MainWindow.ContactList.Remove(MainWindow.ContactList[i]);
                    }
                    continue;
                }
                DepartmentList.Remove(deparment);
            }
            return(res);
        }
Exemplo n.º 5
0
        public bool updateDepartment(string depID, string name, string hodID, string newDepID, string newName, string newhodID)
        {
            IDepartment Dep = this.DepartmentList.FirstOrDefault(dep => dep.DepartmentID == depID.Trim());

            if (hodID is null)
            {
                IStaff hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(newhodID));
                this.StaffList.Remove(hod);
                hod.isHOD = 1;
                this.StaffList.Add(hod);
                DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD);
                DepartmentList.Remove(Dep);
                Dep.HeadOfDepartmentID = newhodID;
                DepartmentList.Add(Dep);
                DataLayer.UpdateDepartmentInDB(hod, Dep, depID);
            }
            else
            {
                IStaff hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(hodID));
                // Remove department and hod from their lists //
                this.DepartmentList.Remove(Dep);
                this.StaffList.Remove(hod);

                // Add them back with changes //
                hod.isHOD = 0;
                DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD);
                this.StaffList.Add(hod);

                hod = this.StaffList.FirstOrDefault(user => user.UserID.Equals(newhodID));
                this.StaffList.Remove(hod);
                hod.isHOD = 1;
                this.StaffList.Add(hod);
                DataLayer.updateStaffMemberToOrFromHODinDB(hod, hod.isHOD);

                Dep.DepartmentID       = newDepID;
                Dep.HeadOfDepartmentID = newhodID;
                Dep.Name = newName;
                this.DepartmentList.Add(Dep);

                DataLayer.UpdateDepartmentInDB(hod, Dep, depID);
            }

            return(true);
        }