Skip to content
This repository has been archived by the owner on Sep 15, 2021. It is now read-only.

Commit

Permalink
[+] Ajustes para impressão do extrato.
Browse files Browse the repository at this point in the history
[*] Melhorias no demo.
  • Loading branch information
RFTD authored and RFTD committed Oct 9, 2016
1 parent ef1e5fa commit 66fd4ab
Show file tree
Hide file tree
Showing 12 changed files with 193 additions and 135 deletions.
14 changes: 8 additions & 6 deletions src/ACBr.Net.Sat.Demo/ACBr.Net.Sat.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\bin\COM Interop\</OutputPath>
Expand All @@ -36,11 +36,11 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="ACBr.Net.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3bb9130f8b775a6, processorArchitecture=MSIL">
<HintPath>..\packages\ACBr.Net.Core.1.0.1.3-beta7\lib\net40\ACBr.Net.Core.dll</HintPath>
<HintPath>..\packages\ACBr.Net.Core.1.0.1.3-rc1\lib\net40\ACBr.Net.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="ACBr.Net.DFe.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d3bb9130f8b775a6, processorArchitecture=MSIL">
<HintPath>..\packages\ACBr.Net.DFe.Core.1.0.1.3-beta4\lib\net40\ACBr.Net.DFe.Core.dll</HintPath>
<HintPath>..\packages\ACBr.Net.DFe.Core.1.0.1.5-rc1\lib\net40\ACBr.Net.DFe.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
Expand All @@ -54,6 +54,7 @@
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms.DataVisualization" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
Expand Down Expand Up @@ -87,6 +88,7 @@
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
Expand All @@ -98,15 +100,15 @@
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="sat.ico" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ACBr.Net.Sat\ACBr.Net.Sat.csproj">
<Project>{ee443d74-27e7-4236-851e-5e31a8ab8e63}</Project>
<Name>ACBr.Net.Sat</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Content Include="sat.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
46 changes: 39 additions & 7 deletions src/ACBr.Net.Sat.Demo/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using ACBr.Net.Core.Exceptions;
using System;
using System.Configuration;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using System.Xml;
Expand All @@ -10,14 +12,14 @@ public static class Extensions
{
public static void LoadXml(this WebBrowser browser, string xml)
{
if(xml == null)
if (xml == null)
return;

var path = Path.GetTempPath();
var fileName = Guid.NewGuid() + ".xml";
var fullFileName = Path.Combine(path, fileName);
var xmlDoc = new XmlDocument();
if(File.Exists(xml))
if (File.Exists(xml))
xmlDoc.Load(xml);
else
xmlDoc.LoadXml(xml);
Expand All @@ -27,17 +29,47 @@ public static void LoadXml(this WebBrowser browser, string xml)

public static void EnumDataSource<T>(this ComboBox cmb, T? valorPadrao = null) where T : struct
{
Guard.Against<ArgumentException>(!typeof(T).IsEnum, "O tipo precisar ser um Enum.");

cmb.DataSource = Enum.GetValues(typeof(T));
if(valorPadrao.HasValue)
if (valorPadrao.HasValue)
cmb.SelectedItem = valorPadrao.Value;
}

public static void AddValue(this KeyValueConfigurationCollection col, string key, string value)
public static void SetAppSetting(this Configuration config, string setting, object value)
{
if (col[key]?.Value != null)
col[key].Value = value;
Guard.Against<ArgumentNullException>(config == null, nameof(config));
Guard.Against<ArgumentNullException>(config.AppSettings == null, nameof(config.AppSettings));

var valor = string.Format(CultureInfo.InvariantCulture, "{0}", value);

if (config.AppSettings.Settings[setting]?.Value != null)
config.AppSettings.Settings[setting].Value = valor;
else
col.Add(key, value);
config.AppSettings.Settings.Add(setting, valor);
}

public static T GetAppSetting<T>(this Configuration config, string setting, T defaultValue)
{
Guard.Against<ArgumentNullException>(config == null, nameof(config));
Guard.Against<ArgumentNullException>(config.AppSettings == null, nameof(config.AppSettings));

var value = config.AppSettings.Settings[setting]?.Value;
if (value == null) return defaultValue;

try
{
if (typeof(T).IsEnum || (typeof(T).IsGenericType && typeof(T).GetGenericArguments()[0].IsEnum))
{
return (T)Enum.Parse(typeof(T), value);
}

return (T)Convert.ChangeType(value, typeof(T), CultureInfo.InvariantCulture);
}
catch (Exception)
{
return defaultValue;
}
}
}
}
36 changes: 18 additions & 18 deletions src/ACBr.Net.Sat.Demo/FrmMain.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 66fd4ab

Please sign in to comment.