diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-01-27 22:57:48 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-01-27 22:57:48 +0200 |
| commit | bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af (patch) | |
| tree | 9dc44c02e8f4128232f0c4c4ae87115221131605 /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB | |
| parent | 20482140c124fd1d5caaffcc9b0dfe853b30dd6f (diff) | |
| download | Tango-bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af.tar.gz Tango-bfc6aeabda4b320f9365f5eef4c8f1bcab9b24af.zip | |
Added IDS_PACK_FORMULA.
Added necessary login to machine designer & db module.
Started working on job segments.
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB')
10 files changed, 189 insertions, 9 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj index 54c29f7f3..c17c43aa0 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Tango.MachineStudio.DB.csproj @@ -114,6 +114,7 @@ <Compile Include="ViewModels\FiberShapesViewVM.cs" /> <Compile Include="ViewModels\FiberSynthsViewVM.cs" /> <Compile Include="ViewModels\HardwareVersionsViewVM.cs" /> + <Compile Include="ViewModels\IdsPackFormulasViewVM.cs" /> <Compile Include="ViewModels\IdsPacksViewVM.cs" /> <Compile Include="ViewModels\LinearMassDensityUnitsViewVM.cs" /> <Compile Include="ViewModels\LiquidTypesRmlsViewVM.cs" /> @@ -142,6 +143,12 @@ <Compile Include="Views\DBViews\ActionTypeView.xaml.cs"> <DependentUpon>ActionTypeView.xaml</DependentUpon> </Compile> + <Compile Include="Views\DBViews\IdsPackFormulasView.xaml.cs"> + <DependentUpon>IdsPackFormulasView.xaml</DependentUpon> + </Compile> + <Compile Include="Views\DBViews\IdsPackFormulaView.xaml.cs"> + <DependentUpon>IdsPackFormulaView.xaml</DependentUpon> + </Compile> <Compile Include="Views\DBViews\ProcessParametersTablesGroupsView.xaml.cs"> <DependentUpon>ProcessParametersTablesGroupsView.xaml</DependentUpon> </Compile> @@ -378,6 +385,14 @@ <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> </Page> + <Page Include="Views\DBViews\IdsPackFormulasView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> + <Page Include="Views\DBViews\IdsPackFormulaView.xaml"> + <Generator>MSBuild:Compile</Generator> + <SubType>Designer</SubType> + </Page> <Page Include="Views\DBViews\ProcessParametersTablesGroupsView.xaml"> <Generator>MSBuild:Compile</Generator> <SubType>Designer</SubType> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs index 8a7afc067..46223d9f4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModelLocator.cs @@ -36,6 +36,7 @@ namespace Tango.MachineStudio.DB SimpleIoc.Default.Register<HardwareVersionsViewVM>(); SimpleIoc.Default.Register<IdsPacksViewVM>(); + SimpleIoc.Default.Register<IdsPackFormulasViewVM>(); SimpleIoc.Default.Register<DispenserTypesViewVM>(); SimpleIoc.Default.Register<LiquidTypesViewVM>(); SimpleIoc.Default.Register<CartridgeTypesViewVM>(); @@ -358,5 +359,13 @@ namespace Tango.MachineStudio.DB return ServiceLocator.Current.GetInstance<ProcessParametersTablesGroupsViewVM>(); } } + + public static IdsPackFormulasViewVM IdsPackFormulasViewVM + { + get + { + return ServiceLocator.Current.GetInstance<IdsPackFormulasViewVM>(); + } + } } }
\ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs index ae4fa8a07..e1be2aa9b 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/DbTableViewModel.cs @@ -156,14 +156,6 @@ namespace Tango.MachineStudio.DB.ViewModels { using (_notification.PushTaskItem("Saving changes to database...")) { - //var dependenctEntities = SelectedEntity.GetDependentEntitiesNameAndGuid(); - - //if (dependenctEntities.Count > 0) - //{ - // _notification.ShowError("The selected entity is being used by " + dependenctEntities.Count + " other entities." + Environment.NewLine + "Please delete any dependencies and try again." + Environment.NewLine + Environment.NewLine + String.Join(Environment.NewLine, dependenctEntities.Select(x => x.Key + ", ID: " + x.Value))); - // return; - //} - try { await SelectedEntity.DeleteAsync(); @@ -226,12 +218,21 @@ namespace Tango.MachineStudio.DB.ViewModels using (_notification.PushTaskItem("Saving changes to database...")) { + if (mode == DialogOpenMode.Adding) + { + entity.Attach(); + } + try { await entity.SaveAsync(); } catch (DbUpdateException ex) { + if (mode == DialogOpenMode.Adding) + { + entity.Detach(); + } Adapter.Invalidate(); _notification.ShowError("Could not save entity." + Environment.NewLine + ex.InnerException.InnerException != null ? ex.InnerException.InnerException.Message : ex.InnerException.Message); } diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/IdsPackFormulasViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/IdsPackFormulasViewVM.cs new file mode 100644 index 000000000..a2763a257 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/ViewModels/IdsPackFormulasViewVM.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.DAL.Observables; +using Tango.MachineStudio.Common.Notifications; + +namespace Tango.MachineStudio.DB.ViewModels +{ + public class IdsPackFormulasViewVM : DbTableViewModel<IdsPackFormula> + { + public IdsPackFormulasViewVM(INotificationProvider notification) : base(notification) + { + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulaView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulaView.xaml new file mode 100644 index 000000000..83b2cc3d7 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulaView.xaml @@ -0,0 +1,33 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.IdsPackFormulaView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:mahapps="http://metro.mahapps.com/winfx/xaml/controls" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:colorPicker="clr-namespace:Tango;assembly=Tango.ColorPicker" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:vm="clr-namespace:Tango.MachineStudio.DB.ViewModels" + xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" + mc:Ignorable="d" + d:DesignHeight="400" d:DesignWidth="300" d:DataContext="{d:DesignInstance Type=vm:IdsPackFormulasViewVM, IsDesignTimeCreatable=False}"> + + <Grid> + <controls:TableGrid> + <TextBlock Text="ID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.ID}" IsReadOnly="True"></TextBox> + <TextBlock Text="GUID:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Guid}" IsReadOnly="True"></TextBox> + <TextBlock Text="Last Updated:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.LastUpdated}" IsReadOnly="True"></TextBox> + <TextBlock Text="Code:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding EditEntity.Code,Mode=TwoWay}"></mahapps:NumericUpDown> + <TextBlock Text="Name:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Name,Mode=TwoWay}"></TextBox> + <TextBlock Text="Description:" FontWeight="Bold"></TextBlock> + <TextBox Text="{Binding EditEntity.Description,Mode=TwoWay}"></TextBox> + <TextBlock Text="Auto Calculated:" FontWeight="Bold"></TextBlock> + <ToggleButton HorizontalAlignment="Right" IsChecked="{Binding EditEntity.AutoCalculated}"></ToggleButton> + </controls:TableGrid> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulaView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulaView.xaml.cs new file mode 100644 index 000000000..4c289ddd2 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulaView.xaml.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachineView.xaml + /// </summary> + public partial class IdsPackFormulaView : UserControl + { + public IdsPackFormulaView() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulasView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulasView.xaml new file mode 100644 index 000000000..81c9124f3 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulasView.xaml @@ -0,0 +1,31 @@ +<UserControl x:Class="Tango.MachineStudio.DB.Views.DBViews.IdsPackFormulasView" + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:global="clr-namespace:Tango.MachineStudio.DB" + xmlns:controls="clr-namespace:Tango.MachineStudio.DB.Controls" + xmlns:converters="clr-namespace:Tango.SharedUI.Converters;assembly=Tango.SharedUI" + xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" + mc:Ignorable="d" + d:DesignHeight="720" d:DesignWidth="1280" Background="White" DataContext="{x:Static global:ViewModelLocator.IdsPackFormulasViewVM}"> + + <UserControl.Resources> + <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter" /> + </UserControl.Resources> + + <Grid> + <controls:DbTableView> + <DataGrid Background="Transparent" ItemsSource="{Binding Adapter.IdsPackFormulasViewSource}" SelectedItem="{Binding SelectedEntity}" AutoGenerateColumns="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" IsReadOnly="True"> + <DataGrid.Columns> + <DataGridTextColumn Header="ID" Binding="{Binding ID}"></DataGridTextColumn> + <DataGridTextColumn Header="GUID" Binding="{Binding Guid}"></DataGridTextColumn> + <DataGridTextColumn Header="Code" Binding="{Binding Code}"></DataGridTextColumn> + <DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn> + <DataGridTextColumn Header="Description" Binding="{Binding Description}"></DataGridTextColumn> + <DataGridTextColumn Header="Auto Calculated" Binding="{Binding AutoCalculated,Converter={StaticResource BooleanToYesNoConverter}}"></DataGridTextColumn> + </DataGrid.Columns> + </DataGrid> + </controls:DbTableView> + </Grid> +</UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulasView.xaml.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulasView.xaml.cs new file mode 100644 index 000000000..079c48746 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackFormulasView.xaml.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using Tango.MachineStudio.DB.CustomAttributes; +using Tango.MachineStudio.DB.Managers; +using Tango.SharedUI.Controls; + +namespace Tango.MachineStudio.DB.Views.DBViews +{ + /// <summary> + /// Interaction logic for MachinesView.xaml + /// </summary> + [DBView] + public partial class IdsPackFormulasView : UserControl + { + public IdsPackFormulasView() : base() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackView.xaml index 537bdb9f7..75093aa77 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPackView.xaml @@ -10,7 +10,7 @@ xmlns:vm="clr-namespace:Tango.MachineStudio.DB.ViewModels" xmlns:local="clr-namespace:Tango.MachineStudio.DB.Views.DBViews" mc:Ignorable="d" - d:DesignHeight="400" d:DesignWidth="300" d:DataContext="{d:DesignInstance Type=vm:IdsPacksViewVM, IsDesignTimeCreatable=False}"> + d:DesignHeight="500" d:DesignWidth="300" d:DataContext="{d:DesignInstance Type=vm:IdsPacksViewVM, IsDesignTimeCreatable=False}"> <UserControl.Resources> <converters:ColorToIntegerConverter x:Key="ColorToIntegerConverter"></converters:ColorToIntegerConverter> @@ -68,6 +68,17 @@ </DataTemplate> </ComboBox.ItemTemplate> </ComboBox> + <TextBlock Text="Index:" FontWeight="Bold"></TextBlock> + <mahapps:NumericUpDown Minimum="0" Maximum="10000" InterceptArrowKeys="True" Background="Transparent" BorderThickness="0" InterceptMouseWheel="True" HasDecimals="False" HorizontalContentAlignment="Left" Value="{Binding EditEntity.PackIndex,Mode=TwoWay}"></mahapps:NumericUpDown> + + <TextBlock Text="Calculation Formula:" FontWeight="Bold"></TextBlock> + <ComboBox ItemsSource="{Binding Adapter.IdsPackFormulas}" SelectedItem="{Binding EditEntity.IdsPackFormula,Mode=TwoWay}"> + <ComboBox.ItemTemplate> + <DataTemplate> + <TextBlock><Run Text="{Binding Name}"></Run></TextBlock> + </DataTemplate> + </ComboBox.ItemTemplate> + </ComboBox> </controls:TableGrid> </Grid> </UserControl> diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPacksView.xaml b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPacksView.xaml index 0837bbf9f..03ab1d7d4 100644 --- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPacksView.xaml +++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.DB/Views/DBViews/IdsPacksView.xaml @@ -12,6 +12,7 @@ <UserControl.Resources> <converters:ColorToIntegerConverter x:Key="ColorToIntegerConverter"></converters:ColorToIntegerConverter> + <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter" /> </UserControl.Resources> <Grid> @@ -57,6 +58,8 @@ </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> + <DataGridTextColumn Header="Index" Binding="{Binding PackIndex}"></DataGridTextColumn> + <DataGridTextColumn Header="Formula" Binding="{Binding IdsPackFormula.Name}"></DataGridTextColumn> </DataGrid.Columns> </DataGrid> </controls:DbTableView> |
