public Control CallAddProductControl(string productScanCode, WarehouseContext dbcontext, Action <Product> createCallback = null)
        {
            var formControl = FormControlHelper.CreateFormControl();
            var product     = new Product();

            product.ScanCode = productScanCode;
            formControl.RenderForm(product, false);
            formControl.ConfirmButton.Content = "录入产品";
            formControl.SubmitCallback        = (d) =>
            {
                try
                {
                    dbcontext.Products.Add((Product)d);
                    dbcontext.SaveChanges();
                    if (createCallback != null)
                    {
                        createCallback((Product)d);
                    }
                }
                catch (Exception ex)
                {
                    //TODO: handle exception
                    formControl.SetErrorMsgManually("ScanCode", "此产品扫码已存在");
                }
            };

            return(formControl);
        }
Пример #2
0
        private static void LoadAppSettingsItems()
        {
            var inputSource          = string.Empty;
            var selectedOperations   = new List <string>();
            var fileTypeToConvertPdf = string.Empty;

            AppWindow.Dispatcher?.Invoke(() =>
            {
                fileTypeToConvertPdf = InfoConstants.AllButPdf;
                inputSource          = AppWindow.ComboBoxInputSource.SelectedValue.ToString();
                selectedOperations   = FormControlHelper.ConvertToList(AppWindow.ListBoxRight.Items.SourceCollection,
                                                                       AppSettingsConstants.OperationTypesExecutionSequence);
            });

            AppSettingsItems = new Dictionary <string, object>
            {
                { AppSettingsConstants.Source, inputSource },
                { AppSettingsConstants.SelectedOperations, selectedOperations },
                { AppSettingsConstants.FileTypeForConvertToPdf, fileTypeToConvertPdf },

                { AppSettingsConstants.InputPath, AppConfigReader.GetInputPath() },
                { AppSettingsConstants.RootOutputPath, AppConfigReader.GetRootOutputPath() },
                { AppSettingsConstants.RootLogPath, AppConfigReader.GetRootLogPath() },
                { AppSettingsConstants.OutputPath, "" },
                { AppSettingsConstants.LogPath, "" },

                { AppSettingsConstants.EnableCombinedLogAndReport, AppConfigReader.EnableCombinedLogAndReport() },
                { AppSettingsConstants.CombinedOutputPath, AppConfigReader.GetCombinedOutputPath() },
                { AppSettingsConstants.CombinedSummaryLogPath, AppConfigReader.GetCombinedSummaryLogPath() },
                { AppSettingsConstants.CombinedErrorLogPath, AppConfigReader.GetCombinedErrorLogPath() },

                { AppSettingsConstants.LogUpdateTimeInSec, AppConfigReader.GetLogUpdateTime() }
            };
        }
Пример #3
0
        /// <summary>
        /// Display all the mods of the Current profile
        /// </summary>
        private void UpdateProfileModsGrid()
        {
            var modCountString = App.FactorioLoader.Profiles.CurrentProfile.Mods.Count.ToString();

            currentProfileModCount.Text = $"Mods: {modCountString}";
            FormControlHelper.PopulateGridWithMods(profileModsGrid, App.FactorioLoader.Profiles.CurrentProfile.Mods);
        }
        public Control CallCreateUserControl(Action <User> createCallback = null)
        {
            var formControl = FormControlHelper.CreateFormControl();

            formControl.RenderForm(new User(), false);
            formControl.ConfirmButton.Content = "创建用户";
            formControl.SubmitCallback        = (d) =>
            {
                using (var dbcontext = new WarehouseContext())
                {
                    try
                    {
                        dbcontext.Users.Add((User)d);
                        dbcontext.SaveChanges();
                        if (createCallback != null)
                        {
                            createCallback((User)d);
                        }
                    }
                    catch (Exception ex)
                    {
                        //TODO: handle exception
                        formControl.SetErrorMsgManually("Username", "此用户名已存在,请更换");
                    }
                }
            };

            return(formControl);
        }
        public Goods CallRegisterGoodsPopup(Product product, WarehouseContext dbcontext)
        {
            Goods newGoods = null;
            var   window   = new NotifyWindow();

            window.Width  = 400;
            window.Height = 600;
            window.Title  = "添加货物";

            var formControl = FormControlHelper.CreateFormControl();
            var goods       = new Goods();

            goods.Product   = product;
            goods.Name      = product.Name;
            goods.State     = GoodsState.Inbound;
            goods.GoodsCode = DateTime.Now.ToString("yyyyMMddHHmmss") + "001";

            formControl.CreateControlCallback = (cx, ctl) =>
            {
                if (cx.ControlType == ControlType.Editable)
                {
                    switch (cx.PropertyInfo.Name)
                    {
                    case "Product":
                        var tb = new TextBox();
                        tb.Text      = product.Name;
                        tb.Style     = Application.Current.Resources["editctl_TextBox"] as Style;
                        tb.IsEnabled = false;
                        CustomValidation.SetValidationOptOut(tb);
                        return(tb);

                    case "GoodsCode":
                        ctl.IsEnabled = false;
                        return(ctl);
                    }
                }
                return(ctl);
            };

            formControl.RenderForm(goods, false);
            formControl.ConfirmButton.Content = "添加";
            formControl.SubmitCallback        = d =>
            {
                try
                {
                    newGoods             = d as Goods;
                    newGoods.InboundDate = DateTime.Now;
                    dbcontext.Goods.Add(newGoods);
                    window.Close();
                }
                catch (Exception ex)
                {
                    window.ShowNotificationMessage("添加货物失败,请重试。");
                }
            };
            window.MyContent = formControl;
            window.ShowDialog();
            return(newGoods);
        }
Пример #6
0
        /// <summary>
        /// Remove mods from profile
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void removeModButton_Click(object sender, EventArgs e)
        {
            var grid = profileModsGrid;

            App.FactorioLoader.Profiles.CurrentProfile.RemoveMods(
                FormControlHelper.GetModsFromGridSelection(grid));
            App.FactorioLoader.Profiles.CurrentProfile.Save();
            UpdateAllModData();
        }
        public void CallWarehouseInboundtPage()
        {
            WarehouseContext dbcontext;
            var tab         = WindowMgr.CreateTabPageWithDBContext("入库单", "入库单", false, out dbcontext);
            var formControl = FormControlHelper.CreateFormControl();

            formControl.CreateControlCallback = (cx, ctl) =>
            {
                if (cx.ControlType == ControlType.Label &&
                    cx.PropertyInfo.Name == "InboundGoods")
                {
                    ctl.VerticalAlignment = VerticalAlignment.Top;
                    return(ctl);
                }
                if (cx.ControlType == ControlType.Editable ||
                    cx.ControlType == ControlType.Readonly)
                {
                    switch (cx.PropertyInfo.Name)
                    {
                    case "Operator":
                        return(RenderSelectUserControl(cx, dbcontext));

                    case "InboundGoods":
                        return(new GoodsList(dbcontext));
                    }
                }
                return(ctl);
            };

            //form submit callback
            formControl.SubmitCallback = d =>
            {
                try
                {
                    dbcontext.WarehouseInbounds.Add((WarehouseInbound)d);
                    dbcontext.SaveChanges();
                    WindowMgr.SendNotification("入库成功", NotificationLevel.Information);
                    WindowMgr.CloseTabPage(tab);
                    dbcontext.Dispose();
                }
                catch (Exception ex)
                {
                    //TODO: handle exception
                    WindowMgr.SendNotification("入库操作失败", NotificationLevel.Error);
                }
            };

            var newinbound = new WarehouseInbound();

            newinbound.Name = string.Format("入库 - {0}", DateTime.Now);
            formControl.RenderForm(newinbound, false);
            formControl.ConfirmButton.Content = "入库";
            tab.Content = formControl;
        }
Пример #8
0
        private void deleteProfileButton_Click(object sender, EventArgs e)
        {
            var message = $"Are you sure you wish to delete profile {App.FactorioLoader.Profiles.CurrentProfile.Name}?";

            if (MetroMessageBox.Show(this, message, "Deleting Profile", MessageBoxButtons.YesNo, MessageBoxIcon.Warning)
                != DialogResult.Yes)
            {
                return;
            }

            App.FactorioLoader.Profiles.CurrentProfile.Delete();
            App.FactorioLoader.Profiles.RemoveCurrentProfile();
            FormControlHelper.PopulateProfileComboBox(profileComboBox);
            UpdateAllModData();
        }
Пример #9
0
        private void ButtonSaveSettings_OnClick(object sender, RoutedEventArgs e)
        {
            if (IsAnySettingsTabControlInputNotGiven())
            {
                FormControlHelper.ShowWarningAlertMsgBox(ApplicationConstants.InputControlEmpty);
                return;
            }

            if (FormControlHelper.ShowConfirmationMsgBox())
            {
                var appConfig = GetAppConfigWriterDictionary();
                AppConfigWriter.UpdateAppConfigKeys(appConfig);

                FormControlHelper.ShowSuccessAlertMsgBox(ApplicationConstants.Done);
            }
        }
Пример #10
0
        private void ComboBoxInputSource_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!(sender is ComboBox item))
            {
                return;
            }

            if (item.SelectedValue.ToString() == AppSettingsConstants.InputSource.List.ToString() ||
                item.SelectedValue.ToString() == AppSettingsConstants.InputSource.Directory.ToString())
            {
                TextBoxInputPath.Text = FormControlHelper.GetFolderPath();
            }
            // Todo: handle single file
            else
            {
                TextBoxInputPath.Text = string.Empty;
            }
        }
Пример #11
0
        private async void ButtonExecute_OnClick(object sender, RoutedEventArgs e)
        {
            if (IsAnyOptionsTabControlInputNotGiven())
            {
                FormControlHelper.ShowWarningAlertMsgBox(ApplicationConstants.InputControlEmpty);
                return;
            }

            AppConfigWriter.UpdateAppConfigKey(AppSettingsConstants.InputPath, TextBoxInputPath.Text);
            SetStatusLabel(false);

            var result = await Task.Run(() => OperationExecutor.ExecutePdfService());

            if (result)
            {
                SetStatusLabel();
                FormControlHelper.ShowSuccessAlertMsgBox(ApplicationConstants.Done);
            }
        }
        public Control CallViewUserControl(User user)
        {
            var formControl = FormControlHelper.CreateFormControl();

            // remove password
            formControl.DetermineFieldCreationCallback = (cx, s) =>
            {
                switch (cx.PropertyInfo.Name)
                {
                case "Username":
                    return(true);

                case "Password":
                    return(false);

                default:
                    return(s);
                }
            };
            formControl.RenderForm(user, true);
            return(formControl);
        }
Пример #13
0
        private void LoadDefaultLogSettings()
        {
            OperationExecutor.AppWindow = this;
            ListBoxLeft.ItemsSource     = _dataList = FormControlHelper.LoadListBoxData();

            // Load Combobox by input sources
            var inputSources = Enum.GetValues(typeof(AppSettingsConstants.InputSource)).Cast <AppSettingsConstants.InputSource>();
            var enumerable   = inputSources as AppSettingsConstants.InputSource[] ?? inputSources.ToArray();

            ComboBoxInputSource.ItemsSource = enumerable.Reverse().Skip(1); // Remove the single file input support

            // Setup from config
            TextBoxOutputPath.Text = AppConfigReader.GetRootOutputPath();
            TextBoxLogPath.Text    = AppConfigReader.GetRootLogPath();
            CheckBoxEnableCombinedLogAndReport.IsChecked = AppConfigReader.EnableCombinedLogAndReport();
            TextBoxCombinedOutputPath.Text     = AppConfigReader.GetCombinedOutputPath();
            TextBoxCombinedErrorLogPath.Text   = AppConfigReader.GetCombinedErrorLogPath();
            TextBoxCombinedSummaryLogPath.Text = AppConfigReader.GetCombinedSummaryLogPath();
            var updateTimeInSec = AppConfigReader.GetLogUpdateTime() / 1000;

            TextBoxLogUpdateTimeInSec.Text = updateTimeInSec.ToString();
        }
Пример #14
0
        /// <summary>
        /// When a grid selection changes then deselect all the other grids so
        /// only a single grid has selections.
        /// Also update the current Mod data
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ChangeGridSelection(object sender, EventArgs e)
        {
            var grid = (MetroGrid)sender;

            if (grid.SelectedRows.Count <= 0)
            {
                UpdateCurrentModDescription();
                return;
            }
            ;

            //Clear all other grid selections
            foreach (var g in AllGrids)
            {
                if (grid.Equals(g))
                {
                    continue;
                }

                g.ClearSelection();
            }
            UpdateCurrentModDescription(FormControlHelper.GetModsFromGridSelection(grid));
        }
        private StackLayout BuilContentChildren()
        {
            // var fontFamily = (string)((OnPlatform<string>)Application.Current.Resources["MaterialFontFamily"]).Platforms.FirstOrDefault(p => p.Platform[0] == Device.RuntimePlatform)?.Value; ;
            var phoneEntry = FormControlHelper.CreateStandardPhoneEntry("Phone Number");

            phoneEntry.SetBinding(Entry.TextProperty, nameof(ViewModel.PhoneNumber));

            var submitButton = FormControlHelper.CreateStandardButton("Submit");

            submitButton.Clicked += SendOtp;

            var stackLayout = new StackLayout
            {
                Spacing         = 0,
                VerticalOptions = LayoutOptions.FillAndExpand,
                Padding         = new Thickness(10),
                Children        =
                {
                    phoneEntry, submitButton
                }
            };

            return(stackLayout);
        }
        public Control CallUpdateUserControl(User user, Action <User> updateCallback = null)
        {
            var formControl = FormControlHelper.CreateFormControl();

            // remove password
            formControl.DetermineFieldCreationCallback = (cx, s) =>
            {
                switch (cx.PropertyInfo.Name)
                {
                case "Username":
                    return(true);

                default:
                    return(s);
                }
            };

            formControl.CreateControlCallback = (cx, c) =>
            {
                if (cx.ControlType == ControlType.Editable)
                {
                    if (cx.PropertyInfo.Name == "Password")
                    {
                        return(CreateResetPwdButton(user));
                    }
                    else if (cx.PropertyInfo.Name == "Username")
                    {
                        c.IsEnabled = false;
                    }
                }
                return(c);
            };

            formControl.SubmitCallback = (d) =>
            {
                using (var dbcontext = new WarehouseContext())
                {
                    try
                    {
                        var selectuser = d as User;
                        var updateuser = dbcontext.Users.Find(selectuser.UserId);
                        updateuser.Name                 = selectuser.Name;
                        updateuser.PhoneNumber          = selectuser.PhoneNumber;
                        updateuser.Memo                 = selectuser.Memo;
                        updateuser.IdentificationNumber = selectuser.IdentificationNumber;
                        updateuser.PermissionGroup      = selectuser.PermissionGroup;
                        updateuser.Department           = selectuser.Department;
                        dbcontext.SaveChanges();
                        WindowMgr.SendNotification("更新用户成功", NotificationLevel.Information);
                        if (updateCallback != null)
                        {
                            updateCallback(selectuser);
                        }
                    }
                    catch (Exception ex)
                    {
                        // TODO
                        WindowMgr.SendNotification("更新用户失败", NotificationLevel.Error);
                    }
                }
            };

            formControl.RenderForm(user, false);
            formControl.ConfirmButton.Content = "保存设置";

            return(formControl);
        }
Пример #17
0
 private void UpdateProfileModsGrid()
 {
     FormControlHelper.PopulateGridWithMods(
         profileModsGrid,
         App.FactorioLoader.Profiles.CurrentProfile.Mods);
 }
Пример #18
0
 private void UpdateAvailableModsGrid()
 {
     FormControlHelper.PopulateGridWithMods
         (availableModsGrid,
         GetModsInCurrentSection());
 }
Пример #19
0
 private void ProfileEditForm_Load(object sender, EventArgs e)
 {
     FormControlHelper.PopulateProfileComboBox(profileComboBox);
     UpdateAllModData();
     UpdateAvailableModsSections();
 }
Пример #20
0
 private void ButtonLogPath_OnClick(object sender, RoutedEventArgs e)
 {
     TextBoxLogPath.Text = FormControlHelper.GetFolderPath();
 }
Пример #21
0
 private void ButtonCombinedErrorLogPath_OnClick(object sender, RoutedEventArgs e)
 {
     TextBoxCombinedErrorLogPath.Text = FormControlHelper.GetFilePath(AppConfigReader.GetCombinedErrorLogPath());
 }
Пример #22
0
 private void ButtonCombinedOutputPath_OnClick(object sender, RoutedEventArgs e)
 {
     TextBoxCombinedOutputPath.Text = FormControlHelper.GetFilePath(AppConfigReader.GetCombinedOutputPath(), InfoConstants.StarCsvExtension);
 }
Пример #23
0
 /// <summary>
 /// Update the profile combo box
 /// </summary>
 private void UpdateProfileComboBox()
 {
     FormControlHelper.PopulateProfileComboBox(profileComboBox);
     profileComboBox.Items.Add(@"Add New Profile");
 }
Пример #24
0
        private void ButtonShowSupportedExtensions_OnClick(object sender, RoutedEventArgs e)
        {
            var supportedExtensions = $"Supported extensions for pdf conversion are: \n {string.Join(",  ", PdfService.Helper.ExtensionHelper.SupportedExt)}";

            FormControlHelper.ShowSuccessAlertMsgBox(supportedExtensions);
        }