This commit is contained in:
2020-11-29 11:05:11 +01:00
commit c0b307e98f
343 changed files with 24871 additions and 0 deletions

Binary file not shown.

BIN
.vs/Mercat-1/v16/.suo Normal file

Binary file not shown.

9
App.xaml Normal file
View File

@@ -0,0 +1,9 @@
<Application x:Class="Mercat_1.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Mercat_1"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

17
App.xaml.cs Normal file
View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace Mercat_1
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

10
AssemblyInfo.cs Normal file
View File

@@ -0,0 +1,10 @@
using System.Windows;
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

57
MainWindow.xaml Normal file
View File

@@ -0,0 +1,57 @@
<Window x:Class="Mercat_1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Mercat_1"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.Resources>
<ControlTemplate x:Key="ValidationTemplate">
<DockPanel>
<TextBlock Foreground="Red" FontSize="20">!</TextBlock>
<AdornedElementPlaceholder/>
</DockPanel>
</ControlTemplate>
<Style x:Key="TextBoxInError" TargetType="{x:Type TextBox}">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)[0].ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
</Grid.ColumnDefinitions>
<Button Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Height="52" Width="246" Click="Button_Click_1">
<StackPanel Orientation="Horizontal">
<Image Source="/document-edit.png">
</Image>
<TextBlock Margin="5,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="14">Nova Entrada</TextBlock>
</StackPanel>
</Button>
<Button Grid.Column="1" HorizontalAlignment="Center" Grid.Row="5" VerticalAlignment="Center" Height="52" Width="246" Click="Button_Click">
<StackPanel Orientation="Horizontal">
<Image Source="/application-exit.png">
</Image>
<TextBlock Margin="5,0" HorizontalAlignment="Stretch" VerticalAlignment="Center" FontSize="14">Sortir</TextBlock>
</StackPanel>
</Button>
</Grid>
</Window>

47
MainWindow.xaml.cs Normal file
View File

@@ -0,0 +1,47 @@
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 Mercat_1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
System.Windows.Application.Current.Shutdown();
}
private void Button_Click_1(object sender, RoutedEventArgs e)
{
// Instantiate the dialog box
var dlg = new Window1
{
Owner = this,
};
dlg.ShowDialog();
}
}
}

63
Mercat-1.csproj Normal file
View File

@@ -0,0 +1,63 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RootNamespace>Mercat_1</RootNamespace>
<UseWPF>true</UseWPF>
<Platforms>AnyCPU;x86</Platforms>
</PropertyGroup>
<ItemGroup>
<Page Remove="UserControl1.xaml" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="itext7" Version="7.1.13" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="5.0.0" />
<PackageReference Include="Prism.Core" Version="8.0.0.1909" />
</ItemGroup>
<ItemGroup>
<Reference Include="DotNetKit.Wpf.AutoCompleteComboBox">
<HintPath>C:\Users\Vicente\git-repos\DotNetKit.Wpf.AutoCompleteComboBox\DotNetKit.Wpf.AutoCompleteComboBox\bin\Release\netcoreapp3.1\DotNetKit.Wpf.AutoCompleteComboBox.dll</HintPath>
<Private>true</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="application-exit.png" />
<Resource Include="document-edit.png" />
</ItemGroup>
<ItemGroup>
<Compile Update="Properties\Resources.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Update="Properties\Settings.Designer.cs">
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Update="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Update="Mercatflor.accdb">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Update="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
</Project>

28
Mercat-1.csproj.user Normal file
View File

@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="View\SingleNumericTextBoxView.xaml.cs">
<SubType>Code</SubType>
</Compile>
<Compile Update="View\Window1.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="View\SingleNumericTextBoxView.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="View\Window1.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

31
Mercat-1.sln Normal file
View File

@@ -0,0 +1,31 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mercat-1", "Mercat-1.csproj", "{130C3EBF-FC99-4E09-A78C-4430A74356A3}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Debug|x86.ActiveCfg = Debug|x86
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Debug|x86.Build.0 = Debug|x86
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Release|Any CPU.Build.0 = Release|Any CPU
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Release|x86.ActiveCfg = Release|x86
{130C3EBF-FC99-4E09-A78C-4430A74356A3}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6AFE8BA6-F7C6-4D92-AA22-AAD416861579}
EndGlobalSection
EndGlobal

BIN
Mercatflor.accdb Normal file

Binary file not shown.

52
MyDataSource.cs Normal file
View File

@@ -0,0 +1,52 @@
using System;
namespace Mercat_1
{
public class MyDataSource
{
public MyDataSource()
{
zeroval = 0;
z1 = 0;
z2 = 0;
z3 = 0;
z4 = 0;
z5 = 0;
z6 = 0;
z7 = 0;
z8 = 0;
z9 = 0;
z10 = 0;
z11 = 0;
z12 = 0;
z13 = 0;
z14 = 0;
z15 = 0;
z16 = 0;
z17 = 0;
Name = "";
Date = DateTime.Now;
}
public int zeroval { get; set; }
public int z1 { get; set; }
public int z2 { get; set; }
public int z3 { get; set; }
public int z4 { get; set; }
public int z5 { get; set; }
public int z6 { get; set; }
public int z7 { get; set; }
public int z8 { get; set; }
public int z9 { get; set; }
public int z10 { get; set; }
public int z11 { get; set; }
public int z12 { get; set; }
public int z13 { get; set; }
public int z14 { get; set; }
public int z15 { get; set; }
public int z16 { get; set; }
public int z17 { get; set; }
public string Name { get; set; }
public DateTime Date { get; set; }
}
}

63
Properties/Resources.Designer.cs generated Normal file
View File

@@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión de runtime:4.0.30319.42000
//
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
// se vuelve a generar el código.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Mercat_1.Properties {
using System;
/// <summary>
/// Clase de recurso fuertemente tipado, para buscar cadenas traducidas, etc.
/// </summary>
// StronglyTypedResourceBuilder generó automáticamente esta clase
// a través de una herramienta como ResGen o Visual Studio.
// Para agregar o quitar un miembro, edite el archivo .ResX y, a continuación, vuelva a ejecutar ResGen
// con la opción /str o recompile su proyecto de VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Devuelve la instancia de ResourceManager almacenada en caché utilizada por esta clase.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Mercat_1.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Reemplaza la propiedad CurrentUICulture del subproceso actual para todas las
/// búsquedas de recursos mediante esta clase de recurso fuertemente tipado.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

101
Properties/Resources.resx Normal file
View File

@@ -0,0 +1,101 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 1.3
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">1.3</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1">this is my long string</data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
[base64 mime encoded serialized .NET Framework object]
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
[base64 mime encoded string representing a byte array form of the .NET Framework object]
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>1.3</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

26
Properties/Settings.Designer.cs generated Normal file
View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Este código fue generado por una herramienta.
// Versión de runtime:4.0.30319.42000
//
// Los cambios en este archivo podrían causar un comportamiento incorrecto y se perderán si
// se vuelve a generar el código.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Mercat_1.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,6 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
</SettingsFile>

28
Settings.cs Normal file
View File

@@ -0,0 +1,28 @@
namespace Mercat_1.Properties {
// Esta clase le permite controlar eventos específicos en la clase de configuración:
// El evento SettingChanging se desencadena antes de cambiar un valor de configuración.
// El evento PropertyChanged se desencadena después de cambiar el valor de configuración.
// El evento SettingsLoaded se desencadena después de cargar los valores de configuración.
// El evento SettingsSaving se desencadena antes de guardar los valores de configuración.
internal sealed partial class Settings {
public Settings() {
// // Para agregar los controladores de eventos para guardar y cambiar la configuración, quite la marca de comentario de las líneas:
//
// this.SettingChanging += this.SettingChangingEventHandler;
//
// this.SettingsSaving += this.SettingsSavingEventHandler;
//
}
private void SettingChangingEventHandler(object sender, System.Configuration.SettingChangingEventArgs e) {
// Agregar código para administrar aquí el evento SettingChangingEvent.
}
private void SettingsSavingEventHandler(object sender, System.ComponentModel.CancelEventArgs e) {
// Agregar código para administrar aquí el evento SettingsSaving.
}
}
}

View File

@@ -0,0 +1,35 @@
<UserControl x:Class="Mercat_1.SingleNumericTextBoxView"
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:local="clr-namespace:Mercat_1"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<UserControl.Resources>
<local:MyDataSource x:Key="Ods"/>
<Style x:Key="errorToolTip" TargetType="Control">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip"
Value="{
Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)/ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource errorToolTip}"/>
</UserControl.Resources>
<Grid>
<TextBox x:Name="age" Height="Auto" Width="Auto"
Margin="5" Grid.Column="1" Grid.Row="1" >
<TextBox.Text>
<Binding Path="zeroval" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
</Grid>
</UserControl>

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Text;
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 Mercat_1
{
/// <summary>
/// Lógica de interacción para SingleNumericTextBoxView.xaml
/// </summary>
public partial class SingleNumericTextBoxView : UserControl
{
public SingleNumericTextBoxView()
{
InitializeComponent();
}
}
}

303
View/Window1.xaml Normal file
View File

@@ -0,0 +1,303 @@
<Window x:Class="Mercat_1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:dotNetKitControls="clr-namespace:DotNetKit.Windows.Controls;assembly=DotNetKit.Wpf.AutoCompleteComboBox"
xmlns:local="clr-namespace:Mercat_1" WindowStartupLocation="CenterScreen"
mc:Ignorable="d"
Title="Nou Moviment de material" Height="609" Width="621">
<Window.Resources>
<ResourceDictionary>
<!-- This style applies to all auto-complete comboboxes in the window by default. -->
<Style TargetType="dotNetKitControls:AutoCompleteComboBox">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<VirtualizingStackPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
<local:MyDataSource x:Key="Ods"/>
<Style x:Key="errorToolTip" TargetType="Control">
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip"
Value="{
Binding RelativeSource={x:Static RelativeSource.Self},
Path=(Validation.Errors)/ErrorContent}"/>
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource errorToolTip}"/>
</ResourceDictionary>
</Window.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0.3*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="1*"/>
<ColumnDefinition Width="0.3*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="4*"/>
<RowDefinition Height="1*"/>
<RowDefinition Height="1*"/>
</Grid.RowDefinitions>
<TextBlock Grid.Column="2" Grid.Row="0" Margin="5" Text="Empresa:"/>
<TextBlock Grid.Column="2" Grid.Row="1" Margin="5" Text="Data:"/>
<!--ItemsSource="{Binding Items}"-->
<dotNetKitControls:AutoCompleteComboBox
x:Name="llistaEmpreses"
Margin="6"
Width="Auto"
Height="Auto"
Grid.Column="3"
Grid.Row="0"
SelectedValuePath="numClient"
TextSearch.TextPath="Name"
SelectedItem="{Binding SelectedItem}"
SelectedValue="{Binding SelectedValue}">
<dotNetKitControls:AutoCompleteComboBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Name}" FontWeight="Bold" />
<!-- <TextBlock>
Some descriptions. Id = <Run Text="{Binding Id, Mode=OneTime}" />.
</TextBlock> -->
</StackPanel>
</DataTemplate>
</dotNetKitControls:AutoCompleteComboBox.ItemTemplate>
</dotNetKitControls:AutoCompleteComboBox>
<!--
<TextBox x:Name="empresa" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="0" >
<TextBox.Text>
<Binding Path="Name" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NameValidationRule/>
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
-->
<DatePicker x:Name="data" Grid.Column="3" Grid.Row="1" Height="Auto" Width="Auto" Margin="6">
<DatePicker.SelectedDate>
<Binding Path="Date" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:DateValidation/>
</Binding.ValidationRules>
</Binding>
</DatePicker.SelectedDate>
</DatePicker>
<TextBlock Grid.Column="2" HorizontalAlignment="Center" Grid.Row="2" Text="ENTRADA" TextWrapping="Wrap" VerticalAlignment="Center" FontWeight="Bold">
<TextBlock.TextDecorations>
<TextDecoration/>
</TextBlock.TextDecorations>
</TextBlock>
<TextBlock Grid.Column="3" HorizontalAlignment="Center" Grid.Row="2" Text="SORTIDA" TextWrapping="Wrap" VerticalAlignment="Center" FontWeight="Bold">
<TextBlock.TextDecorations>
<TextDecoration/>
</TextBlock.TextDecorations>
</TextBlock>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="3" Text="Carros DC: " TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBox x:Name="entrada_dc" Height="Auto" Width="Auto"
Margin="10" Grid.Column="2" Grid.Row="3" >
<TextBox.Text>
<Binding Path="z1" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox x:Name="sortida_dc" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="3" >
<TextBox.Text>
<Binding Path="z2" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="4" Text="Carros CC+: " TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBox x:Name="entrada_cc" Height="Auto" Width="Auto"
Margin="10" Grid.Column="2" Grid.Row="4" >
<TextBox.Text>
<Binding Path="z3" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox x:Name="sortida_cc" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="4" >
<TextBox.Text>
<Binding Path="z4" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="5" Text="Carros Tag5: " TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBox x:Name="entrada_tag5" Height="Auto" Width="Auto"
Margin="10" Grid.Column="2" Grid.Row="5" >
<TextBox.Text>
<Binding Path="z5" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox x:Name="sortida_tag5" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="5" >
<TextBox.Text>
<Binding Path="z6" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="6" Text="Safates: " TextWrapping="Wrap" VerticalAlignment="Center" RenderTransformOrigin="0.527,-1.118"/>
<TextBox x:Name="entrada_safates" Height="Auto" Width="Auto"
Margin="10" Grid.Column="2" Grid.Row="6" >
<TextBox.Text>
<Binding Path="z7" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox x:Name="sortida_safates" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="6" >
<TextBox.Text>
<Binding Path="z8" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="7" Text="Alçes Curtes: " TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBox x:Name="entrada_alsacurta" Height="Auto" Width="Auto"
Margin="10" Grid.Column="2" Grid.Row="7" >
<TextBox.Text>
<Binding Path="z9" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox x:Name="sortida_alsacurta" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="7" >
<TextBox.Text>
<Binding Path="z10" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="8" Text="Alçes Llarges: " TextWrapping="Wrap" VerticalAlignment="Center"/>
<TextBox x:Name="entrada_alsallarga" Height="Auto" Width="Auto"
Margin="10" Grid.Column="2" Grid.Row="8" >
<TextBox.Text>
<Binding Path="z11" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBox x:Name="sortida_alsallarga" Height="Auto" Width="Auto"
Margin="10" Grid.Column="3" Grid.Row="8" >
<TextBox.Text>
<Binding Path="z12" Source="{StaticResource Ods}" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<local:NumValidationRule Min="0" Max="9999" />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
<TextBlock Grid.Column="1" HorizontalAlignment="Right" Grid.Row="9" Text="Observacions: " TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,10,0,0"/>
<TextBox x:Name="Observacions" Height="120" HorizontalAlignment="Stretch" AcceptsReturn="True" TextWrapping="Wrap" Grid.Column="2" Margin="10" Grid.Row="9" VerticalAlignment="Top" Grid.ColumnSpan="2" />
<!-- <Button Content="Desar" Grid.Column="2" HorizontalAlignment="Center" Grid.Row="9" VerticalAlignment="Center"
Width="153" Height="26" Click="okButton_Click"/> -->
<Button Content="Desar"
Grid.Column="2" Grid.Row="10"
HorizontalContentAlignment="Center" Width="152" Height="26"
VerticalAlignment="Center"
Click="okButton_Click">
<Button.Style>
<Style TargetType="Button">
<Setter Property="IsEnabled" Value="False"/>
<Style.Triggers>
<MultiDataTrigger>
<MultiDataTrigger.Conditions>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=data}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=entrada_dc}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=entrada_cc}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=entrada_tag5}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=entrada_alsacurta}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=entrada_alsallarga}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=entrada_safates}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=sortida_dc}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=sortida_cc}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=sortida_tag5}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=sortida_safates}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=sortida_alsacurta}" Value="False"/>
<Condition Binding="{Binding Path=(Validation.HasError), ElementName=sortida_alsallarga}" Value="False"/>
</MultiDataTrigger.Conditions>
<Setter Property="IsEnabled" Value="True"/>
</MultiDataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
<Button Content="Torna" Grid.Column="3" HorizontalAlignment="Center" Grid.Row="10" VerticalAlignment="Center" Width="152" Height="26" Click="cancelButton_Click"/>
</Grid>
</Window>

339
View/Window1.xaml.cs Normal file
View File

@@ -0,0 +1,339 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
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 System.Data.OleDb;
using System.Data;
using Mercat_1.Empreses;
using Mercat_1.PdfCreator;
using System.Diagnostics;
namespace Mercat_1
{
/// <summary>
/// Lógica de interacción para Window1.xaml
/// </summary>
public partial class Window1 : Window
{
#region ViewModel
sealed class ViewModel
: INotifyPropertyChanged
{
#region INotifyPropertyChanged
public event PropertyChangedEventHandler PropertyChanged;
void SetField<X>(ref X field, X value, [CallerMemberName] string propertyName = null)
{
if (EqualityComparer<X>.Default.Equals(field, value)) return;
field = value;
var h = PropertyChanged;
if (h != null) h(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
// Autocombobox Default settings
//public IReadOnlyList<Person> Items
//{
// get { return PersonModule.All; }
//}
Empresa selectedItem;
public Empresa SelectedItem
{
get { return selectedItem; }
set { SetField(ref selectedItem, value); }
}
long? selectedValue;
public long? SelectedValue
{
get { return selectedValue; }
set { SetField(ref selectedValue, value); }
}
}
#endregion
public Window1()
{
InitializeComponent();
if (!FillComboBox())
{
DialogResult = false;
}
}
#region Fillcombobox
public bool FillComboBox()
{
bool success = true;
try
{
DataTable dt = new DataTable();
using (OleDbConnection connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\source\\Mercat-1\\Mercatflor.accdb;Persist Security Info=True"))
{
using (OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM empreses", connection))
{
da.Fill(dt);
}
}
//select new Empresa(Convert.ToUInt32(dr["Id"]), dr["Empresa"].ToString())).ToList();
IReadOnlyList<Empresa> empresesList = (from DataRow dr in dt.Rows
select new Empresa(Convert.ToUInt32(dr["Id"]), Convert.ToUInt32(dr["numClient"]), dr["Empresa"].ToString())).ToList();
llistaEmpreses.ItemsSource = empresesList;
}
catch (System.Data.OleDb.OleDbException oleError)
{
DisplayOleDbErrorCollection(oleError);
success = false;
}
catch (Exception ex)
{
MessageBox.Show(string.Format("{0} Exception caught.", ex), "ERROR");
success = false;
}
return success;
}
public void DisplayOleDbErrorCollection(OleDbException exception)
{
for (int i = 0; i < exception.Errors.Count; i++)
{
MessageBox.Show("Index #" + i + "\n" +
"Message: " + exception.Errors[i].Message + "\n" +
"Native: " + exception.Errors[i].NativeError.ToString() + "\n" +
"Source: " + exception.Errors[i].Source + "\n" +
"SQL: " + exception.Errors[i].SQLState + "\n");
}
}
#endregion
public Thickness DocumentMargin
{
get { return (Thickness)DataContext; }
set { DataContext = value; }
}
private void cancelButton_Click(object sender, RoutedEventArgs e)
{
// Dialog box canceled
DialogResult = false;
}
private void okButton_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(llistaEmpreses.Text.ToString()))
{
MessageBox.Show("El nombre de empresa esta vacio o no es correcto", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error);
}
bool saveresult = SaveDatatoDB();
MypdfApp rere = new MypdfApp();
SendToPrinter();
string myMsg = "Combobox.Text: " + llistaEmpreses.Text + "\n" + string.Format("SelectedItem: {0} \n SelectedValue: {1}",llistaEmpreses.SelectedItem, llistaEmpreses.SelectedValue);
MessageBoxResult result = MessageBox.Show(myMsg, "Resultados", MessageBoxButton.YesNoCancel);
// Dialog box accepted
//DialogResult = true;
}
private void SendToPrinter()
{
ProcessStartInfo info = new ProcessStartInfo();
info.Verb = "print";
info.FileName = @"E:\\source\\Mercat-1\\demo.pdf";
info.CreateNoWindow = true;
info.WindowStyle = ProcessWindowStyle.Hidden;
Process p = new Process();
p.StartInfo = info;
p.Start();
p.WaitForInputIdle();
System.Threading.Thread.Sleep(3000);
if (false == p.CloseMainWindow())
p.Kill();
}
#region SaveFormData
private bool SaveDatatoDB()
{
bool success = true;
/*
* llistaempreses - Combobox amb el nom de l'empresa
* data - Data de l'operació
* entrada_dc / sortida_dc - Entrades i sortides de carros DC
* entrada_cc / sortida_cc - Entrades i sortides de carros CC+
* entrada_tag5 / sortida_tag5 - Entrades i sortides de carros Tag5
* entrada_safates / sortida_safates - Entrades i sortides de Safates
* entrada_alsacurta / sortida_alsacurta - Entrades i sortides de alces curtes
* entrada_alsallarga / sortida_alsallarga - Entrades i sortides de alces llargues
* Observacions - observacions de l'entrada
*/
try
{
using (OleDbConnection connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\source\\Mercat-1\\Mercatflor.accdb;Persist Security Info=True"))
{
// Insertamos los datos del formulario en la tabla 'moviments' de la base de datos
connection.Open();
string queryInsertMovement = "INSERT INTO moviments (data, numClient, entrada_dc, entrada_cc, entrada_tag5, entrada_safates, entrada_alsacurta, entrada_alsallarga, observacions, sortida_dc, sortida_cc, sortida_tag5, sortida_safates, sortida_alsacurta, sortida_alsallarga)" +
" VALUES (@Data, '" + llistaEmpreses.SelectedValue.ToString() + "'," + entrada_dc.Text.ToString() + "," + entrada_cc.Text.ToString() + "," + entrada_tag5.Text.ToString() + "," +
entrada_safates.Text.ToString() + "," + entrada_alsacurta.Text.ToString() + "," + entrada_alsallarga.Text.ToString() + ",'" + Observacions.Text.ToString() + "'," +
sortida_dc.Text.ToString() + "," + sortida_cc.Text.ToString() + "," + sortida_tag5.Text.ToString() + "," + sortida_safates.Text.ToString() + "," +
sortida_alsacurta.Text.ToString() + "," + sortida_alsallarga.Text.ToString() + ")";
using (OleDbCommand cmd = new OleDbCommand(queryInsertMovement, connection))
{
cmd.Parameters.Add("@Data", OleDbType.Date).Value = data.SelectedDate.Value.Date;
try
{
cmd.ExecuteNonQuery();
}
catch (InvalidOperationException inv)
{
MessageBox.Show(string.Format("{0} ", inv), "ERROR");
}
}
// Buscamos en la tabla 'sumatori' si el cliente tiene registros
bool hasRecords = false;
bool canContinue = true;
int dbId = 0;
Int64 dbNumClient = (Int64)llistaEmpreses.SelectedValue;
int dbTotalDC = Int32.Parse(entrada_dc.Text) - Int32.Parse(sortida_dc.Text);
int dbTotalCC = Int32.Parse(entrada_cc.Text) - Int32.Parse(sortida_cc.Text);
int dbTotalTag = Int32.Parse(entrada_tag5.Text) - Int32.Parse(sortida_tag5.Text);
int dbTotalSafates = Int32.Parse(entrada_safates.Text) - Int32.Parse(sortida_safates.Text);
int dbTotalAlsaCurta = Int32.Parse(entrada_alsacurta.Text) - Int32.Parse(sortida_alsacurta.Text);
int dbTotalAlsaLlarga = Int32.Parse(entrada_alsallarga.Text) - Int32.Parse(sortida_alsallarga.Text);
string dbObservacions = string.Empty;
DateTime dbDataActualit;
string finalSqlQuery = string.Empty;
string queryBuscarCliente = string.Format("SELECT * FROM sumatori WHERE numClient = {0}", llistaEmpreses.SelectedValue);
using (OleDbDataAdapter da = new OleDbDataAdapter(queryBuscarCliente, connection))
{
try
{
DataTable dt = new DataTable();
da.Fill(dt);
if (dt != null)
{
foreach (DataRow dr in dt.Rows)
{
dbId = dr.Field<int>("Id");
dbNumClient = dr.Field<Int64>("numClient");
dbDataActualit = dr.Field<DateTime>("data_actualitzacio");
dbTotalDC += dr.Field<int>("total_dc");
dbTotalCC += dr.Field<int>("total_cc");
dbTotalTag += dr.Field<int>("total_tag5");
dbTotalSafates += dr.Field<int>("total_safates");
dbTotalAlsaCurta += dr.Field<int>("total_alsacurta");
dbTotalAlsaLlarga += dr.Field<int>("total_alsallarga");
dbObservacions = dr.Field<string>("observacions");
hasRecords = true;
//break;
}
}
else
{
canContinue = false;
}
}
catch (InvalidOperationException inv)
{
MessageBox.Show(string.Format("{0} ", inv), "ERROR");
canContinue = false;
}
}
if (canContinue)
{
dbDataActualit = DateTime.Now;
// si Observacions.text.lenght == 0 llavors "" sino afegim
if (Observacions.Text.Length > 0) { dbObservacions += dbDataActualit.ToString() + " -> " + Observacions.Text + "\n"; };
if (hasRecords)
{
// Update records
//dbObservacions += dbDataActualit.ToString() + " -> " + Observacions.Text + "\n";
finalSqlQuery = "UPDATE sumatori SET data_actualitzacio = '" + dbDataActualit.ToString() + "', total_dc = " + dbTotalDC.ToString() + ", total_cc = " + dbTotalCC.ToString() +
", total_tag5 = " + dbTotalTag.ToString() + ", total_safates = " + dbTotalSafates.ToString() + ", total_alsacurta = " + dbTotalAlsaCurta.ToString() +
", total_alsallarga = " + dbTotalAlsaLlarga.ToString() + ",observacions = '" + dbObservacions + "' WHERE numClient = " + llistaEmpreses.SelectedValue.ToString();
}
else
{
// Insert records
//dbObservacions = dbDataActualit.ToString() + " -> " + Observacions.Text + "\n";
finalSqlQuery = "INSERT INTO sumatori (numClient, data_actualitzacio, total_dc, total_cc, total_tag5, total_safates, total_alsacurta, total_alsallarga, observacions)" +
" VALUES ('" + llistaEmpreses.SelectedValue.ToString() + "','" + dbDataActualit.ToString() + "'," + dbTotalDC.ToString() + "," + dbTotalCC.ToString() + "," +
dbTotalTag.ToString() + "," + dbTotalSafates.ToString() + "," + dbTotalAlsaCurta.ToString() + "," + dbTotalAlsaLlarga.ToString() + ",'" +
dbObservacions + "')";
}
using (OleDbCommand cmd = new OleDbCommand(finalSqlQuery, connection))
{
//cmd.Parameters.Add("@Data", OleDbType.Date).Value = dbDataActualit.ToString();
try
{
cmd.ExecuteNonQuery();
}
catch (InvalidOperationException inv)
{
MessageBox.Show(string.Format("{0} ", inv), "ERROR");
}
}
}
else
{
// ERROR
MessageBoxResult result = MessageBox.Show("Ha ocurrido un error mientras se obtenia datos de la base de datos.", "ERROR", MessageBoxButton.OK, MessageBoxImage.Error );
success = false;
}
//
connection.Close();
}
}
catch (System.Data.OleDb.OleDbException oleError)
{
DisplayOleDbErrorCollection(oleError);
success = false;
}
catch (Exception ex)
{
MessageBox.Show(string.Format("{0} Exception caught.", ex), "ERROR");
success = false;
}
return success;
}
#endregion
}
}

108
ViewModel/DBConnection.cs Normal file
View File

@@ -0,0 +1,108 @@
using System;
using System.Data;
using System.Data.OleDb;
/*
SELECT QUERY
------------
string query = "SELECT * FROM [MyTable]";
DBConnect db = new DBConnect();
db.Connect();
DataTable dt = db.Select(query);
db.DisConnect();
OTROS QUERYS
------------
DBConnect db = new DBConnect();
db.Connect();
db.Script(query);
db.DisConnect();
*/
namespace Mercat_1.DBConnect
{
public class DBConnect
{
OleDbConnection connection;
OleDbCommand cmd;
OleDbDataAdapter adapter;
bool isset = false;
public DBConnect()
{
connection = new OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0; Data Source=" + AppDomain.CurrentDomain.BaseDirectory + "\\Mercatflor.accdb;Persist Security Info=True");
}
public string Script(string Query)
{
if (isset)
{
try
{
cmd = new OleDbCommand(CheckInject(Query), connection);
object result = cmd.ExecuteScalar();
if (result == null)
return "1";
else
return result.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
}
return "0";
}
public DataTable Select(string Query)
{
if (isset)
{
DataTable dt = new DataTable();
adapter = new OleDbDataAdapter(CheckInject(Query), connection);
adapter.Fill(dt);
return dt;
}
return new DataTable();
}
public void Connect()
{
if (!isset)
{
connection.Open();
isset = true;
}
}
public void DisConnect()
{
if (isset)
{
connection.Close();
//connection = null;
adapter = null;
cmd = null;
isset = false;
}
}
public string CheckInject(string sql)
{
sql = sql.Replace("--", " ");
sql = sql.Replace("/*", " ");
//sql = sql.Replace('%', ' ');
//sql.Replace('*', ' ');
return sql;
}
public string CheckInjectText(string sql)
{
sql = sql.Replace(',', ' ');
sql.Replace('$', ' ');
sql.Replace('^', ' ');
sql.Replace('%', ' ');
return sql;
}
}
}

50
ViewModel/Empreses.cs Normal file
View File

@@ -0,0 +1,50 @@
namespace Mercat_1.Empreses
{
public sealed class Empresa
{
public long Id { get; private set; }
public long numClient { get; private set; }
public string Name { get; private set; }
public override string ToString()
{
return string.Format("Id = {0}, NumClient = {1} nomEmpresa = {2}", Id, numClient, Name);
//return string.Format("Person(numClient = {0}, Name = {2})", numClient, Name);
}
public Empresa(long id, long numclient, string name)
//public Empresa(long numclient, string name)
{
Id = id;
numClient = numclient;
Name = name;
}
}
/*
* Default class from AutocompleteCombobox
public static class PersonModule
{
/// <summary>
/// List of name automatically generated by http://listofrandomnames.com . Thanks!
/// </summary>
static readonly string source =
@"
Aaron Custodio
Zulma Avent
";
static readonly IReadOnlyList<Person> allPersons =
source.Split(new[] { Environment.NewLine, "\n" }, StringSplitOptions.RemoveEmptyEntries)
.Select((name, i) => new Person(i + 1L, name))
.ToArray();
public static IReadOnlyList<Person> All
{
get { return allPersons; }
}
}
*/
}

View File

@@ -0,0 +1,106 @@
using System;
using System.Globalization;
using System.Windows.Controls;
using System.Net.Mail;
namespace Mercat_1
{
/// <summary>
/// Rule for email
/// </summary>
public class EmailValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
ValidationResult result = new ValidationResult(true, null);
if (string.IsNullOrEmpty(value.ToString()))
{
result = new ValidationResult(false, "Email obligatori.");
}
else
{
try
{
new MailAddress(value.ToString());
}
catch (Exception)
{
result = new ValidationResult(false, "Si us plau introdueix un email valid.");
}
}
return result;
}
}
/// <summary>
/// Rule for num
/// </summary>
public class NumValidationRule : ValidationRule
{
public int Min { get; set; }
public int Max { get; set; }
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
var num = 0;
ValidationResult result = new ValidationResult(true, null);
if (string.IsNullOrEmpty(value.ToString()))
{
result = new ValidationResult(false, "Quantitat es obligatoria");
}
else
{
try
{
if (((string)value).Length > 0)
num = int.Parse((string)value);
}
catch (Exception e)
{
result = new ValidationResult(false, "Caracters no permesos o : " + e.Message);
}
if ((num < Min) || (num > Max))
{
result = new ValidationResult(false, "Introdueix un numero entre: " + Min + " - " + Max + ".");
}
}
return result;
}
}
/// <summary>
/// Rule for name
/// </summary>
public class NameValidationRule : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
ValidationResult result = new ValidationResult(true, null);
if (string.IsNullOrEmpty(value.ToString()))
{
result = new ValidationResult(false, "Nom de l'empresa es obligatori.");
}
return result;
}
}
public class DateValidation : ValidationRule
{
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
{
ValidationResult result = new ValidationResult(true, null);
if (value is null)
{
result = new ValidationResult(false, "Data d'entrada obligatoria.");
}
return result;
}
}
}

131
ViewModel/pdfCreator.cs Normal file
View File

@@ -0,0 +1,131 @@
using iText.IO.Image;
using iText.Kernel.Colors;
using iText.Kernel.Pdf;
using iText.Kernel.Pdf.Action;
using iText.Kernel.Pdf.Canvas.Draw;
using iText.Layout;
using iText.Layout.Element;
using iText.Layout.Properties;
using System;
namespace Mercat_1.PdfCreator
{
public class MypdfApp
{
public MypdfApp()
{
this.createPdf();
}
private void createPdf()
{
// Must have write permissions to the path folder
PdfWriter writer = new PdfWriter("E:\\source\\Mercat-1\\demo.pdf");
PdfDocument pdf = new PdfDocument(writer);
Document document = new Document(pdf);
// Header
Paragraph header = new Paragraph("HEADER")
.SetTextAlignment(TextAlignment.CENTER)
.SetFontSize(20);
// New line
Paragraph newline = new Paragraph(new Text("\n"));
document.Add(newline);
document.Add(header);
// Add sub-header
Paragraph subheader = new Paragraph("SUB HEADER")
.SetTextAlignment(TextAlignment.CENTER)
.SetFontSize(15);
document.Add(subheader);
// Line separator
LineSeparator ls = new LineSeparator(new SolidLine());
document.Add(ls);
// Add paragraph1
Paragraph paragraph1 = new Paragraph("Lorem ipsum " +
"dolor sit amet, consectetur adipiscing elit, " +
"sed do eiusmod tempor incididunt ut labore " +
"et dolore magna aliqua.");
document.Add(paragraph1);
// Add image
//Image img = new Image(ImageDataFactory
// .Create(@"..\..\image.jpg"))
// .SetTextAlignment(TextAlignment.CENTER);
//document.Add(img);
// Table
Table table = new Table(2, false);
Cell cell11 = new Cell(1, 1)
.SetBackgroundColor(ColorConstants.GRAY)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("State"));
Cell cell12 = new Cell(1, 1)
.SetBackgroundColor(ColorConstants.GRAY)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("Capital"));
Cell cell21 = new Cell(1, 1)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("New York"));
Cell cell22 = new Cell(1, 1)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("Albany"));
Cell cell31 = new Cell(1, 1)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("New Jersey"));
Cell cell32 = new Cell(1, 1)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("Trenton"));
Cell cell41 = new Cell(1, 1)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("California"));
Cell cell42 = new Cell(1, 1)
.SetTextAlignment(TextAlignment.CENTER)
.Add(new Paragraph("Sacramento"));
table.AddCell(cell11);
table.AddCell(cell12);
table.AddCell(cell21);
table.AddCell(cell22);
table.AddCell(cell31);
table.AddCell(cell32);
table.AddCell(cell41);
table.AddCell(cell42);
document.Add(newline);
document.Add(table);
// Hyper link
Link link = new Link("click here",
PdfAction.CreateURI("https://www.google.com"));
Paragraph hyperLink = new Paragraph("Please ")
.Add(link.SetBold().SetUnderline()
.SetItalic().SetFontColor(ColorConstants.BLUE))
.Add(" to go www.google.com.");
document.Add(newline);
document.Add(hyperLink);
// Page numbers
int n = pdf.GetNumberOfPages();
for (int i = 1; i <= n; i++)
{
document.ShowTextAligned(new Paragraph(String
.Format("page" + i + " of " + n)),
559, 806, i, TextAlignment.RIGHT,
VerticalAlignment.TOP, 0);
}
// Close document
document.Close();
}
}
}

BIN
application-exit.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,69 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>DotNetKit.Wpf.AutoCompleteComboBox</name>
</assembly>
<members>
<member name="T:DotNetKit.Windows.Controls.AutoCompleteComboBox">
<summary>
AutoCompleteComboBox.xaml
</summary>
<summary>
AutoCompleteComboBox
</summary>
</member>
<member name="M:DotNetKit.Windows.Controls.AutoCompleteComboBox.TextFromItem(System.Object)">
<summary>
Gets text to match with the query from an item.
Never null.
</summary>
<param name="item"/>
</member>
<member name="M:DotNetKit.Windows.Controls.AutoCompleteComboBox.InitializeComponent">
<summary>
InitializeComponent
</summary>
</member>
<member name="T:DotNetKit.Windows.Controls.AutoCompleteComboBoxSetting">
<summary>
Represents an object to configure <see cref="T:DotNetKit.Windows.Controls.AutoCompleteComboBox"/>.
</summary>
</member>
<member name="M:DotNetKit.Windows.Controls.AutoCompleteComboBoxSetting.GetFilter(System.String,System.Func{System.Object,System.String})">
<summary>
Gets a filter function which determines whether items should be suggested or not
for the specified query.
Default: Gets the filter which maps an item to <c>true</c>
if its text contains the query (case insensitive).
</summary>
<param name="query">
The string input by user.
</param>
<param name="stringFromItem">
The function to get a string which identifies the specified item.
</param>
<returns></returns>
</member>
<member name="P:DotNetKit.Windows.Controls.AutoCompleteComboBoxSetting.MaxSuggestionCount">
<summary>
Gets an integer.
The combobox opens the drop down
if the number of suggested items is less than the value.
Note that the value is larger, it's heavier to open the drop down.
Default: 100.
</summary>
</member>
<member name="P:DotNetKit.Windows.Controls.AutoCompleteComboBoxSetting.Delay">
<summary>
Gets the duration to delay updating the suggestion list.
Returns <c>Zero</c> if no delay.
Default: 300ms.
</summary>
</member>
<member name="P:DotNetKit.Windows.Controls.AutoCompleteComboBoxSetting.Default">
<summary>
Gets the default setting.
</summary>
</member>
</members>
</doc>

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"additionalProbingPaths": [
"C:\\Users\\Vicente\\.dotnet\\store\\|arch|\\|tfm|",
"C:\\Users\\Vicente\\.nuget\\packages",
"C:\\Microsoft\\Xamarin\\NuGet"
]
}
}

View File

@@ -0,0 +1,9 @@
{
"runtimeOptions": {
"tfm": "netcoreapp3.1",
"framework": {
"name": "Microsoft.WindowsDesktop.App",
"version": "3.1.0"
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More