Esempio n. 1
0
        //public static SalesContext db = new SalesContext();

        //public static Customer CloneCustomer(Customer SelectedItem)
        //{
        //    using (var db = new SalesContext())
        //    {
        //        var item = db.Customers.Find(SelectedItem.Id);
        //        item.CustomerRank = CustomerRanks.Where(p => p.Id == item.CustomerRankID).Single();
        //        return item;
        //    }
        //}

        #endregion

        #region Asset
        public async static Task GetAllAssets()
        {
            Assets.Clear();
            AssetCategories.Clear();
            using (var db = new SalesContext())
            {
                var result  = await(from c in db.Assets select c).ToListAsync();
                var result1 = await(from c in db.AssetCategories.Include("Assets") select c).ToListAsync();
                var result2 = await(from c in db.Departments.Include("Assets") select c).ToListAsync();
                var result3 = await(from c in db.InstallationLocations.Include("Assets") select c).ToListAsync();
                foreach (Asset item in result)
                {
                    Assets.Add(item);
                }
                foreach (AssetCategory item in result1)
                {
                    AssetCategories.Add(item);
                }
                foreach (Department item in result2)
                {
                    Departments.Add(item);
                }
                foreach (InstallationLocation item in result3)
                {
                    InstallationLocations.Add(item);
                }
            }
        }
        public async void LoadDataSources(object e)
        {
            var equipment = await GetData.EquipmentQueryAsync();

            var employees = await GetData.EmployeeQueryAsync();

            var departments = await GetData.DepartmentQueryAsync();

            var jobsites = await GetData.JobsiteQueryAsync();

            foreach (EquipmentModel item in equipment)
            {
                Equipment.Add(item);
            }
            foreach (DepartmentModel department in departments)
            {
                Departments.Add(department);
            }
            foreach (JobsiteModel jobsite in jobsites)
            {
                Jobsites.Add(jobsite);
            }

            var today = DateTime.Now;
            var authorizedEmployees = employees.Where(x => !x.Restrictions.Any(x => x.Name == "Equipment Assignments" && x.EndDate >= today));

            foreach (EmployeeModel employee in authorizedEmployees)
            {
                AuthorizedEmployees.Add(employee);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 新增子部门
 /// </summary>
 /// <param name="NewDepartmentName">新增子部門的名字</param>
 /// <param name="errMsg">返回錯誤信息</param>
 /// <returns>返回操作結果</returns>
 public bool AddChildDepartment(string NewDepartmentName, string UserID, ref string errMsg)
 {
     try
     {
         QYConfig.RegistWX();
         var accessToken = AccessTokenContainer.GetToken(QYConfig.CorpId);
         var result      = MailListApi.CreateDepartment(accessToken, NewDepartmentName, int.Parse(DepartmentID));
         if (result.errcode.ToString() == "请求成功")
         {
             if (DepartmentDA.AddDepartment(result.id.ToString(), DepartmentID, NewDepartmentName, "1", UserID))
             {
                 QYDepartmentBL newdep = GetByWXID(result.id.ToString());
                 Departments.Add(newdep);
                 return(true);
             }
             else
             {
                 errMsg = "数据库新增部门失败";
                 return(false);
             }
         }
         else
         {
             Logger.Log4Net.Error(result.errcode + ":" + result.errmsg);
             errMsg = result.errcode + ":" + result.errmsg;
         }
     }
     catch (Exception e)
     {
         Logger.Log4Net.Error("add department error:" + e);
         errMsg = "操作失敗:" + e.Message;
         return(false);
     }
     return(false);
 }
Esempio n. 4
0
 public bool AddDepartment(Department department)
 {
     if (Departments.Count == 0)
     {
         if (department is Faculty)
         {
             (department as Faculty).myEvent += this.PrintMessage;
         }
         Departments.Add(department);
         return(true);
     }
     else if (Departments.Count <= 10)
     {
         for (int i = 0; i < Departments.Count; i++)
         {
             if (!department.Equals(Departments[i]))
             {
                 if (department is Faculty)
                 {
                     (department as Faculty).myEvent += this.PrintMessage;
                 }
                 Departments.Add(department);
                 return(true);
             }
         }
     }
     return(false);
 }
Esempio n. 5
0
        public List <Department> RetrieveAll()
        {
            SqlCommand     command = null;
            SqlDataAdapter adapter = null;

            try
            {
                // Define command.
                command             = mDbConnection.CreateCommand();
                command.CommandText = "RetrieveAllDepartments";
                command.CommandType = CommandType.StoredProcedure;

                // Execute command.
                adapter = new SqlDataAdapter(command);
                DataTable DepartmentDataTable = new DataTable("Departments");
                adapter.Fill(DepartmentDataTable);

                // Create a list.
                List <Department> Departments = null;
                if (DepartmentDataTable.Rows.Count > 0)
                {
                    Departments = new List <Department>();
                }

                // Iterate each row.
                foreach (DataRow row in DepartmentDataTable.Rows)
                {
                    // Create an instance of Department.
                    Department Department = new Department(Int32.Parse(row["DepartmentId"].ToString()));
                    Department.Name             = row["Name"].ToString();
                    Department.Description      = row["Description"].ToString();
                    Department.Reason           = row["Reason"].ToString();
                    Department.IsActive         = bool.Parse(row["IsActive"].ToString());
                    Department.LastUpdateUserId = Int32.Parse(row["LastUpdateUserId"].ToString());
                    Department.LastUpdateDate   = DateTime.Parse(row["LastUpdateDate"].ToString());
                    Department.CustomData.Add("LastUpdateUserName", row["LastUpdateUserName"].ToString());

                    Department.CustomData.Add("IsActive", row["PIsActive"].ToString());

                    // Add to list.
                    Departments.Add(Department);
                }

                // Return the list.
                return(Departments);
            }
            catch { throw; }
            finally
            {
                // Dispose.
                if (adapter != null)
                {
                    adapter.Dispose();
                }
                if (command != null)
                {
                    command.Dispose();
                }
            }
        }
Esempio n. 6
0
        public void Inital()
        {
            Departments.Clear();
            using (var db = new DataModel())
            {
                tempPersons = new List <Person>();
                var tempdeps = db.Departments.ToList();
                tempdeps.ForEach(d => Departments.Add(d));
                //people中有外键相连的Departments属性,好像一定要通过Departments = db.Departments.ToList()一下 生成的list中才会生成Departments属性,好奇怪
                tempPersons     = db.Persons.OrderBy(p => p.DepId).ToList();
                Operators       = db.Accountants.Select(p => p.Person.PersonName).ToList();                                       //查询报销操作人员的姓名到List
                AccountantsName = db.Persons.Where(p => p.Department.DepartmentName == "财务部").Select(p => p.PersonName).ToList(); //查询财务部人员的姓名到List
                Persons.Clear();
                tempPersons.ForEach(p => Persons.Add(p));                                                                         //list 转 obserbableColletion
            }
            Department temp = new Department()
            {
                DepartmentId = 0, DepartmentName = ""
            };

            Departments.Insert(0, temp);
            StaffOperateMode         = "浏览模式";
            BtnStaffAppendEna        = true;
            BtnStaffModifyEna        = true;
            BtnStaffCancelConfirmEna = false;
            ComStaffDepartmentEna    = false;
            TextStaffEna             = false;
        }
        public async void LoadComboBoxes(object e)
        {
            var certificationTypes = await GetData.CertificationQueryAsync();

            foreach (CertificationModel certification in certificationTypes)
            {
                CertificationTypes.Add(certification);
            }
            var restrictionTypes = await GetData.RestrictionQueryAsync();

            foreach (RestrictionModel restrictionType in restrictionTypes)
            {
                RestrictionTypes.Add(restrictionType);
            }
            var departments = await GetData.DepartmentQueryAsync();

            foreach (DepartmentModel department in departments)
            {
                Departments.Add(department);
            }
            var jobTitles = await GetData.JobTitleQueryAsync();

            foreach (JobTitleModel jobTitle in jobTitles)
            {
                JobTitles.Add(jobTitle);
            }
        }
Esempio n. 8
0
        async Task ExecuteLoadDeptsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Departments.Clear();
                var items = await DataStore.Departments.ToListAsync();

                foreach (var item in items)
                {
                    Departments.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Esempio n. 9
0
 private void Create()
 {
     Departments.Add(new Department()
     {
         Name = "Цех 0", ShortName = "0"
     });
     Context.SaveChanges();
 }
Esempio n. 10
0
        private void Add()
        {
            var d = new Department();

            Departments.Add(d);
            SelectedDepartment = d;
            RaisePropertyChanged("Departments");
        }
Esempio n. 11
0
        internal void AddDepartment(DepartmentVM departmentVM)
        {
            var subdeps = EntityManager.AllEntities.Departments.SelectMany(d => d.Departments);

            if (!subdeps.Contains(departmentVM.Id))
            {
                Departments.Add(departmentVM);
            }
        }
Esempio n. 12
0
 void Instance_UserDataLoadComplete(object sender, EventArgs e)
 {
     CompanyName = CompanyEditedName = PersonalHandler.Instance.CompanyName;
     Departments.Clear();
     foreach (var item in PersonalHandler.Instance.Model.Departments)
     {
         Departments.Add(item);
     }
 }
        private void AddDepartment()
        {
            var viewModel = new DepartmentViewModel(new Department());

            if (_dialogService.ShowDialog(viewModel) == true)
            {
                Departments.Add(_repository.GetDepartmentDto(viewModel.Department.Id));
            }
        }
Esempio n. 14
0
 public void AddDepartment(string name)
 {
     if (Departments.Select(o => o.Name.ToLower().Trim()).Contains(name.ToLower().Trim()))
     {
         throw new ArgumentOutOfRangeException(nameof(BaseDepartment.Name), "Имя должно быть уникальным");
     }
     Departments.Add(new BaseDepartment(name));
     OnPropertyChanged(nameof(Departments));
 }
Esempio n. 15
0
        public async static Task AddDepartment(Department itemPara)
        {
            using (var db = new SalesContext())
            {
                db.Departments.Add(itemPara);
                await UpdateDatabase(db);

                Departments.Add(itemPara);
            }
        }
Esempio n. 16
0
        private void LoadDepartmentsForCustomer(int customerId)
        {
            CustomerDto customer = Customers.Where(c => c.CustomerID == customerId).SingleOrDefault();

            Departments.Clear();
            foreach (var item in customer.DepartmentsCollection)
            {
                Departments.Add(item);
            }
        }
 public ActionResult Create(Departments dep)
 {
     try
     {
         department.Add(dep);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
Esempio n. 18
0
        public static void InitializeDepartments()
        {
            List <Department> departmentList = HospitalDB.FetchDepartments();

            foreach (Department department in departmentList)
            {
                if (department != null)
                {
                    Departments.Add(department.ID, department);
                }
            }
        }
Esempio n. 19
0
 public void AddDepartment(Department dep)
 {
     if (dep == null)
     {
         throw new ArgumentNullException();
     }
     if (!HasDepartment(dep))
     {
         Departments.Add(dep);
         dep.AddTo(this);
     }
 }
Esempio n. 20
0
        private async Task LoadDepartmentLookupAsync()
        {
            Departments.Clear();
            Departments.Add(new NullLookupItem {
                DisplayMember = " - "
            });
            var lookup = await _employeeTypeLookupDataService.GetDepartmentLookupAsync();

            foreach (var lookupItem in lookup)
            {
                Departments.Add(lookupItem);
            }
        }
Esempio n. 21
0
 private void InitializeDepartments()
 {
     Departments.Add(new Department {
         Id = 1, Name = "Developers"
     });
     Departments.Add(new Department {
         Id = 2, Name = "Admins"
     });
     Departments.Add(new Department {
         Id = 3, Name = "Media"
     });
     //dep.ForEach(x => departmentBindingSource.Add(x));
 }
        public async Task OnSearchDepartment()
        {
            if (String.IsNullOrEmpty(DepartmentSearch) || String.IsNullOrWhiteSpace(DepartmentSearch))
            {
                await _confirmationDialogHelper.ErrorWindowShow("Veuillez remplir le champ de recherche.");
            }
            else
            {
                Departments.Clear();
                if (firstNameOrLastName.IsMatch(DepartmentSearch))
                {
                    for (int i = 0; i < GetDepartments.Count; i++)
                    {
                        if (GetDepartments[i].Code.ToLower().Contains(DepartmentSearch.ToLower()))
                        {
                            Departments.Add(GetDepartments[i]);
                        }
                        else if (GetDepartments[i].Name.ToLower().Contains(DepartmentSearch.ToLower()))
                        {
                            Departments.Add(GetDepartments[i]);
                        }
                    }
                }
                else if (fullNameRx.IsMatch(DepartmentSearch))
                {
                    var word      = DepartmentSearch.Split(' ');
                    var countWord = word.Length;

                    foreach (var depart in GetDepartments)
                    {
                        int i        = 0;
                        var fullname = depart.Name;
                        do
                        {
                            if (fullname.ToLower().Contains((word[i]).ToLower()))
                            {
                                if (i == countWord - 1)
                                {
                                    Departments.Add(depart);
                                }
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        } while (i < countWord);
                    }
                }
            }
        }
Esempio n. 23
0
        private void InitData()
        {
            Departments.Add(new Department {
                Id = 1, Name = "Компьютерный отдел"
            });
            Departments.Add(new Department {
                Id = 2, Name = "Финансовый отдел"
            });
            Departments.Add(new Department {
                Id = 3, Name = "Юридический отдел"
            });

            Employees.Add(new Employee
            {
                Id       = 1,
                Name     = "Иваненко Иван",
                Photo    = @"..\..\Photo\p1.jpg",
                Birth    = new DateTime(1990, 1, 15),
                Entry    = new DateTime(2015, 3, 3),
                Fire     = "-",
                Position = "разработчик",
                Salary   = 2000,
                DepId    = 1
            });

            Employees.Add(new Employee
            {
                Id       = 2,
                Name     = "Петренко Петр",
                Photo    = @"..\..\Photo\p2.jpg",
                Birth    = new DateTime(1995, 10, 20),
                Entry    = new DateTime(2015, 3, 4),
                Fire     = "-",
                Position = "бухгалтер",
                Salary   = 1200,
                DepId    = 2
            });

            Employees.Add(new Employee
            {
                Id       = 3,
                Name     = "Сидоренко Сидор",
                Photo    = @"..\..\Photo\p3.jpg",
                Birth    = new DateTime(1992, 7, 5),
                Entry    = new DateTime(2015, 3, 5),
                Fire     = "-",
                Position = "юрист",
                Salary   = 1500,
                DepId    = 3
            });
        }
 private void ReloadDepartments(List <Department> departments)
 {
     Departments.Clear();
     foreach (var department in departments.OrderBy(d => d.Name))
     {
         Departments.Add(new DepartmentItemViewModel
         {
             Cities       = department.Cities,
             Customers    = department.Customers,
             DepartmentId = department.DepartmentId,
             Name         = department.Name,
         });
     }
 }
Esempio n. 25
0
 /// <summary>
 /// 获取部门列表
 /// </summary>
 /// <param name="agentid">代理商ID</param>
 /// <returns></returns>
 public static List <Department> GetDepartments(string agentid)
 {
     if (!Departments.ContainsKey(agentid))
     {
         DataTable         dt   = new OrganizationDAL().GetDepartments(agentid);
         List <Department> list = new List <Department>();
         foreach (DataRow dr in dt.Rows)
         {
             Department model = new Department();
             model.FillData(dr);
             list.Add(model);
         }
         Departments.Add(agentid, list);
         return(list);
     }
     return(Departments[agentid].Where(m => m.Status == 1).ToList());
 }
        private void ReloadDepartment(List <Department> departaments)
        {
            Departments.Clear();

            departaments = departaments.OrderBy(x => x.Name).ToList();

            foreach (var department in departaments)
            {
                Departments.Add(new DepartmentItemViewModel()
                {
                    Cities       = department.Cities,
                    Customers    = department.Customers,
                    DepartmentId = department.DepartmentId,
                    Name         = department.Name
                });
            }
        }
Esempio n. 27
0
        public NewEmployeeViewModel()
        {
            //Departments = new BindableCollection<DepartmentModel>(GlobalConfig.Connection.GetAllDepartments());
            //Functions = new BindableCollection<FunctionModel>(GlobalConfig.Connection.GetAllFunctions());
            //Titles = new BindableCollection<TitleModel>(GlobalConfig.Connection.GetAllTitles());
            Departments.Add(new DepartmentModel {
                Id = 2, DeptName = "Fork Licensing"
            });
            Departments.Add(new DepartmentModel {
                Id = 3, DeptName = "Lab"
            });

            Functions.Add(new FunctionModel {
                Id = 3, DeptId = 2, FunctionName = "Fork", RenewalMonths = 36
            });
            Functions.Add(new FunctionModel {
                Id = 4, DeptId = 2, FunctionName = "Clamp", RenewalMonths = 36
            });
            Functions.Add(new FunctionModel {
                Id = 5, DeptId = 2, FunctionName = "Arial", RenewalMonths = 36
            });
            Functions.Add(new FunctionModel {
                Id = 6, DeptId = 3, FunctionName = "Deviation", RenewalMonths = 0
            });
            Functions.Add(new FunctionModel {
                Id = 7, DeptId = 3, FunctionName = "Approve Deviation", RenewalMonths = 0
            });
            Functions.Add(new FunctionModel {
                Id = 8, DeptId = 3, FunctionName = "MMC", RenewalMonths = 0
            });

            Titles.Add(new TitleModel {
                Id = 9, TitleName = "Utility"
            });
            Titles.Add(new TitleModel {
                Id = 7, TitleName = "Drum Operator"
            });
            Titles.Add(new TitleModel {
                Id = 2, TitleName = "Adhesive Room"
            });

            GetEmployees();
            IsSelected = true;
            NotifyOfPropertyChange(() => ModeSwitch);
        }
Esempio n. 28
0
        /// <summary>
        /// Добавление нового департамента
        /// </summary>
        /// <param name="Name">Наименование</param>
        /// <param name="HigherDepartmentId">Id вышестоящего департамента</param>
        public void Add_Department(string Name, int HigherDepartmentId)
        {
            if (Name == null || Name == "")
            {
                Name = "Новый департамент";
            }                                                                 //присвоение имени по умолчанию
            Department department = new Department(Name, HigherDepartmentId); //создаем новый экземпляр департамента

            Departments.Add(department);                                      //добавляем экземпляр в коллекцию департаментов организации
            if (HigherDepartmentId == 0)
            {
                SlaveDepartmentId.Add(department.Id);
            }                                                                      //если Id вышестоящего департамента 0 - подчиняем организации
            else
            {
                this[HigherDepartmentId].SlaveDepartmentId.Add(department.Id);
            }                                                                       //или подчиняем указанному департаменту
        }
Esempio n. 29
0
        /// <summary>
        /// Method that add department to the list of departments.
        /// </summary>
        /// <param name="department">Department that need to add.</param>
        public void AddDepartment(Department department)
        {
            bool check = false;

            foreach (var tempDepartment in Departments)
            {
                if (tempDepartment.Equals(department) || Departments.Count >= 10)
                {
                    check = true;
                    break;
                }
            }
            if (!check)
            {
                Departments.Add(department);
            }
            department.EventAddedMember += DisplayInfoAboutNewMember;
        }
Esempio n. 30
0
        /// <summary>
        /// Adds newly created child department to parent department
        /// </summary>
        /// <param name="parentDept">Parent department</param>
        /// <param name="childDept">Departmet to add</param>
        /// <returns>
        ///  0 if child was added successfully,
        /// </returns>
        public int AddDepartment(IDepartmentDTO pd, IDepartmentDTO cd)
        {
            BaseDepartment parentDept = pd as BaseDepartment;
            BaseDepartment childDept  = cd as BaseDepartment;

            // Creation of root department
            // it means childDept is root department
            if (parentDept == null && childDept.ParentDeptID == 0)
            {
                Departments.Add(childDept);
                return(0);
            }

            // Adding child department to parent dept
            Departments.Add(childDept);
            parentDept.SubDepts.Add(childDept.DeptID);
            childDept.ParentDeptID = parentDept.DeptID;
            return(0);
        }