예제 #1
0
        private void btnConfirmOk_Click(object sender, RoutedEventArgs e)
        {
            if (increaseContactLimitation != 0 && increaseGroupLimitation != 0)
            {
                var increaseContactNumber = UC_AddressBook.AllContactCount + 1;
                var increaseGroupNumber = UC_AddressBook.AllGroupCount + increaseGroupLimitation;
                DatabaseParameterController dbParamController = new DatabaseParameterController();
                dbParamController.SaveDatabaseParameters(increaseContactNumber, increaseGroupNumber);
                increaseContactLimitation = 0;
                increaseGroupLimitation = 0;
            }

            if (increaseContactLimitation != 0)
            {
                var increaseNumber = UC_AddressBook.AllContactCount + 1;
                DatabaseParameterController dbParamController = new DatabaseParameterController();
                dbParamController.SaveDatabaseParameters(increaseNumber, GroupDB.MAX_GROUP);
                increaseContactLimitation = 0;
            }

            if(increaseGroupLimitation != 0)
            {
                var increaseNumber = GroupDB.MAX_GROUP + increaseGroupLimitation;
                DatabaseParameterController dbParamController = new DatabaseParameterController();
                dbParamController.SaveDatabaseParameters(UC_AddressBook.AllContactCount, increaseNumber);
                increaseGroupLimitation = 0;
            }

            StatusPanel.Visibility = Visibility.Collapsed;
            btnConfirmOk.Visibility = Visibility.Collapsed;
            btnConfirmNo.Visibility = Visibility.Collapsed;
            btnSave_Click(sender, e);
        }
예제 #2
0
        private async Task<List<int>> GetGroupIdList(string groupsStr)
        {
            List<int> groupsList = new List<int>();

            if (groupsStr == string.Empty)
                return groupsList;

            var groupsArr = groupsStr.Split(new char[] { GroupDB.SEPARATE_TOKEN, GroupDB.SEPARATE_TOKEN_TEMP }).Distinct().ToList();
            var currentGroupCount = UC_AddressBook.AllGroupCount;
            var newGroups = new List<string> { };

            foreach (var item in groupsArr)
            {
                if (item.Equals(string.Empty))
                    continue;

                var group = listGroup_EF.FirstOrDefault(gr => gr.Name.Equals(item));
                if (group != null)
                {
                    groupsList.Add(group.Id);
                }
                else
                {
                    newGroups.Add(item);
                }
            }

            var totalGroupCount = currentGroupCount + newGroups.Count;

            if (totalGroupCount > GroupDB.MAX_LIMITATION)
            {
                var exceed_limit_group = string.Format(UC_AddressBook.ResourcesStringLoader.GetString("exceed_group_limit"), GroupDB.MAX_LIMITATION);
                NotifyUser(exceed_limit_group, NotifyType.ErrorMessage);
                UpdateGUIWhenStopingProcess();
                return null;
            }

            if (totalGroupCount > GroupDB.MAX_GROUP && totalGroupCount <= GroupDB.MAX_LIMITATION)
            {
                Flyout_CreateJoinGroup.Hide();
                var exceed_group_limit_increase_number = string.Format(UC_AddressBook.ResourcesStringLoader.GetString("exceed_group_limit_increase_number"), totalGroupCount);
                var res = await Modals.UIConfirmPopup.ShowAsyncConfirmPopup(exceed_group_limit_increase_number);
                if (res == PopupResult.Yes)
                {
                    DatabaseParameterController dbParamController = new DatabaseParameterController();
                    dbParamController.SaveDatabaseParameters(UC_AddressBook.AllContactCount, totalGroupCount);
                }
                else
                {
                    return null;
                }
                
            }

            //foreach (var item in newGroups)
            //{
            //    int groupId = dbController.AddNewGroup(item);
            //    groupsList.Add(groupId);
            //}

            groupsList.AddRange(dbController.AddGroups(newGroups));

            return groupsList.Distinct().ToList();
        }
예제 #3
0
        private async void ContentDialog_PrimaryButtonClick(object sender, RoutedEventArgs e)
        {
            switch (this.aMode)
            {
                case ActionGroupMode.MODE_ADD:
                    if (UC_AddressBook.AllGroupCount >= GroupDB.MAX_GROUP)
                    {
                        var msg = string.Format(UC_AddressBook.ResourcesStringLoader.GetString("exceed_group_limit_increase_number"), GroupDB.MAX_GROUP + 1);
                        var res = await Modals.UIConfirmPopup.ShowAsyncConfirmPopup(msg);
                        if (res == PopupResult.Yes)
                        {
                            DatabaseParameterController dbParamController = new DatabaseParameterController();
                            dbParamController.SaveDatabaseParameters(UC_AddressBook.AllContactCount, GroupDB.MAX_GROUP + 1);
                        }
                        else
                        {
                            this.Hide();
                            return;
                        }
                    }

                    var gname = GroupDB.TrimAll(this.tbox_gname.Text);
                    if (!string.IsNullOrEmpty(gname))
                    {
                        if (!CheckGroupName(gname))
                        {
                            //args.Cancel = true;
                            var msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-group_invalid");
                            Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                            return;
                        }
                        if (currentMode == MODE_LOCAL)
                        {
                            var res = controller.AddNewGroup(gname);
                            if (res > 0)
                            {
                                ((Page_LocalGroups)parent).ReloadGroup();
                                this.Hide();
                            }
                        }
                        else
                        {
                            var totalGroupCount = Page_PrinterContacts.GetTotalGroupsCount + 1;
                            var groupLimit = UC_AddressBook.CurrentPrinterContact.GroupLimit;
                            if (totalGroupCount > groupLimit)
                            {
                                this.Hide();
                                var msg = string.Format(UC_AddressBook.ResourcesStringLoader.GetString("exceed_max_limit_group"), groupLimit);
                                Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                            }
                            else
                            {
                                ((Page_PrinterContacts)parent).ReloadGroup(gname, "");
                                this.Hide();
                            }
                        }
                    }
                    else
                    {
                        //args.Cancel = true;
                        var msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-group_invalid");
                        Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                        return;
                    }
                    break;
                case ActionGroupMode.MODE_EDIT:
                    var newGroupName = tbox_gname.Text.Trim();
                    newGroupName = String.Join(" ", newGroupName.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries));
                    if (!oldGroupName.Equals(newGroupName))
                    {
                        if (!CheckGroupName(newGroupName) || string.IsNullOrEmpty(newGroupName))
                        {
                            //args.Cancel = true;
                            var msg = UC_AddressBook.ResourcesStringLoader.GetString("DIALOG-Message-group_invalid");
                            Modals.UIConfirmPopup.ShowAsyncInfoPopup(msg);
                            return;
                        }
                        if (currentMode == MODE_LOCAL)
                        {
                            var res = controller.UpdateGroupNameById(gID, newGroupName);
                            if (res > 0)
                            {
                                ((Page_LocalGroups)parent).ReloadGroup();
                                this.Hide();
                            }
                        }
                        else
                        {
                            ((Page_PrinterContacts)parent).ReloadGroup(oldGroupName, newGroupName);
                            this.Hide();
                        }
                    }
                    else
                    {
                        this.Hide();
                    }
                    break;
                default:
                    break;
            }

            Page_LocalContacts.IsReload = true;
        }
예제 #4
0
        private async void AddGroup_YesConfirmation_Click(object sender, RoutedEventArgs e)
        {
            var newGroupName = GroupDB.TrimAll(this.tbox_AddGroup.Text);

            if (UC_AddressBook.AllGroupCount >= GroupDB.MAX_LIMITATION)
            {
                var msg = string.Format(UC_AddressBook.ResourcesStringLoader.GetString("exceed_max_limit_group"), GroupDB.MAX_LIMITATION);
                tbox_Validate_AddGroup.Text = msg;
                tbox_Validate_AddGroup.Visibility = Visibility.Visible;
            }
            else
            {
                if (UC_AddressBook.AllGroupCount >= GroupDB.MAX_GROUP && UC_AddressBook.AllGroupCount <= GroupDB.MAX_LIMITATION)
                {
                    HideFlyout_AddGroup();
                    var msg = string.Format(UC_AddressBook.ResourcesStringLoader.GetString("exceed_group_limit_increase_number"), GroupDB.MAX_GROUP + 1);
                    var res = await Modals.UIConfirmPopup.ShowAsyncConfirmPopup(msg);
                    if (res == PopupResult.Yes)
                    {
                        DatabaseParameterController dbParamController = new DatabaseParameterController();
                        dbParamController.SaveDatabaseParameters(UC_AddressBook.AllContactCount, GroupDB.MAX_GROUP + 1);
                    }
                    else
                    {
                        return;
                    }
                }

                HideFlyout_AddGroup();

                if (string.IsNullOrEmpty(newGroupName) || newGroupName.Equals(" "))
                    return; // empty group
                var isAddSuccess = dbController.AddNewGroup(newGroupName);
                if (isAddSuccess > 0)
                {
                    Page_LocalContacts.IsReload = true;
                    Page_LocalContacts.IsResumeSelectContacts = true;
                    ReloadGroup();
                }
            }
        }
예제 #5
0
        private void save_database_parameters(int newContactCount, int newGroupCount)
        {
            try
            {
                DatabaseParameterController dpController = new DatabaseParameterController();
                dpController.SaveDatabaseParameters(newContactCount, newGroupCount);
            }
            catch (Exception)
            {
                throw;
            }

        }
예제 #6
0
        private bool checkLimit()
        {
            int newGroupCount = 0;
            string strGroup = tbox_group.Text.TrimStart().TrimEnd();
            if (CheckLimitGroupInLocal(strGroup) > 0)
            {
                newGroupCount = UC_AddressBook.AllGroupCount + CheckLimitGroupInLocal(strGroup);
            }
            else
            {
                newGroupCount = UC_AddressBook.AllGroupCount;
            }
            int curentLimitGroup = GroupDB.MAX_GROUP;
            bool doAdd = true;
            if (newGroupCount > GroupDB.MAX_LIMITATION)
            {
                MessageBox.Show(CMLibrary.Properties.Resources.exceed_group_limit);
                return false;
            }
            else if (newGroupCount > curentLimitGroup)
            {
                MessageBoxResult dialogRes = MessageBox.Show(
                       String.Format(CMLibrary.Properties.Resources.exceed_limit_increase_group_number, newGroupCount),
                       CMLibrary.Properties.Resources.import,
                       MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (dialogRes == MessageBoxResult.Yes)
                {
                    DatabaseParameterController dpController = new DatabaseParameterController();
                    dpController.SaveDatabaseParameters(ContactDB.MAX_CONTACT, newGroupCount);
                }
                else
                {
                    doAdd = false;
                    this.Close();
                }
            }
            return doAdd;
        }
예제 #7
0
        private void btn_import_Click(object sender, RoutedEventArgs e)
        {
            List<ContactDB> importList = new List<ContactDB>();

            int count = listview_contacts.Items.Count;
            for (int i = 0; i < count; i++)
            {
                Object item = listview_contacts.Items[i];
                if (item is ListViewContactItem)
                {
                    if (((ListViewContactItem)item).IsCheck)
                    {
                        int idx = ((ListViewContactItem)item).Index;
                        importList.Add(controllerAndData.ListData[idx]);
                    }
                }
            }

            int importCount = importList.Count();
            int currentLimit = ContactDB.MAX_CONTACT;

            bool doImport = false;
            int newContactCount = UC_AddressBook.AllContactCount + importCount;
            if (newContactCount <= currentLimit)
            {
                doImport = true;
            }
            else if (newContactCount <= ContactDB.MAX_LIMITATION)
            {
                MessageBoxResult dialogRes = MessageBox.Show(
                       String.Format(CMLibrary.Properties.Resources.exceed_limit_increase_number, newContactCount),
                       CMLibrary.Properties.Resources.import,
                       MessageBoxButton.YesNo, MessageBoxImage.Question);

                if (dialogRes == MessageBoxResult.Yes)
                {
                    DatabaseParameterController dpController = new DatabaseParameterController();
                    dpController.SaveDatabaseParameters(newContactCount, GroupDB.MAX_GROUP);
                    doImport = true;
                }
            }
            else
            {
                MessageBox.Show(CMLibrary.Properties.Resources.exceed_contact_limit);
            }

            if (doImport)
            {
                if (ownParent is Window_ImportContact)
                {
                    controllerAndData.ListData = importList;
                    ((Window_ImportContact)ownParent).ReceivetListContact(controllerAndData);
                }

                this.Close();
            }
        }
        private bool isLimitGroup()
        {
            int curentLimitGroup = GroupDB.MAX_GROUP;
            int newGroupCount = UC_AddressBook.AllGroupCount + 1;
            bool doAdd = false;
            
            if (newGroupCount > GroupDB.MAX_LIMITATION)
            {
                MessageBox.Show(CMLibrary.Properties.Resources.exceed_group_limit);
            }
            else
            {
                if (newGroupCount > curentLimitGroup)
                {
                    MessageBoxResult dialogRes = MessageBox.Show(
                           String.Format(CMLibrary.Properties.Resources.exceed_limit_increase_group_number, newGroupCount),
                           CMLibrary.Properties.Resources.import,
                           MessageBoxButton.YesNo, MessageBoxImage.Question);

                    if (dialogRes == MessageBoxResult.Yes)
                    {
                        DatabaseParameterController dpController = new DatabaseParameterController();
                        dpController.SaveDatabaseParameters(ContactDB.MAX_CONTACT, newGroupCount);
                        doAdd = true;
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    doAdd = true;
                }
            }
            return doAdd;
        }
예제 #9
0
 private async void btnConfirmOk_Click(object sender, RoutedEventArgs e)
 {
     isImported = false;
     UpdateGUIWhenStartProgressImportContact();
     DatabaseParameterController dbParamController = new DatabaseParameterController();
     dbParamController.SaveDatabaseParameters(contactLimit, GroupDB.MAX_GROUP);
     await ImportContactsFromFile();
     UpdateGUIWhenStopProgressImportContact();
 }