implementado emailer #44
@@ -4,6 +4,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
VisualStudioVersion = 17.6.33829.357
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Controladora", "Controladora\Controladora.csproj", "{7168B549-F229-4D49-8C53-AF1CEB9BBB6B}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6C83A4AB-C70D-4D4E-A879-5E960C4A103A} = {6C83A4AB-C70D-4D4E-A879-5E960C4A103A}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entidades", "Entidades\Entidades.csproj", "{78A331E5-86D4-427E-AA45-5879F9E5E98B}"
|
||||
EndProject
|
||||
@@ -11,9 +14,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Modelo", "Modelo\Modelo.csp
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Vista", "Vista\Vista.csproj", "{8C9E8090-5D8F-42AE-9813-C68D384C6863}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{6C83A4AB-C70D-4D4E-A879-5E960C4A103A} = {6C83A4AB-C70D-4D4E-A879-5E960C4A103A}
|
||||
{7168B549-F229-4D49-8C53-AF1CEB9BBB6B} = {7168B549-F229-4D49-8C53-AF1CEB9BBB6B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Informes", "Informes\Informes.csproj", "{6C83A4AB-C70D-4D4E-A879-5E960C4A103A}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{78A331E5-86D4-427E-AA45-5879F9E5E98B} = {78A331E5-86D4-427E-AA45-5879F9E5E98B}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -36,6 +45,10 @@ Global
|
||||
{8C9E8090-5D8F-42AE-9813-C68D384C6863}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8C9E8090-5D8F-42AE-9813-C68D384C6863}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8C9E8090-5D8F-42AE-9813-C68D384C6863}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6C83A4AB-C70D-4D4E-A879-5E960C4A103A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
10
Informes/ConfigEmail.cs
Normal file
10
Informes/ConfigEmail.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Informes
|
||||
{
|
||||
public class ConfigEmail
|
||||
{
|
||||
public string EmailAddr { get; set; }
|
||||
public string EmailPass { get; set; }
|
||||
public List<string> EmailTarget { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
133
Informes/InformeEmail.cs
Normal file
133
Informes/InformeEmail.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net.Mail;
|
||||
using System.Net;
|
||||
using System.Text.Json;
|
||||
|
||||
using Entidades;
|
||||
namespace Informes
|
||||
{
|
||||
public class InformeEmail
|
||||
{
|
||||
/// <summary>
|
||||
/// Envia Informes por Email
|
||||
/// </summary>
|
||||
|
||||
private static InformeEmail instance = new();
|
||||
public static InformeEmail Instance
|
||||
{
|
||||
get { return instance; }
|
||||
}
|
||||
|
||||
public string EnviarEmailFactura(string titulo, List<DetalleFactura> desc)
|
||||
{
|
||||
string? ret = null;
|
||||
string json;
|
||||
ConfigEmail config;
|
||||
try
|
||||
{ // leemos el archivo de configuracion para obtener los certificados y mails destino de los informes
|
||||
json = File.ReadAllText("settings.json");
|
||||
config = JsonSerializer.Deserialize<ConfigEmail>(json);
|
||||
|
||||
}
|
||||
catch (IOException)
|
||||
{
|
||||
ret = "No se pudo leer el archivo \"settings.json\"";
|
||||
throw;
|
||||
}
|
||||
|
||||
foreach (var i in config.EmailTarget)
|
||||
{
|
||||
if (String.IsNullOrWhiteSpace(i)) return "Hay Emails mal cargados";
|
||||
|
||||
}
|
||||
|
||||
SmtpClient smtp = new SmtpClient();
|
||||
smtp.Host = "smtp.gmail.com";
|
||||
smtp.Port = 587;
|
||||
smtp.Credentials = new NetworkCredential(config.EmailAddr, config.EmailPass);
|
||||
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
|
||||
smtp.EnableSsl = true;
|
||||
|
||||
MailMessage mail = new MailMessage();
|
||||
mail.Subject = titulo;
|
||||
mail.IsBodyHtml = true;
|
||||
mail.Body = GenerarTabla(desc);
|
||||
mail.Sender = new MailAddress(config.EmailAddr);
|
||||
foreach (var i in config.EmailTarget) mail.To.Add(i);
|
||||
mail.From = new MailAddress(config.EmailAddr);
|
||||
|
||||
try
|
||||
{
|
||||
#if DEBUG
|
||||
Console.WriteLine($"From: {config.EmailAddr}, Title: {titulo}");
|
||||
#endif
|
||||
smtp.Send(mail);
|
||||
mail.Dispose();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ret = "No se pudo comunicar con el server SMTP";
|
||||
throw;
|
||||
}
|
||||
|
||||
//Decimos que se envio el email correctamente si el valor del retorno sigue siendo nulo en otro caso tendra la descripcion del error.
|
||||
return (ret == null) ?
|
||||
"Se envio el Email Correctamente":
|
||||
ret;
|
||||
//
|
||||
}
|
||||
|
||||
private string GenerarTabla(List<DetalleFactura> desc)
|
||||
{
|
||||
// Esta seccion es el armado del mail html
|
||||
string body =
|
||||
@"
|
||||
<style>
|
||||
table, td, th {
|
||||
border: 1px solid black;
|
||||
}
|
||||
</style>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Producto</td>
|
||||
<th>Cantidad</td>
|
||||
<th>Precio CU</td>
|
||||
<th>Subtotal</td>
|
||||
</tr>";
|
||||
|
||||
foreach (var i in desc)
|
||||
{
|
||||
body +=
|
||||
@$"
|
||||
<tr>
|
||||
<td>{i.Producto.Nombre}</td>
|
||||
<td>{i.Cantidad}</td>
|
||||
<td>{i.Producto.Precio}</td>
|
||||
<td>{i.Producto.Precio * i.Cantidad}</td>
|
||||
</tr>";
|
||||
}
|
||||
|
||||
body +=
|
||||
@$"
|
||||
<tr>
|
||||
<td>Total</td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td>{CalcularTotal(desc)}</td>
|
||||
</tr>
|
||||
</table>
|
||||
";
|
||||
return body;
|
||||
}
|
||||
private double CalcularTotal(List<DetalleFactura> desc)
|
||||
{
|
||||
double total = 0;
|
||||
foreach (var i in desc)
|
||||
{
|
||||
total += i.Producto.Precio * i.Cantidad;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
13
Informes/Informes.csproj
Normal file
13
Informes/Informes.csproj
Normal file
@@ -0,0 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Entidades\Entidades.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
BIN
Informes/bin/Debug/net6.0/Entidades.dll
Normal file
BIN
Informes/bin/Debug/net6.0/Entidades.dll
Normal file
Binary file not shown.
BIN
Informes/bin/Debug/net6.0/Entidades.pdb
Normal file
BIN
Informes/bin/Debug/net6.0/Entidades.pdb
Normal file
Binary file not shown.
36
Informes/bin/Debug/net6.0/Informes.deps.json
Normal file
36
Informes/bin/Debug/net6.0/Informes.deps.json
Normal file
@@ -0,0 +1,36 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v6.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v6.0": {
|
||||
"Informes/1.0.0": {
|
||||
"dependencies": {
|
||||
"Entidades": "1.0.0"
|
||||
},
|
||||
"runtime": {
|
||||
"Informes.dll": {}
|
||||
}
|
||||
},
|
||||
"Entidades/1.0.0": {
|
||||
"runtime": {
|
||||
"Entidades.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"Informes/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Entidades/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Informes/bin/Debug/net6.0/Informes.dll
Normal file
BIN
Informes/bin/Debug/net6.0/Informes.dll
Normal file
Binary file not shown.
BIN
Informes/bin/Debug/net6.0/Informes.pdb
Normal file
BIN
Informes/bin/Debug/net6.0/Informes.pdb
Normal file
Binary file not shown.
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
|
||||
23
Informes/obj/Debug/net6.0/Informes.AssemblyInfo.cs
Normal file
23
Informes/obj/Debug/net6.0/Informes.AssemblyInfo.cs
Normal file
@@ -0,0 +1,23 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("Informes")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("Informes")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("Informes")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
55f9793ce92bee586e65f5b38a3a7676261de34c
|
||||
@@ -0,0 +1,11 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net6.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = Informes
|
||||
build_property.ProjectDir = C:\Users\fedpo\Downloads\final actual\final actual\Informes\
|
||||
8
Informes/obj/Debug/net6.0/Informes.GlobalUsings.g.cs
Normal file
8
Informes/obj/Debug/net6.0/Informes.GlobalUsings.g.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.IO;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Net.Http;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
BIN
Informes/obj/Debug/net6.0/Informes.assets.cache
Normal file
BIN
Informes/obj/Debug/net6.0/Informes.assets.cache
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
||||
59ca0345c28b4ca3e61ae3f6ff36103ebf42ff8f
|
||||
@@ -0,0 +1,15 @@
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\bin\Debug\net6.0\Informes.deps.json
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\bin\Debug\net6.0\Informes.dll
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\bin\Debug\net6.0\Informes.pdb
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\bin\Debug\net6.0\Entidades.dll
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\bin\Debug\net6.0\Entidades.pdb
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.csproj.AssemblyReference.cache
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.GeneratedMSBuildEditorConfig.editorconfig
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.AssemblyInfoInputs.cache
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.AssemblyInfo.cs
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.csproj.CoreCompileInputs.cache
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.csproj.CopyComplete
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.dll
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\refint\Informes.dll
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\Informes.pdb
|
||||
C:\Users\fedpo\Downloads\final actual\final actual\Informes\obj\Debug\net6.0\ref\Informes.dll
|
||||
BIN
Informes/obj/Debug/net6.0/Informes.dll
Normal file
BIN
Informes/obj/Debug/net6.0/Informes.dll
Normal file
Binary file not shown.
BIN
Informes/obj/Debug/net6.0/Informes.pdb
Normal file
BIN
Informes/obj/Debug/net6.0/Informes.pdb
Normal file
Binary file not shown.
BIN
Informes/obj/Debug/net6.0/ref/Informes.dll
Normal file
BIN
Informes/obj/Debug/net6.0/ref/Informes.dll
Normal file
Binary file not shown.
BIN
Informes/obj/Debug/net6.0/refint/Informes.dll
Normal file
BIN
Informes/obj/Debug/net6.0/refint/Informes.dll
Normal file
Binary file not shown.
126
Vista/FrmInforme.Designer.cs
generated
126
Vista/FrmInforme.Designer.cs
generated
@@ -28,19 +28,145 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
label1 = new Label();
|
||||
label2 = new Label();
|
||||
label3 = new Label();
|
||||
dgvEmailTarget = new DataGridView();
|
||||
txtEmailAddr = new TextBox();
|
||||
txtEmailPass = new TextBox();
|
||||
txtEmailTargetAdd = new TextBox();
|
||||
btnAñadir = new Button();
|
||||
btnGuardar = new Button();
|
||||
btnEliminar = new Button();
|
||||
((System.ComponentModel.ISupportInitialize)dgvEmailTarget).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(12, 22);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(65, 15);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "Email Addr";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(12, 48);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(62, 15);
|
||||
label2.TabIndex = 1;
|
||||
label2.Text = "Email Pass";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(12, 76);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(71, 15);
|
||||
label3.TabIndex = 2;
|
||||
label3.Text = "Email Target";
|
||||
//
|
||||
// dgvEmailTarget
|
||||
//
|
||||
dgvEmailTarget.AllowUserToAddRows = false;
|
||||
dgvEmailTarget.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dgvEmailTarget.EditMode = DataGridViewEditMode.EditProgrammatically;
|
||||
dgvEmailTarget.EnableHeadersVisualStyles = false;
|
||||
dgvEmailTarget.Location = new Point(89, 76);
|
||||
dgvEmailTarget.Name = "dgvEmailTarget";
|
||||
dgvEmailTarget.RowTemplate.Height = 25;
|
||||
dgvEmailTarget.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
|
||||
dgvEmailTarget.Size = new Size(240, 150);
|
||||
dgvEmailTarget.TabIndex = 3;
|
||||
//
|
||||
// txtEmailAddr
|
||||
//
|
||||
txtEmailAddr.Location = new Point(89, 18);
|
||||
txtEmailAddr.Name = "txtEmailAddr";
|
||||
txtEmailAddr.Size = new Size(202, 23);
|
||||
txtEmailAddr.TabIndex = 4;
|
||||
//
|
||||
// txtEmailPass
|
||||
//
|
||||
txtEmailPass.Location = new Point(89, 47);
|
||||
txtEmailPass.Name = "txtEmailPass";
|
||||
txtEmailPass.PasswordChar = '*';
|
||||
txtEmailPass.Size = new Size(202, 23);
|
||||
txtEmailPass.TabIndex = 5;
|
||||
//
|
||||
// txtEmailTargetAdd
|
||||
//
|
||||
txtEmailTargetAdd.Location = new Point(335, 76);
|
||||
txtEmailTargetAdd.Name = "txtEmailTargetAdd";
|
||||
txtEmailTargetAdd.Size = new Size(197, 23);
|
||||
txtEmailTargetAdd.TabIndex = 6;
|
||||
//
|
||||
// btnAñadir
|
||||
//
|
||||
btnAñadir.Location = new Point(335, 105);
|
||||
btnAñadir.Name = "btnAñadir";
|
||||
btnAñadir.Size = new Size(75, 23);
|
||||
btnAñadir.TabIndex = 7;
|
||||
btnAñadir.Text = "Añadir";
|
||||
btnAñadir.UseVisualStyleBackColor = true;
|
||||
btnAñadir.Click += btnAñadir_Click;
|
||||
//
|
||||
// btnGuardar
|
||||
//
|
||||
btnGuardar.Location = new Point(89, 232);
|
||||
btnGuardar.Name = "btnGuardar";
|
||||
btnGuardar.Size = new Size(75, 23);
|
||||
btnGuardar.TabIndex = 8;
|
||||
btnGuardar.Text = "Guardar";
|
||||
btnGuardar.UseVisualStyleBackColor = true;
|
||||
btnGuardar.Click += btnGuardar_Click;
|
||||
//
|
||||
// btnEliminar
|
||||
//
|
||||
btnEliminar.Location = new Point(335, 134);
|
||||
btnEliminar.Name = "btnEliminar";
|
||||
btnEliminar.Size = new Size(75, 23);
|
||||
btnEliminar.TabIndex = 9;
|
||||
btnEliminar.Text = "Eliminar";
|
||||
btnEliminar.UseVisualStyleBackColor = true;
|
||||
btnEliminar.Click += btnEliminar_Click;
|
||||
//
|
||||
// FrmInforme
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(800, 450);
|
||||
Controls.Add(btnEliminar);
|
||||
Controls.Add(btnGuardar);
|
||||
Controls.Add(btnAñadir);
|
||||
Controls.Add(txtEmailTargetAdd);
|
||||
Controls.Add(txtEmailPass);
|
||||
Controls.Add(txtEmailAddr);
|
||||
Controls.Add(dgvEmailTarget);
|
||||
Controls.Add(label3);
|
||||
Controls.Add(label2);
|
||||
Controls.Add(label1);
|
||||
Name = "FrmInforme";
|
||||
Text = "Informes";
|
||||
WindowState = FormWindowState.Maximized;
|
||||
((System.ComponentModel.ISupportInitialize)dgvEmailTarget).EndInit();
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label label1;
|
||||
private Label label2;
|
||||
private Label label3;
|
||||
private DataGridView dgvEmailTarget;
|
||||
private TextBox txtEmailAddr;
|
||||
private TextBox txtEmailPass;
|
||||
private TextBox txtEmailTargetAdd;
|
||||
private Button btnAñadir;
|
||||
private Button btnGuardar;
|
||||
private Button btnEliminar;
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
using System;
|
||||
using Informes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
@@ -12,9 +14,90 @@ namespace Vista
|
||||
{
|
||||
public partial class FrmInforme : Form
|
||||
{
|
||||
const string configpath = "settings.json";
|
||||
public FrmInforme()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
if (!File.Exists(configpath))
|
||||
{
|
||||
string json = JsonSerializer.Serialize(new ConfigEmail { EmailAddr = "", EmailPass = "", EmailTarget = new List<String>() }, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configpath, json);
|
||||
}
|
||||
|
||||
string jsonString = File.ReadAllText(configpath);
|
||||
ConfigEmail config = JsonSerializer.Deserialize<ConfigEmail>(jsonString);
|
||||
CargaDatos(config);
|
||||
}
|
||||
|
||||
private void CargaDatos(ConfigEmail ce)
|
||||
{
|
||||
txtEmailAddr.Text = ce.EmailAddr;
|
||||
txtEmailPass.Text = ce.EmailPass;
|
||||
|
||||
dgvEmailTarget.DataSource = null;
|
||||
dgvEmailTarget.Columns.Add("EmailTarget", "EmailTarget");
|
||||
|
||||
// Agregar los datos al DataGridView
|
||||
foreach (var str in ce.EmailTarget)
|
||||
{
|
||||
dgvEmailTarget.Rows.Add(str);
|
||||
}
|
||||
}
|
||||
private void btnGuardar_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string> emailTarget = new List<string>();
|
||||
|
||||
foreach (DataGridViewRow row in dgvEmailTarget.Rows)
|
||||
{
|
||||
if (row.Cells["EmailTarget"].Value != null)
|
||||
{
|
||||
emailTarget.Add(row.Cells["EmailTarget"].Value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
ConfigEmail config = new ConfigEmail
|
||||
{
|
||||
EmailAddr = txtEmailAddr.Text,
|
||||
EmailPass = txtEmailPass.Text,
|
||||
EmailTarget = emailTarget
|
||||
};
|
||||
|
||||
string json = JsonSerializer.Serialize(config, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(configpath, json);
|
||||
}
|
||||
|
||||
private void btnAñadir_Click(object sender, EventArgs e)
|
||||
{
|
||||
List<string> emailTarget = new List<string>();
|
||||
emailTarget.Add(txtEmailTargetAdd.Text);
|
||||
foreach (DataGridViewRow row in dgvEmailTarget.Rows)
|
||||
{
|
||||
if (row.Cells["EmailTarget"].Value != null)
|
||||
{
|
||||
emailTarget.Add(row.Cells["EmailTarget"].Value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
// Agregar los datos al DataGridView
|
||||
dgvEmailTarget.Rows.Add(txtEmailTargetAdd.Text);
|
||||
}
|
||||
|
||||
private void btnEliminar_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (dgvEmailTarget.SelectedRows.Count > 0)
|
||||
{
|
||||
// Elimina la fila seleccionada
|
||||
dgvEmailTarget.Rows.RemoveAt(dgvEmailTarget.SelectedRows[0].Index);
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("Por favor, selecciona una fila para eliminar EmailTarget.");
|
||||
}
|
||||
}
|
||||
catch (Exception) { throw; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing"">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Controladora\Controladora.csproj" />
|
||||
<ProjectReference Include="..\Entidades\Entidades.csproj" />
|
||||
<ProjectReference Include="..\Informes\Informes.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -123,6 +123,66 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj",
|
||||
"projectName": "Informes",
|
||||
"projectPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj",
|
||||
"packagesPath": "C:\\Users\\fedpo\\.nuget\\packages\\",
|
||||
"outputPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\obj\\",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
"C:\\Users\\fedpo\\AppData\\Roaming\\NuGet\\NuGet.Config",
|
||||
"C:\\Program Files (x86)\\NuGet\\Config\\Microsoft.VisualStudio.Offline.config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net6.0"
|
||||
],
|
||||
"sources": {
|
||||
"C:\\Program Files (x86)\\Microsoft SDKs\\NuGetPackages\\": {},
|
||||
"https://api.nuget.org/v3/index.json": {},
|
||||
"https://fedesrv.ddns.net/git/api/packages/fede/nuget/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net6.0": {
|
||||
"targetAlias": "net6.0",
|
||||
"projectReferences": {
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Entidades\\Entidades.csproj": {
|
||||
"projectPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Entidades\\Entidades.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
}
|
||||
},
|
||||
"frameworks": {
|
||||
"net6.0": {
|
||||
"targetAlias": "net6.0",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "C:\\Program Files\\dotnet\\sdk\\7.0.306\\RuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
},
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Modelo\\Modelo.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
@@ -213,6 +273,9 @@
|
||||
},
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Entidades\\Entidades.csproj": {
|
||||
"projectPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Entidades\\Entidades.csproj"
|
||||
},
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj": {
|
||||
"projectPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,19 @@
|
||||
"bin/placeholder/Entidades.dll": {}
|
||||
}
|
||||
},
|
||||
"Informes/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETCoreApp,Version=v6.0",
|
||||
"dependencies": {
|
||||
"Entidades": "1.0.0"
|
||||
},
|
||||
"compile": {
|
||||
"bin/placeholder/Informes.dll": {}
|
||||
},
|
||||
"runtime": {
|
||||
"bin/placeholder/Informes.dll": {}
|
||||
}
|
||||
},
|
||||
"Modelo/1.0.0": {
|
||||
"type": "project",
|
||||
"framework": ".NETCoreApp,Version=v6.0",
|
||||
@@ -52,6 +65,11 @@
|
||||
"path": "../Entidades/Entidades.csproj",
|
||||
"msbuildProject": "../Entidades/Entidades.csproj"
|
||||
},
|
||||
"Informes/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../Informes/Informes.csproj",
|
||||
"msbuildProject": "../Informes/Informes.csproj"
|
||||
},
|
||||
"Modelo/1.0.0": {
|
||||
"type": "project",
|
||||
"path": "../Modelo/Modelo.csproj",
|
||||
@@ -61,7 +79,8 @@
|
||||
"projectFileDependencyGroups": {
|
||||
"net6.0-windows7.0": [
|
||||
"Controladora >= 1.0.0",
|
||||
"Entidades >= 1.0.0"
|
||||
"Entidades >= 1.0.0",
|
||||
"Informes >= 1.0.0"
|
||||
]
|
||||
},
|
||||
"packageFolders": {
|
||||
@@ -97,6 +116,9 @@
|
||||
},
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Entidades\\Entidades.csproj": {
|
||||
"projectPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Entidades\\Entidades.csproj"
|
||||
},
|
||||
"C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj": {
|
||||
"projectPath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Informes\\Informes.csproj"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "WPBgDz5Ag7uyUpIln8eBMvu2+XqGSiWG0TNaL6A9IRZAEDYpI2SXVE367iYE3zDP7SrxjO4nhM2wKkdjx8Psbw==",
|
||||
"dgSpecHash": "HaKkXKrDu+gimYBODDKQ5E1ZL1m4YoG9CrkcmpZyBjOtEmifQPEVkmmKOyOtFgPNaLHFACDybW6TDfmls/Ua8g==",
|
||||
"success": true,
|
||||
"projectFilePath": "C:\\Users\\fedpo\\Downloads\\final actual\\final actual\\Vista\\Vista.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
|
||||
Reference in New Issue
Block a user