예제 #1
0
        private void AddTagButton_Clicked(object sender, RoutedEventArgs e)
        {
            if (this.TagsDbset == null)
            {
                this.TagsDbset = Conn.Set <Tags>();
            }
            if (this.ListOfTags == null)
            {
                this.ListOfTags = new List <Tags>();
            }

            //Detect if this tag is currently added to the project
            bool TagExist = this.ListOfTags.Where(lt => lt.TagName.ToLower() == this.NewTagTextBox.Text.ToLower().Trim()).FirstOrDefault() != null;

            if (TagExist)
            {
                this.AddTagPopupButton.IsPopupOpen = false;
                this.MySnackbar.MessageQueue.Enqueue("This tag is already added to project".ToUpper());
                return;
            }

            //Create the new tag
            var newTag = this.TagsDbset.Create();

            newTag.TagName = this.NewTagTextBox.Text;
            newTag.TagKey  = Encryption.GetUniqueKey(16);
            newTag.Color   = this.TagColorPicker.CurrentSelectedColor.Color.ToString();
            newTag.AddedBy = ((MainWindow)App.Current.MainWindow).StaffKey;
            newTag.AddOn   = ExtendedFunctions.GetNetworkTime();

            MyTagChips tc = new MyTagChips(newTag);

            tc.Margin    = new Thickness(3);
            tc.Deleting += Tc_Deleting;

            //Add to collections
            this.TagWrapPanel.Children.Add(tc);
            this.ListOfTags.Add(newTag);
            this.TagsDbset.Add(newTag);

            //Close the popup
            this.AddTagPopupButton.IsPopupOpen = false;
        }
예제 #2
0
        /// <summary>
        /// Load categories to treeview
        /// </summary>
        internal void LoadTreeView()
        {
            //Clear all items
            this.ProjectCategoryTree.Items.Clear();

            //Create the basic categories
            CreateBasicCategory();

            using (Data.ConnectContainer Conn = new ConnectContainer())
            {
                //Create new dbset (short live)
                var CategoryDbset = Conn.Set <Data.Category>();
                CategoryDbset.Load();

                //The root item
                this.ProjectCategories          = new CategoryItem();
                this.ProjectCategories.Category = CategoryDbset.Local.Where(cate => cate.ParentKey == "").FirstOrDefault();
                this.FindChild(this.ProjectCategories, CategoryDbset.Local);

                //Attach to the tree
                this.ProjectCategoryTree.Items.Add(this.ProjectCategories);
                this.ProjectCategoryTree.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
            }
        }
예제 #3
0
        /// <summary>
        /// Create a dataset from database and bind to datagrid view
        /// </summary>
        private void BindingDatabase()
        {
            //Lấy tham chiếu đến Database Entity Model
            if (this.Conn == null)
            {
                this.Conn = new Data.ConnectContainer();
            }

            //Personal information
            if (this.PersonalDataset == null)
            {
                this.PersonalDataset = Conn.Set(typeof(Data.Staff));

                if (this.IsEditing)
                {
                    var Personal = Conn.Staffs.Where(stf => stf.Key == this.StaffKey);
                    foreach (var item in Personal)
                    {
                        PersonalDataset.Attach(item);
                    }
                }

                if (this.PersonalDataset.Local.Count == 0)
                {
                    var   newPs = this.PersonalDataset.Create();
                    Staff C     = (Staff)newPs;
                    C.Key = this.StaffKey;
                    this.PersonalDataset.Local.Add(newPs);
                }
                this.PersonalDatagrid.ItemsSource = PersonalDataset.Local;
            }

            //Chức vụ
            if (this.JobTitleDataSet == null)
            {
                this.JobTitleDataSet = Conn.Set(typeof(Data.JobTitles));
                JobTitleDataSet.Load();
                this.JobTitleDbset = JobTitleDataSet.Local;
            }

            //Phòng ban
            if (this.DepartmentDataSet == null)
            {
                this.DepartmentDataSet = Conn.Set(typeof(Data.Department));
                DepartmentDataSet.Load();
                this.DepartmentDbset = DepartmentDataSet.Local;
            }

            //Học vấn
            if (this.EducationDbset == null)
            {
                var Edus = Conn.Educations.Where(edu => edu.StaffKey == this.StaffKey);
                this.EducationDbset = Conn.Set(typeof(Data.Education));
                foreach (var item in Edus)
                {
                    EducationDbset.Attach(item);
                }
                this.EducationGrid.ItemsSource = EducationDbset.Local;
            }

            //Ngoại ngữ
            if (this.LanguageDbset == null)
            {
                var Language = Conn.ForeignLanguages.Where(lg => lg.StaffKey == this.StaffKey);
                this.LanguageDbset = Conn.Set(typeof(Data.ForeignLanguage));
                foreach (var item in Language)
                {
                    LanguageDbset.Attach(item);
                }
                this.ForeignLanguageDatagrid.ItemsSource = this.LanguageDbset.Local;
            }

            //Lĩnh vực chuyên môn
            if (this.ProfessionalDbset == null)
            {
                this.ProfessionalDbset = Conn.Set(typeof(Data.ProfesstionalArea));
                ProfessionalDbset.Load();
            }

            //Giấy phép hành nghề
            if (this.LicenseDbset == null)
            {
                var Licenses = Conn.PracticingLicenses.Where(lc => lc.StaffKey == this.StaffKey);
                this.LicenseDbset = Conn.Set(typeof(Data.PracticingLicense));
                foreach (var item in Licenses)
                {
                    LicenseDbset.Attach(item);
                }
                this.PracticingDatagrid.ItemsSource = this.LicenseDbset.Local;
            }

            //Kinh nghiệm làm việc
            if (this.ExpDbset == null)
            {
                var Exps = Conn.WorkingExperiences.Where(exp => exp.StaffKey == this.StaffKey);
                this.ExpDbset = Conn.Set(typeof(Data.WorkingExperience));
                foreach (var item in Exps)
                {
                    ExpDbset.Attach(item);
                }
                this.ExperienceGrid.ItemsSource = this.ExpDbset.Local;
            }

            //Phan quyen
            if (this.PermissionDbset == null)
            {
                var Permission = Conn.Permissions.Where(pm => pm.StaffKey == this.StaffKey);
                this.PermissionDbset = Conn.Set(typeof(Data.Permission));
                foreach (var item in Permission)
                {
                    PermissionDbset.Attach(item);
                }
                this.PermissionGrid.ItemsSource = PermissionDbset.Local;
                if (PermissionDbset.Local.Count == 0)
                {
                    Data.Permission myPermission = (Data.Permission)PermissionDbset.Create();
                    myPermission.StaffKey = this.StaffKey;
                    myPermission.Key      = Encryption.GetUniqueKey(16);
                    this.PermissionDbset.Local.Add(myPermission);
                }
            }
        }