Documentos de Académico
Documentos de Profesional
Documentos de Cultura
`
1
ÍNDICE
RESUMEN:...................................................................................................................................................... 3
INFORMACIÓN DE LA EMPRESA.................................................................................................6
FUNDAMENTACIÓN.............................................................................................................................17
OBJETIVOS ................................................................................................................................................ 19
ANÁLISIS DE REQUERIMIENTOS ................................................................................................ 21
ESTUDIO DE FACTIBILIDAD........................................................................................................... 31
MATRIZ FODA ........................................................................................................................................ 46
DIAGRAMA DE GANTT ................................................................................................................... 48
DIAGRAMA DE CASOS DE USO ............................................................................................... 51
MODELO ENTIDAD RELACIÓN ................................................................................................. 53
MODELO RELACIONAL ................................................................................................................... 55
CONSULTAS SQL ................................................................................................................................. 57
DIGRAMA DE FLUJO DE DATOS (DFD) ............................................................................ 65
DIAGRAMA DE CLASES UML ...................................................................................................... 72
IDENTIFICACIÓN DE CONJUNTOS Y FUNCIONES ...................................................76
DISEÑO DE PANTALLAS ..................................................................................................................79
CÓDIGO FUENTE ................................................................................................................................ 86
MANUAL DE USUARIO ...................................................................................................................188
RED DE LA EMPRESA ..................................................................................................................... 206
CONCLUSIÓN ........................................................................................................................................211
BIBLIOGRAFÍA ....................................................................................................................................... 213
ANEXO ........................................................................................................................................................ 215
2
RESUMEN:
3
Going back to before, we focused on the details that the client requested
and we were able to solve various conflicts and problems that arose, we
used interviews to understand better those needs raised by the client. This
is how we have improved the performance of our program so that it
performs at its best.
Expected and 100% satisfactory results were presented to us, the program
fulfills its function and solves the problems raised up to now 100%. We also
consider future problems that may arise, and we tried to solve 80%
compared to the beginning of the project, it is estimated that by the end of
it 90% or higher can be achieved.
INFORMACIÓN DE
LA EMPRESA
6
DESCRIPCIÓN Y PRESENTACIÓN:
LOGO:
DESCRIPCIÓN:
FORMA JURÍDICA:
Dadas las circunstancias, los socios consideran formar una SRL la opción
más viable. Dado que esta conlleva ventajas como: una cifra de capital
necesario más pequeña y una complejidad de funcionamiento menor a
otros tipos de empresas. En adición, permite elegir una forma de
7
MISIÓN DE LA EMPRESA:
VISIÓN DE LA EMPRESA:
OBJETIVOS:
BPS:
DGI:
MTSS:
MEF:
TRÁMITES:
(Ver en Anexo)
DESCRIPCIÓN COSTO
Antel $3.000
UTE $4.500
OSE $1.500
Alquiler $18.000
Sueldos $53.120
Mantenimiento $4.000
TOTAL $90.825
Horas/mes = 64h
0.00125 = 1.341
ESTIMACION DE COSTOS
14
MEZCLA COMERCIAL:
FUNDAMENTACIÓN
17
OBJETIVOS
19
OBJETIVO GENERAL:
OBJETIVOS ESPECÍFICOS:
ANÁLISIS DE
REQUERIMIENTOS
21
PROPÓSITO:
Se pretende que el software sea de uso intuitivo, de tal manera que los
usuarios no encuentren mayores obstáculos en el manejo del mismo y
logren adquirir de manera rápida el conocimiento necesario para su
correcta ejecución.
REFERENCIAS
EDUSALTO
YOUTUBE
23
Fue creado para emprendedores que procuran llevar a cabo una gestión
global de su empresa de forma digital y no cumplan con los
requerimientos de un usuario avanzado.
ENTORNO OPERATIVO
REQUERIMIENTOS FUNCIONALES
Registro/Ingreso de usuario
Versión: 1.1
Gestionar inventario
Versión: 1.2
Gestionar ventas
Versión: 1.3
Gestionar gastos
Versión: 1.4.
Emisión de informes
Versión: 1.5.
Reglas de negocio
Interfaces de usuario
Interfaces de hardware
Interfaces de software
Interfaces de comunicación
REQUERIMIENTOS NO FUNCIONALES
OTROS REQUERIMIENTOS
ESTUDIO DE
FACTIBILIDAD
31
FACTIBILIDAD OPERATIVA:
RECURSOS HUMANOS:
Desarrolladores:
● Luciano Beraza
● Bruno Guglielmone
● Santiago Esquerré
● Facundo Manitto
● Gerónimo Ramos
Clientes:
● Andrés Argain
● Agustina Legnazzi
32
FACTIBILIDAD TÉCNICA:
Servidor FTP:
● Rack de pared pivotante de 12U OpenSky
● Patchera De 24 Puertos Cat6e NRG+
● Organizador de Cables NEXXT de 1U
● Switch TP-LINK TL-SG1024D
● Router TP-Link TL-R480T+
● Servidor Dell PowerEdge R420 8x 1U
o Procesador: 2x Xeon E5-2403 1.80 GHz
o Memoria RAM: 32GB (4x8GB) DDR3
o Controlador de Almacenamiento: Dell PERC H310 6Gbps
SAS/SATA Mini Mono RAID
o Almacenamiento: 2x 1TB 2.5” 7200rpm 6Gbps SATA
● Monitor: Acer V6 V226HQL led 21.5"
● Kit de teclado y mouse inalámbrico Logitech MK345
● PDU Rackeable 1U ProLink PL006
34
PC3 x3 https://pcpartpicker.com/list/7mRyV
w
PC5 https://pcpartpicker.com/list/QDTqhk
Monitor x7 https://www.mercadolibre.com.uy/m
onitor-acer-v6-v226hql-led-215-
negro-
100v240v/p/MLU7568845?pdp_filters
=category:MLU1648#searchVariation
=MLU7568845&position=1&search_la
yout=stack&type=product&tracking_
id=75419791-ceb4-4a9a-a508-
cd610a70899c
Rack https://tienda.opensky.com.uy/Rack-
de-pared-pivotante-de-12U-
600x600-p467472557
Patchera 24 https://articulo.mercadolibre.com.uy/
puertos MLU-611398443-patchera-de-24-
puertos-cat6e-montable-racks-
organiza-cables-
_JM#position=1&search_layout=stac
k&type=item&tracking_id=bf65c5b3-
0ffd-4869-8eb6-7e36fe44d57c
Switch https://articulo.mercadolibre.com.uy/
(Rackeable) MLU-463259656-switch-tp-link-tl-
24 puertos sg1024d-24-puertos-gigabit-
rackeable-
36
_JM#position=18&search_layout=sta
SOFTWARE DE ADMNISTRACIÓN PARA “LA MILAGROSA” MILANESERÍA | INGENIEROS SOFTWARE
Escuela Superior Catalina Harriague de Castaños | 3ro EMT Informática
ck&type=item&tracking_id=9bc0321f
-3df3-4a75-8119-033796d8dcfd
Router https://www.mercadolibre.com.uy/ro
uter-tp-link-tl-r480t-negro-
100v240v/p/MLU7868093#searchVari
ation=MLU7868093&position=1&searc
h_layout=stack&type=product&track
ing_id=b6011f8d-306f-49de-9fd5-
e58a782b62ba
Servidor https://www.theserverstore.com/dell-
poweredge-r420-8x-1u-sff-
server.html
Licencia https://www.microsoft.com/es-
Windows 10 es/d/windows-10-
Pro pro/df77x4d43rkt?activetab=pivot:inf
ormacióngeneraltab
Licencia https://www.office.com
Office 365
37
Impresora https://www.mercadolibre.com.uy/im
Epson presora-a-color-multifuncion-
Expression epson-expression-xp-2101-con-wifi-
XP-21-01 negra-100v240v/p/MLU17748647?m
Licencia https://www.ganttproject.biz
GantProject
Organizador https://articulo.mercadolibre.com.uy/
de Cables MLU-603442864-organizador-de-
cables-horizontal-plastico-prack-1u-
19-_JM?m
Rosetas https://articulo.mercadolibre.com.uy/
Modelo MLU-609995499-caja-doble-de-red-
Doble x6 roseta-para-rj-45-_JM?matt_t
38
Cámara x4 https://articulo.mercadolibre.com.uy/
MLU-465420666-camara-exterior-
wifi-ip-full-hd-color-dia-y-noche-
_JM#position=19&search_layout=sta
ck&type=item&tracking_id=ba64919
d-1adb-4beb-877f-fd8dfa1973b5
Laptop x5 https://articulo.mercadolibre.com.uy/
MLU-600021076-notebook-hp-
gaming-pavilion-ryzen-5-8gb-
256gb-156-1050-3gb-
_JM?searchVariation=173545027681#
searchVariation=173545027681&positi
on=3&search_layout=stack&type=ite
m&tracking_id=d4a4265b-1bf2-
48dd-9846-36f91dd8dec5
Celular https://www.mercadolibre.com.uy/ip
Iphone 8 hone-8-64-gb-gris-
espacial/p/MLU8752432?pdp_filters=
category:MLU1055#searchVariation=
MLU8752432&position=1&search_layo
ut=stack&type=product&tracking_id
=bb1b7c86-3f17-4efc-87b9-
13fc17c09407
39
Celular https://www.mercadolibre.com.uy/ap
Iphone XR ple-iphone-xr-128-gb-
blanco/p/MLU12866684?product_trig
ger_id=MLU12866686&pdp_filters=ca
tegory%3AMLU1055&applied_product
_filters=MLU12866686&quantity=1
Celular https://www.mercadolibre.com.uy/xia
Xiaomi omi-redmi-note-10-pro-global-dual-
Redmi Note sim-128-gb-bronce-gradiente-6-gb-
10 ram/p/MLU17953706?pdp_filters=cat
egory:MLU1055#searchVariation=MLU
17953706&position=1&search_layout=
stack&type=product&tracking_id=59
dae77e-c92f-4174-b2d6-
7b6d2a8e92d4
Samsung https://servicom.com.uy/tienda/celul
A20S ares/samsung-galaxy-a20s-32gb/
FACTIBILIDAD ECONÓMICA
DESCRIPCIÓN COSTO
PC1 $45.513
Impresora $5.200
PC2 $45.513
PC3 $37.140
PC4 $37.140
PC5 $25.472
Monitor x7 $50.225
Rack $9.718
Router $2.752
42
Switch $5.074
Laptop x5 $178.500
Cámara IP x4 $12.600
TOTAL $608.334
43
DESCRIPCIÓN COSTO
Antel $3.000
UTE $4.500
OSE $1.500
Alquiler $18.000
TOTAL $27.000
44
FACTIBILIDAD LEGAL
Las contraseñas de todos los usuarios son encriptadas para cumplir con el
artículo 1 de la ley 18.331. Se utilizará el algoritmo de encriptación “sha2”
para que la seguridad proporcionada sea mayor y eficaz en caso de que
un acceso no autorizado intente ingresar. Se manejará el artículo 5 para
que la base de datos sea adecuada a la misma.
MATRIZ FODA
46
Estrategias:
DIAGRAMA DE
GANTT
48
DIAGRAMA DE
CASOS DE USO
51
MODELO ENTIDAD
RELACIÓN
53
MODELO
RELACIONAL
55
PASAJE A TABLAS:
CONSULTAS SQL
57
--HACE EL LOGIN
SELECT Username, Contraseña FROM usuario WHERE BINARY Username = @Username AND
AES_DECRYPT(Contraseña, @key) = @Passwd ;
mysql –u root –p
Debemos crear una nueva base de datos con el mismo nombre, para posibilitar
la acción de importarla.
en el directorio actual.
62
sencilla.
63
DIGRAMA DE
FLUJO DE DATOS
(DFD)
65
DIAGRAMA DE
CLASES UML
72
IDENTIFICACIÓN
DE CONJUNTOS Y
FUNCIONES
76
Función
Ventas Tipo
Venta
1
En
local
Venta
2
Venta Envío
Función
Tipo de documento
Venta probatorio
s
Venta 1
Venta 2 E-Factura
Contado
Venta 3
E-Factura
Venta 4 Crédito
E-Ticket
Venta 5 Contado
E-Ticket
Venta 6
Crédito
77
Conjunto
Venta Producto
s s
Venta 1
Producto 1
Ventas 2 Producto 2
Ventas 3 Producto 3
Ventas 4 Producto 4
Conjunto
Materia prima Producto
Pollo
Milanesa de pollo
Pan rallado
Milanesa de carne
Jamon y queso
Condimentos Milanesa
de
jamon y
Carne
queso
78
DISEÑO DE
PANTALLAS
79
CÓDIGO FUENTE
86
CONEXIONSQL.CS
using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;
using MySql.Data;
using Ingenieros_Commerce_Manager_v2._0.Entities;
using Google.Protobuf.WellKnownTypes;
using System.Windows.Documents;
using System.IO;
using System.Windows;
namespace Ingenieros_Commerce_Manager_v2._0
{
public class conexionsql
{
#region MySQLResources
private readonly MySqlConnection conexion = new
MySqlConnection("Server=localhost; Database=proyecto; Uid=usuario;
Pwd=user;");
private MySqlCommand comandos = new MySqlCommand();
public MySqlDataReader datos;
protected MySqlDataAdapter adapter;
#endregion
#region DataTables
DataTable DTProd = new DataTable();
DataTable DTMatPrim = new DataTable();
DataTable UserData = new DataTable();
DataTable DTClientes = new DataTable();
DataTable DTGastos = new DataTable();
DataTable DTVentas = new DataTable();
DataTable InfoVentas = new DataTable();
#endregion
#region Ventas
public void RestarStock(int id, string cantidad)
{
AbrirConexion();
comandos.CommandText = "update `producto_venta` set Stock = Stock
- '"+cantidad+"' where `ID.Prod` = '"+id+"' ;";
comandos.ExecuteNonQuery();
87
}
public DataTable GetVentas()
{
CerrarReader();
AbrirConexion();
comandos.CommandText = @"SELECT `IdVenta`, `ID.CLI`, `Nombre`
Cliente, TipoDocumento, CAST(DATE_FORMAT(Fecha, '%e/%c/%Y') as char) Fecha,
Importe, IF(`Envio`=1, 'A domicilio', 'Venta en local') Envio
FROM `venta` left join `cliente` on
`venta`.`IDCliente` = `cliente`.`ID.CLI`
WHERE `venta`.`IDUsuario` =
'"+Usuario.Id+@"' ORDER BY IdVenta DESC;
";
EjecutarReader();
DTVentas.Rows.Clear();
DTVentas.Load(datos);
return DTVentas;
}
public DataTable GetInfoVentas(int idventa)
{
CerrarReader();
AbrirConexion();
comandos.CommandText = "SELECT `Descripcion` Producto,
`PrecioVenta` Precio, `Cantidad`, `SubTotal` FROM `detalleventa`,
`producto_venta` WHERE `detalleventa`.`IdProd` = `producto_venta`.`ID.Prod`
AND IdVenta = '"+idventa+"';";
EjecutarReader();
InfoVentas.Rows.Clear();
InfoVentas.Load(datos);
return InfoVentas;
}
public int RegistrarVenta(string TipoDocumento, string Fecha, float
Importe, bool Envio, float Cambio, DataTable detalle)
{
AbrirConexion();
CerrarReader();
try
{
comandos.Parameters.Clear();
comandos.Parameters.AddWithValue("@IdUsuario", Usuario.Id);
88
comandos.Parameters.AddWithValue("@TipoDocumento",
TipoDocumento);
if (Cliente.IDCLI > 0)
{
comandos.Parameters.AddWithValue("@IdCliente",
Cliente.IDCLI);
if (TipoDocumento.Contains("Crédito"))
{
comandos.CommandText = "UPDATE `cliente` SET `Saldo` =
`Saldo` + '"+Importe+"' WHERE `ID.CLI` = '"+ Cliente.IDCLI + "';";
comandos.ExecuteNonQuery();
}
}
else
{
comandos.Parameters.AddWithValue("@IdCliente",
DBNull.Value);
if (TipoDocumento.Contains("Crédito"))
{
MessageBox.Show("Debe especificar el cliente para
realizar ventas a crédito.", "Error", MessageBoxButton.OK,
MessageBoxImage.Warning);
return 0;
}
}
comandos.Parameters.AddWithValue("@Importe", Importe);
if (Envio == true)
{
comandos.Parameters.AddWithValue("@Envio", 1);
}
else
{
comandos.Parameters.AddWithValue("@Envio", 0);
}
comandos.Parameters.AddWithValue("@Cambio", Cambio);
comandos.CommandText = "insert into venta(`IDUsuario`,
`IDCliente`, `TipoDocumento`, `Fecha`, `Importe`, `Envio`, `Cambio`) values
(@IdUsuario, @IdCliente, @TipoDocumento, STR_TO_DATE('" + Fecha + "',
'%e/%c/%Y'), @Importe, @Envio, @Cambio);";
comandos.ExecuteNonQuery();
comandos.Parameters.Clear();
comandos.CommandText = "SELECT LAST_INSERT_ID();";
CerrarReader();
EjecutarReader();
datos.Read();
int idventa = datos.GetInt32(0);
CerrarReader();
89
{
int idprod = Convert.ToInt32(row["IDProducto"]);
float precio = float.Parse(row["PrecioVenta"].ToString());
float Cantidad = float.Parse(row["Cantidad"].ToString());
float SubTotal = float.Parse(row["SubTotal"].ToString());
comandos.CommandText = "INSERT into `detalleventa`
(`IdVenta`, `IdProd`, `PrecioVenta`, `Cantidad`, `SubTotal`) VALUES ('" +
idventa + "', '" + idprod + "', '" + precio + "', '"+Cantidad+"',
'"+SubTotal+"')";
comandos.ExecuteNonQuery();
}
CerrarConexion();
return idventa;
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButton.OK,
MessageBoxImage.Error);
return 0;
}
}
#endregion
#region Usuario
public int GetUserID(string username)
{
AbrirConexion();
comandos.CommandText = "SELECT `ID.Usuario` FROM `usuario` WHERE
Username = '"+username+"';";
EjecutarReader();
datos.Read();
Usuario.Id = datos.GetInt32("ID.Usuario");
CerrarReader();
return Usuario.Id;
}
public void SetUserData(int id)
{
AbrirConexion();
CerrarReader();
adapter = new MySqlDataAdapter("select `ID.Usuario`, `Username`,
CAST(AES_DECRYPT(`Contraseña`, '"+Usuario.key+"') AS CHAR), `Denominacion`,
`RUT`, `Direccion`, `Telefono`, `Foto` from usuario where
`usuario`.`ID.Usuario` = '" + id + "';", conexion);
adapter.Fill(UserData);
Usuario.Username = UserData.Rows[0][1].ToString();
Usuario.Password = UserData.Rows[0][2].ToString();
90
Usuario.Denominacion = UserData.Rows[0][3].ToString();
Usuario.RUT = UserData.Rows[0][4].ToString();
Usuario.Direccion = UserData.Rows[0][5].ToString();
Usuario.Telefono = UserData.Rows[0][6].ToString();
if (UserData.Rows[0][7] != DBNull.Value)
{
Usuario.Foto = (UserData.Rows[0][7]) as byte[];
}
adapter.Dispose();
}
public void SetUserImg(byte[] img, int id)
{
AbrirConexion();
string cadena = "UPDATE `usuario` SET Foto=@imagen WHERE
`ID.Usuario`= '"+id.ToString()+"';";
MySqlCommand comando = new MySqlCommand(cadena, conexion);
comando.Parameters.AddWithValue("@imagen", img);
comando.ExecuteNonQuery();
SetUserData(id);
}
public void UpdateUser(string user, string pwrd, string denom, string
RUT, string dir, string tel, int id)
{
comandos.Parameters.Clear();
AbrirConexion();
comandos.CommandText = "UPDATE `usuario` SET `Username` = '"+user+
"', `Contraseña` = AES_ENCRYPT(@Passwd, @key), `Denominacion` = '" + denom+"',
`RUT` = '"+RUT+"', `Direccion` = '"+dir+"', `Telefono` = '"+tel+"' WHERE
`usuario`.`ID.Usuario` = "+id.ToString()+";";
comandos.Parameters.AddWithValue("@Passwd", pwrd);
comandos.Parameters.AddWithValue("@key", Usuario.key);
comandos.ExecuteNonQuery();
SetUserData(id);
}
#endregion
#region Gastos
public DataTable GetGastos()
{
AbrirConexion();
comandos.CommandText = "SELECT IdGasto, Valor, Concepto, Tipo,
CAST(DATE_FORMAT(Fecha, '%e/%c/%Y') as char) Fecha from gasto where IdUsuario
= '" + Usuario.Id+"';";
EjecutarReader();
DTGastos.Rows.Clear();
DTGastos.Load(datos);
return DTGastos;
}
91
}
public void ActualizarGasto(string Valor, string Concepto, string
Fecha, string Tipo, string id)
{
AbrirConexion();
comandos.CommandText = "UPDATE `gasto` SET `Valor` = '" + Valor +
"', `Concepto` = '" + Concepto + "', `Fecha` = STR_TO_DATE('" + Fecha + "',
'%e/%c/%Y'), `Tipo` = '" + Tipo + "' WHERE `gasto`.`IdGasto` IN (" + id + ")
;";
comandos.ExecuteNonQuery();
}
#endregion
#region Clientes
Usuario.Id + "';";
EjecutarReader();
DTClientes.Rows.Clear();
DTClientes.Load(datos);
Cliente.Nombre = DTClientes.Rows[0]["Nombre"].ToString();
Cliente.Direccion = DTClientes.Rows[0]["Direccion"].ToString();
Cliente.Telefono = DTClientes.Rows[0]["Telefono"].ToString();
Cliente.Saldo =
float.Parse(DTClientes.Rows[0]["Saldo"].ToString());
}
public void InsertarCliente(string Nombre, string Direccion, string
Telefono, float Saldo)
{
AbrirConexion();
comandos.CommandText = "INSERT INTO `cliente` (`ID.CLI`,
`IdUsuario`, `Nombre`, `Direccion`, `Telefono`, `Saldo`) VALUES
(NULL,'"+Usuario.Id+"', '" +Nombre+ "', '" +Direccion+ "', '" +Telefono+ "',
'" +Saldo+ "');";
comandos.ExecuteNonQuery();
}
public void EliminarCliente(int id)
{
AbrirConexion();
comandos.CommandText = "DELETE FROM `cliente` WHERE
`cliente`.`ID.CLI` IN (" + id + ") ;";
comandos.ExecuteNonQuery();
}
public void ActualizarCliente(string Nombre, string Direccion, string
Telefono, float Saldo, string id)
{
AbrirConexion();
comandos.CommandText = "UPDATE `cliente` SET `Nombre` = '" +
Nombre + "', `Direccion` = '" + Direccion + "', `Telefono` = '" + Telefono +
"', `Saldo` = '" + Saldo + "' WHERE `cliente`.`ID.CLI` IN (" + id + ") ;";
comandos.ExecuteNonQuery();
}
#endregion
#region Inventario
public DataTable MostrarDTProd()
{
AbrirConexion();
comandos.CommandText = "select `ID.Prod`, `PrecioUnitario`,
`Descripcion`, `Stock`, `CostoUnitario` from producto_venta WHERE `IdUsuario`
= '" + Usuario.Id + "';";
EjecutarReader();
93
DTProd.Rows.Clear();
DTProd.Load(datos);
return DTProd;
}
public void SetProduct(int id)
{
AbrirConexion();
comandos.CommandText = "select `ID.Prod`, `PrecioUnitario`,
`Descripcion`, `Stock`, `CostoUnitario` from producto_venta where `ID.Prod` =
" + id + ";";
EjecutarReader();
DataTable producto = new DataTable();
producto.Load(datos);
Producto.ClearProductData();
if(producto.Rows.Count > 0)
{
Producto.IDPROD = int.Parse(producto.Rows[0][0].ToString());
Producto.Descripcion = producto.Rows[0][2].ToString();
Producto.PrecioUnitario =
int.Parse(producto.Rows[0][1].ToString());
Producto.Stock = int.Parse(producto.Rows[0][3].ToString());
Producto.CostoUnitario =
int.Parse(producto.Rows[0][4].ToString());
}
else
{
MessageBox.Show("No se encontraron datos.", "Error",
MessageBoxButton.OK, MessageBoxImage.Asterisk);
}
}
public DataTable MostrarDTMatPrim()
{
AbrirConexion();
comandos.CommandText = "select `ID.Mat`, `Costo`, `Descripcion`,
`Stock` from materia_prima WHERE `IdUsuario` = '"+Usuario.Id+"';";
EjecutarReader();
DTMatPrim.Rows.Clear();
DTMatPrim.Load(datos);
return DTMatPrim;
}
public void InsertarProd(string stock, string descrip, string precio)
{
AbrirConexion();
comandos.CommandText = "INSERT INTO `producto_venta` (`ID.Prod`,
`IdUsuario`, `Stock`, `Descripcion`, `PrecioUnitario`) VALUES (NULL,
'"+Usuario.Id+"', '"+Double.Parse(stock)+ "', '" +descrip+ "', '" +
Double.Parse(precio) + "');";
comandos.ExecuteNonQuery();
94
}
public void UsarMatPrim(int id, string fecha, float cantidad)
{
AbrirConexion();
95
comandos.Connection = conexion;
}
}
public void setComandos(string consulta)
{
comandos.CommandText = consulta;
}
public void EjecutarReader()
{
CerrarReader();
datos = comandos.ExecuteReader();
}
public void CerrarReader()
{
if (datos != null)
{
datos.Dispose();
datos.Close();
}
}
public void CerrarConexion()
{
if(conexion.State == ConnectionState.Open)
{
conexion.Dispose();
conexion.Close();
}
}
protected MySqlConnection GetMySqlConnection()
{
return conexion;
}
#endregion
}
}
97
FORMINICIAL.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using MySql.Data.MySqlClient;
using Ingenieros_Commerce_Manager_v2._0.Entities;
using System.IO;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormInicial : Form
{
public FormInicial()
{
InitializeComponent();
//Estas lineas eliminan los parpadeos del formulario o controles
en la interfaz grafica (Pero no en un 100%)
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
}
//Instancia de clase
conexionsql conexionsql = new conexionsql();
SecurityCheck check = new SecurityCheck();
this.WindowState = FormWindowState.Normal;
RedondeoForm.CornerRadius = 30;
}
}
private void BotonHide_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
[DllImport("user32.dll", EntryPoint = "ReleaseCapture")]
private extern static void ReleaseCapture();
[DllImport("user32.dll", EntryPoint = "SendMessage")]
private extern static void SendMessage(System.IntPtr hWnd, int wMsg,
int wParam, int lParam);
private void panelHeader_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
}
region.Exclude(sizeGripRectangle);
this.panelContenedor.Region = region;
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e) //Interactuar con el
rectangulo
{
SolidBrush blueBrush = new SolidBrush(Color.FromArgb(244, 244,
244));
e.Graphics.FillRectangle(blueBrush, sizeGripRectangle);
base.OnPaint(e);
ControlPaint.DrawSizeGrip(e.Graphics, Color.Transparent,
sizeGripRectangle);
}
#endregion
#region Estetica
private void lblRegistrarse_MouseHover(object sender, EventArgs e)
//Efecto estetico
{
lblRegistrarse.Cursor = Cursors.Hand;
lblRegistrarse.ForeColor = Color.Purple;
}
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.showpwd;
}
if (File.Exists("UserInfo.txt"))
{
File.Delete("UserInfo.txt");
}
}
formPrincipal.Show();
this.Hide();
}
else
{
MessageBox.Show("Usuario o contraseña incorrectos.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\nError al conectar, intente
de nuevo más tarde.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
private void lblRegistrarse_Click(object sender, EventArgs e)
//Muestra la interfaz de registro
{
lblRecordar.Visible = false;
btnRecordar.Visible = false;
txbConfirm.Visible = true;
btnRegistrarse.Visible = true;
btnLogin.Visible = false;
lblRegistrarse.Visible= false;
lblVolver.Visible = true;
}
private void btnRegistrarse_Click(object sender, EventArgs e) //Se
registra en la base de datos
{
try
{
if (txbPasswd.Texts == txbConfirm.Texts)
{
if(check.RegisterWEncrypt(txbUsuario.Texts,
txbPasswd.Texts) > 0)
{
MessageBox.Show("Usted fue registrado con éxito!",
"Usuario registrado", MessageBoxButtons.OK, MessageBoxIcon.Information);
102
txbConfirm.Visible = false;
lblRecordar.Visible = true;
btnRecordar.Visible = true;
btnRegistrarse.Visible = false;
btnLogin.Visible = true;
lblRegistrarse.Visible = true;
lblVolver.Visible = false;
}
else
{
MessageBox.Show("Error al registrar, intente de nuevo
más tarde.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
else
{
MessageBox.Show("Las contraseñas no son iguales.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
catch (Exception ex)
{
if (ex.Message.Contains("Duplicate entry"))
{
MessageBox.Show("El usuario ya existe.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
}
}
}
103
#endregion
FORMINVENTARIO.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using Microsoft.VisualStudio.Utilities.Internal;
using Ingenieros_Commerce_Manager_v2._0.Entities;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormInventario : Form
{
//Instancia de clase
conexionsql sql = new conexionsql();
Module module = new Module();
//Variables
private string idprod = null, idmat = null;
private bool editar = false;
public FormInventario()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
foreach (DataGridViewColumn column in dgvProductos.Columns)
{
105
cmbBusqueda.Items.Add(column.HeaderText);
}
if (dgvMatPrim.SelectedRows.Count > 0)
{
dgvProductos.ClearSelection();
if (idmat == null)
{
idmat =
dgvMatPrim.CurrentRow.Cells["ID.Mat"].Value.ToString();
106
else if
(!(idmat.Contains(dgvMatPrim.CurrentRow.Cells["ID.Mat"].Value.ToString())))
{
idmat = idmat + ", " +
dgvMatPrim.CurrentRow.Cells["ID.Mat"].Value.ToString();
}
}
cmbTipo.Texts = "Materia Prima";
}
private void btnIngreso_Click(object sender, EventArgs e)
{
if (txbPrecio.Texts.Trim() != "" && txbStock.Texts.Trim() != "" &&
txbDescrip.Texts.Trim() != "" && cmbTipo.Texts.Trim() != "")
{
if (cmbTipo.Texts == "Producto en Venta")
{
try
{
if (editar == true)
{
sql.UpdateProd(txbStock.Texts, txbDescrip.Texts,
txbPrecio.Texts, idprod);
editar = false;
}
else
{
sql.InsertarProd(txbStock.Texts, txbDescrip.Texts,
txbPrecio.Texts);
}
MostrarProductos();
MessageBox.Show("Datos ingresados correctamente",
"Acción realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
ClearTextBoxs();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else if (cmbTipo.Texts == "Materia Prima")
{
try
{
107
if (editar == true)
{
sql.UpdateMatPrim(txbStock.Texts,
txbDescrip.Texts, txbPrecio.Texts, idmat);
editar = false;
}
else
{
sql.InsertarMatPrim(txbStock.Texts,
txbDescrip.Texts, txbPrecio.Texts);
}
MostrarProductos();
MessageBox.Show("Datos ingresados correctamente",
"Acción realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
ClearTextBoxs();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Ingrese un tipo válido", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Debe completar todos los campos", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else if (dgvProductos.SelectedRows.Count > 0)
{
RemovePlaceHolders();
txbPrecio.Texts =
dgvProductos.CurrentRow.Cells["PrecioUnitario"].Value.ToString();
txbDescrip.Texts =
dgvProductos.CurrentRow.Cells["Descripcion"].Value.ToString();
txbStock.Texts =
dgvProductos.CurrentRow.Cells["Stock"].Value.ToString();
cmbTipo.Texts = "Producto en Venta";
editar = true;
}
else
{
MessageBox.Show("Seleccione una fila.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
try
{
sql.EliminarMatPrim(idmat);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else if (dgvProductos.SelectedRows.Count > 0)
109
}
else
{
MessageBox.Show("Seleccione una fila.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
MostrarProductos();
ClearTextBoxs();
}
cmbBusqueda.Texts = "";
btnUsar.Visible = false;
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
113
{
if (dgvProductos.SelectedRows.Count == 1)
{
btnCalcular.Visible = true;
}
else
{
btnCalcular.Visible = false;
}
}
sql.SetProduct(int.Parse(dgvProductos.CurrentRow.Cells["ID.Prod"].Value.ToStri
ng()));
FormCalcularCosto formCalcularCosto = new FormCalcularCosto();
var respuesta = formCalcularCosto.ShowDialog();
if(respuesta == DialogResult.OK)
{
MessageBox.Show("Datos ingresados correctamente.", "Acción
realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
MostrarProductos();
}
}
}
cmbTipo.Texts = "Producto en Venta";
}
114
}
115
FORMPRINCIPAL.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using MySql.Data.MySqlClient;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormPrincipal : Form
{
public FormPrincipal()
{
InitializeComponent();
//Estas lineas eliminan los parpadeos del formulario o controles
en la interfaz grafica (Pero no en un 100%)
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
Module.formContenedor = this;
conexionsql.CerrarReader();
}
//Instancia de clase
conexionsql conexionsql = new conexionsql();
FormSeguridad formSeguridad = new FormSeguridad();
//Variables
bool sideBarOpen = true;
bool ventasClosed = true;
this.WindowState = FormWindowState.Maximized;
RedondeoForm.CornerRadius = 0;
}
else
{
this.WindowState = FormWindowState.Normal;
RedondeoForm.CornerRadius = 30;
}
}
private void BotonHide_Click(object sender, EventArgs e)
{
this.WindowState = FormWindowState.Minimized;
}
[DllImport("user32.dll", EntryPoint = "ReleaseCapture")]
private extern static void ReleaseCapture();
[DllImport("user32.dll", EntryPoint = "SendMessage")]
private extern static void SendMessage(System.IntPtr hWnd, int wMsg,
int wParam, int lParam);
private void panelHeader_MouseDown(object sender, MouseEventArgs e)
{
ReleaseCapture();
SendMessage(this.Handle, 0x112, 0xf012, 0);
RedondeoForm.CornerRadius = 30;
}
if (color == btnVentas)
{
btnVentas.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.venta24blue;
btnGastos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.gasto24;
btnPagos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.pagos24;
btnInventario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.inevntario24;
btnResumen.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.resumen24;
btnUsuario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.usuario24;
}
else if (color == btnGastos)
{
btnVentas.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.venta24;
btnGastos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.gasto24blue;
btnPagos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.pagos24;
btnInventario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.inevntario24;
btnResumen.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.resumen24;
btnUsuario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.usuario24;
}
else if (color == btnPagos)
{
btnVentas.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.venta24;
btnGastos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.gasto24;
119
btnPagos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.pagos24blue;
btnInventario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.inevntario24;
btnResumen.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.resumen24;
btnUsuario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.usuario24;
}
else if (color == btnInventario)
{
btnVentas.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.venta24;
btnGastos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.gasto24;
btnPagos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.pagos24;
btnInventario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.inevntario24blue;
btnResumen.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.resumen24;
btnUsuario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.usuario24;
}
else if (color == btnResumen)
{
btnVentas.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.venta24;
btnGastos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.gasto24;
btnPagos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.pagos24;
btnInventario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.inevntario24;
btnResumen.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.resumen24blue;
btnUsuario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.usuario24;
}
else if (color == btnUsuario)
{
btnVentas.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.venta24;
btnGastos.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.gasto24;
btnPagos.Image =
120
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.pagos24;
btnInventario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.inevntario24;
btnResumen.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.resumen24;
btnUsuario.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.usuario24blue;
}
}
private void btnVentas_Click(object sender, EventArgs e)
{
TimerVentas.Start();
}
private void btnGastos_Click(object sender, EventArgs e)
{
colorearBoton(btnGastos, btnPagos, btnVentas, btnInventario,
btnResumen, btnUsuario);
AbrirFormulario<FormGastos>();
}
private void btnPagos_Click(object sender, EventArgs e)
{
colorearBoton(btnPagos, btnVentas, btnGastos, btnInventario,
btnResumen, btnUsuario);
AbrirFormulario<FormClientes>();
}
private void btnInventario_Click(object sender, EventArgs e)
{
var respuesta = formSeguridad.ShowDialog();
if (respuesta == DialogResult.OK)
{
colorearBoton(btnInventario, btnPagos, btnGastos, btnVentas,
btnResumen, btnUsuario);
AbrirFormulario<FormInventario>();
}
}
private void btnResumen_Click(object sender, EventArgs e)
{
var respuesta = formSeguridad.ShowDialog();
if (respuesta == DialogResult.OK)
{
colorearBoton(btnResumen, btnPagos, btnGastos, btnVentas,
btnInventario, btnUsuario);
AbrirFormulario<FormResumen>();
}
}
private void btnUsuario_Click(object sender, EventArgs e)
{
121
}
private void sidebarTimer_Tick(object sender, EventArgs e)
{
if (sideBarOpen)
{
sideBarPanel.Width -= 30;
panelPrincipal.Width += 30;
int x = panelPrincipal.Location.X;
int y = panelPrincipal.Location.Y;
panelPrincipal.Location = new Point(x-30, y);
if (sideBarPanel.Width == sideBarPanel.MinimumSize.Width)
{
panelPrincipal.Location = new Point(71, y);
panelPrincipal.Width = panelHeader.Width -
sideBarPanel.Width;
sideBarOpen = false;
sidebarTimer.Stop();
}
}
else
{
sideBarPanel.Width += 30;
panelPrincipal.Width -= 30;
int x = panelPrincipal.Location.X;
int y = panelPrincipal.Location.Y;
panelPrincipal.Location = new Point(x + 30, y);
if (sideBarPanel.Width == sideBarPanel.MaximumSize.Width)
{
panelPrincipal.Location = new Point(230, y);
panelPrincipal.Width = panelHeader.Width -
sideBarPanel.Width;
sideBarOpen = true;
sidebarTimer.Stop();
}
}
}
private void btnMenu_Click(object sender, EventArgs e)
{
sidebarTimer.Start();
}
private void TimerVentas_Tick(object sender, EventArgs e)
122
{
if (ventasClosed)
{
VentasContainer.Height += 30;
if(VentasContainer.Height ==
VentasContainer.MaximumSize.Height)
{
ventasClosed = false;
TimerVentas.Stop();
}
}
else
{
VentasContainer.Height -= 30;
if(VentasContainer.Height ==
VentasContainer.MinimumSize.Height)
{
ventasClosed = true;
TimerVentas.Stop();
}
}
}
private void btnRegistrar_Click(object sender, EventArgs e)
{
TimerVentas.Start();
AbrirFormulario<FormVentas>();
colorearBoton(btnVentas, btnPagos, btnGastos, btnInventario,
btnResumen, btnUsuario);
}
private void btnHistorial_Click(object sender, EventArgs e)
{
TimerVentas.Start();
AbrirFormulario<FormHistorialVenta>();
colorearBoton(btnVentas, btnPagos, btnGastos, btnInventario,
btnResumen, btnUsuario);
}
#endregion
}
}
123
FORMVENTAS.CS
using System;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.IO;
using System.Reflection;
using System.Runtime.Remoting.Messaging;
using System.Windows.Forms;
using Ingenieros_Commerce_Manager_v2._0.Entities;
using iTextSharp.text.pdf;
using iTextSharp.text;
using iTextSharp.tool.xml;
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormVentas : Form
{
public FormVentas()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
}
//Instancia de clase
conexionsql sql = new conexionsql();
Module module = new Module();
//Variables
int pago;
MessageBoxButtons.OK, MessageBoxIcon.Error);
txbCantidad.Texts = "0";
txbCantidad.Select();
return;
}
txbCantidad.Texts = (num + 1).ToString();
txbCantidad.Select();
}
}
private void FillProductInfo()
{
txbIDProd.Texts = Producto.IDPROD.ToString();
txbProd.Texts = Producto.Descripcion;
txbPrecio.Texts = Producto.PrecioUnitario.ToString();
txbStock.Texts = Producto.Stock.ToString();
txbCantidad.Select();
}
try
{
sql.SetProduct(int.Parse(txbIDProd.Texts));
FillProductInfo();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
}
foreach (DataGridViewRow row in dgvVenta.Rows)
{
if (row.Cells["IDProducto"].Value.ToString() ==
txbIDProd.Texts)
{
prodexiste = true;
break;
}
}
if (!prodexiste)
{
dgvVenta.Rows.Add(
new object[]
{
txbIDProd.Texts,
txbProd.Texts,
txbCantidad.Texts,
precio.ToString(),
(float.Parse(txbCantidad.Texts)*precio).ToString()
});
sql.RestarStock(int.Parse(txbIDProd.Texts),
txbCantidad.Texts.Replace(',', '.'));
}
else
{
MessageBox.Show("El producto ya ha sido seleccionado.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
txbIDProd.Select();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
CalcularTotal();
ClearProducts();
txbIDProd.Select();
}
total = total +
float.Parse(row.Cells["SubTotal"].Value.ToString());
}
txbTotal.Texts = total.ToString("0.00");
}
}
private void ClearProducts()
{
txbIDProd.Texts = "0";
txbProd.Texts = "";
txbPrecio.Texts = "";
txbStock.Texts = "";
txbCantidad.Texts = "0";
}
e.Graphics.DrawImage(Properties.Resources.trash24, new
System.Drawing.Rectangle(x, y, w, h));
e.Handled = true;
}
}
int.Parse(dgvVenta.Rows[index].Cells["IDProducto"].Value.ToString()),
dgvVenta.Rows[index].Cells["Cantidad"].Value.ToString().Replace(',', '.')
);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar+",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dgvVenta.Rows.RemoveAt(index);
CalcularTotal();
}
}
}
private void CalcularCambio()
{
if(txbPaga.Texts.Length == 0)
{
txbCambio.Texts = "0";
return;
}
if (!int.TryParse(txbPaga.Texts, out pago))
{
MessageBox.Show("Formato incorrecto.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if (txbTotal.Texts.Trim() == "")
{
MessageBox.Show("No existen productos en la venta.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
return;
}
if(pago < float.Parse(txbTotal.Texts))
{
return;
}
txbCambio.Texts = (pago - float.Parse(txbTotal.Texts)).ToString();
}
else
{
cambio= 0;
}
int idventa = sql.RegistrarVenta(cmbTipoDoc.Texts, txbFecha.Texts,
float.Parse(txbTotal.Texts), envio, cambio, detalle);
if (idventa != 0)
{
var respuesta = MessageBox.Show("Venta Nº:'"+idventa+"'
generada \n ¿Desea generar el documento?", "Acción completada",
MessageBoxButtons.YesNo, MessageBoxIcon.Information);
if(respuesta == DialogResult.Yes)
{
SaveFileDialog dialog = new SaveFileDialog();
dialog.FileName = DateTime.Now.ToString("ddMMyyyyHHmmss")
+ ".pdf";
dialog.AddExtension = true;
dialog.DefaultExt = "pdf";
dialog.RestoreDirectory = true;
string txthtml =
Properties.Resources.Plantilla.ToString();
txthtml = txthtml.Replace("@DENOMINACION",
Usuario.Denominacion);
txthtml = txthtml.Replace("@DIRECCION",
Usuario.Direccion);
txthtml = txthtml.Replace("@TELEFONO", Usuario.Telefono);
txthtml = txthtml.Replace("@RUT", Usuario.RUT);
txthtml = txthtml.Replace("@TIPODOCUMENTO",
cmbTipoDoc.Texts);
txthtml = txthtml.Replace("@IDVENTA",
idventa.ToString("000000"));
txthtml = txthtml.Replace("@FECHA", txbFecha.Texts);
txthtml = txthtml.Replace("@TOTAL", txbTotal.Texts);
txthtml = txthtml.Replace("@CLIENTE", txbNombre.Texts);
txthtml = txthtml.Replace("@DIRCLI", Cliente.Direccion);
sql.SetProduct(int.Parse(row.Cells["IDProducto"].Value.ToString()));
filas += "<tr>";
filas += "<td>" +
row.Cells["Cantidad"].Value.ToString() + "</td>";
filas += "<td>" + Producto.Descripcion + "</td>";
filas += "<td>" +
131
row.Cells["PrecioUnitario"].Value.ToString() + "</td>";
filas += "<td>" +
row.Cells["SubTotal"].Value.ToString() + "</td>";
filas += "</tr>";
}
txthtml = txthtml.Replace("@FILAS", filas);
if (dialog.ShowDialog() == DialogResult.OK)
{
using (FileStream fs = new FileStream(dialog.FileName,
FileMode.Create))
{
Document pdf = new Document(PageSize.A4, 25, 25,
25, 25);
PdfWriter writer = PdfWriter.GetInstance(pdf, fs);
pdf.Open();
pdf.Add(new Phrase(""));
System.Drawing.Image img =
System.Drawing.Image.FromStream(Usuario.ByteToImage(Usuario.Foto));
var format = img.RawFormat;
iTextSharp.text.Image image =
iTextSharp.text.Image.GetInstance(img, format);
image.ScaleToFit(80, 80);
image.Alignment =
iTextSharp.text.Image.UNDERLYING;
image.SetAbsolutePosition(pdf.LeftMargin, pdf.Top
- 80);
pdf.Add(image);
txbCambio.Texts = "";
}
}
}
}
133
FORMHISTORIALVENTA.CS
using Microsoft.VisualStudio.Utilities.Internal;
using Org.BouncyCastle.Math.EC.Multiplier;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using iTextSharp.tool.xml;
using iTextSharp.text;
using iTextSharp.text.pdf;
using Ingenieros_Commerce_Manager_v2._0.Entities;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormHistorialVenta : Form
{
public FormHistorialVenta()
{
InitializeComponent();
}
//Instancia de clase
conexionsql sql = new conexionsql();
DataTable DTVentas = new DataTable();
DataTable InfoVentas = new DataTable();
});
}
dialog.FileName = DateTime.Now.ToString("ddMMyyyyHHmmss")
+ ".pdf";
dialog.AddExtension = true;
dialog.DefaultExt = "pdf";
dialog.RestoreDirectory = true;
sql.SetCliente(int.Parse(DTVentas.Rows[index]["ID.CLI"].ToString()));
string txthtml =
Properties.Resources.Plantilla.ToString();
txthtml = txthtml.Replace("@DENOMINACION",
Usuario.Denominacion);
txthtml = txthtml.Replace("@DIRECCION",
Usuario.Direccion);
txthtml = txthtml.Replace("@TELEFONO", Usuario.Telefono);
txthtml = txthtml.Replace("@RUT", Usuario.RUT);
txthtml = txthtml.Replace("@TIPODOCUMENTO",
dgvVentas.Rows[index].Cells["TipoDocumento"].Value.ToString());
txthtml = txthtml.Replace("@IDVENTA",
int.Parse(dgvVentas.Rows[index].Cells["IdVentas"].Value.ToString()).ToString("
000000"));
txthtml = txthtml.Replace("@FECHA",
dgvVentas.Rows[index].Cells["Fecha"].Value.ToString());
txthtml = txthtml.Replace("@TOTAL",
dgvVentas.Rows[index].Cells["Importe"].Value.ToString());
txthtml = txthtml.Replace("@CLIENTE",
dgvVentas.Rows[index].Cells["Cliente"].Value.ToString());
135
txthtml = txthtml.Replace("@DIRCLI",
Entities.Cliente.Direccion);
if (dialog.ShowDialog() == DialogResult.OK)
{
using (FileStream fs = new FileStream(dialog.FileName,
FileMode.Create))
{
Document pdf = new Document(PageSize.A4, 25, 25,
25, 25);
PdfWriter writer = PdfWriter.GetInstance(pdf, fs);
pdf.Open();
pdf.Add(new Phrase(""));
if(Usuario.Foto != null)
{
System.Drawing.Image img =
System.Drawing.Image.FromStream(Usuario.ByteToImage(Usuario.Foto));
var format = img.RawFormat;
iTextSharp.text.Image image =
iTextSharp.text.Image.GetInstance(img, format);
image.ScaleToFit(80, 80);
image.Alignment =
iTextSharp.text.Image.UNDERLYING;
image.SetAbsolutePosition(pdf.LeftMargin,
pdf.Top - 80);
pdf.Add(image);
}
136
}
}
}
else
{
row.Visible = false;
}
}
}
}
}
FORMBUSCARCLIENTE.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ingenieros_Commerce_Manager_v2._0.Entities;
using Microsoft.VisualStudio.Utilities.Internal;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormBuscarCliente : Form
{
public FormBuscarCliente()
{
InitializeComponent();
}
//Instancia de clase
conexionsql sql = new conexionsql();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
Cliente.IDCLI =
int.Parse(dgvCliente.CurrentRow.Cells["ID.CLI"].Value.ToString());
Cliente.Saldo =
float.Parse(dgvCliente.CurrentRow.Cells["Saldo"].Value.ToString());
Cliente.Telefono =
dgvCliente.CurrentRow.Cells["Telefono"].Value.ToString();
Cliente.Direccion =
dgvCliente.CurrentRow.Cells["Direccion"].Value.ToString();
Cliente.Nombre =
dgvCliente.CurrentRow.Cells["Nombre"].Value.ToString();
}
{
txbBuscar.Texts = "";
foreach (DataGridViewRow row in dgvCliente.Rows)
{
row.Visible = true;
}
cmbBusqueda.Texts = "";
}
FORMBUSCARPROD.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Ingenieros_Commerce_Manager_v2._0.Entities;
using Microsoft.VisualStudio.Utilities.Internal;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormBuscarProd : Form
{
public FormBuscarProd()
{
InitializeComponent();
}
//Instancia de clase
conexionsql sql = new conexionsql();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
142
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
row.Visible = true;
}
cmbBusqueda.Texts = "";
}
FORMCALCULARCOSTO.CS
using Ingenieros_Commerce_Manager_v2._0.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormCalcularCosto : Form
{
public FormCalcularCosto()
{
InitializeComponent();
}
//Instancia de clase
conexionsql sql = new conexionsql();
float costonuevo;
txbCantidad.Texts = "0";
txbCantidad.Select();
return;
}
txbCantidad.Texts = (num - 1).ToString();
txbCantidad.Select();
}
{
if (!float.TryParse(txbCantidad.Texts, out float cantidad) |
!float.TryParse(txbCostoProduccion.Texts, out float costo))
{
MessageBox.Show("Formato incorrecto", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else
{
costonuevo = costo / cantidad;
lblCostoCalculado.Text = "Costo calculado:" + costonuevo;
}
}
}
}
147
FORMCLIENTES.CS
using Microsoft.VisualStudio.Utilities.Internal;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormClientes : Form
{
public FormClientes()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
}
//Instancia de clase
conexionsql sql = new conexionsql();
//Variables;
bool editar;
string id;
public void ClearTextBoxs()
{
customTextBoxNombre.Texts = "";
customTextBoxDireccion.Texts = "";
customTextBoxTelefono.Texts = "";
customTextBoxSaldo.Texts = "";
}
private void FormClientes_Load(object sender, EventArgs e)
{
try
{
dgvClientes.DataSource = sql.GetClientes();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
148
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
try
{
if (editar == true)
{
sql.ActualizarCliente(customTextBoxNombre.Texts,
customTextBoxDireccion.Texts, customTextBoxTelefono.Texts,
float.Parse(customTextBoxSaldo.Texts), id);
editar = false;
}
else
{
sql.InsertarCliente(customTextBoxNombre.Texts,
customTextBoxDireccion.Texts, customTextBoxTelefono.Texts,
float.Parse(customTextBoxSaldo.Texts));
}
dgvClientes.DataSource = sql.GetClientes();
MessageBox.Show("Datos ingresados correctamente",
"Acción realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
ClearTextBoxs();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Debe completar todos los campos", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
149
}
else if
(!(id.Contains(dgvClientes.CurrentRow.Cells["ID.CLI"].Value.ToString())))
{
id = id + ", " +
dgvClientes.CurrentRow.Cells["ID.CLI"].Value.ToString();
}
}
}
customTextBoxNombre.Texts =
dgvClientes.CurrentRow.Cells["Nombre"].Value.ToString();
customTextBoxDireccion.Texts =
dgvClientes.CurrentRow.Cells["Direccion"].Value.ToString();
customTextBoxTelefono.Texts =
dgvClientes.CurrentRow.Cells["Telefono"].Value.ToString();
customTextBoxSaldo.Texts =
dgvClientes.CurrentRow.Cells["Saldo"].Value.ToString();
editar = true;
}
else
{
MessageBox.Show("Seleccione una fila.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
{
if (dgvClientes.SelectedRows.Count > 0)
{
var respuesta = MessageBox.Show("¿Desea eliminar los elementos
seleccionados? Esta acción no puede revertirse", "Advertencia",
MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (respuesta == DialogResult.Yes)
{
try
{
sql.EliminarCliente(int.Parse(id));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else
{
MessageBox.Show("Seleccione una fila.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dgvClientes.DataSource = sql.GetClientes();
ClearTextBoxs();
{
CurrencyManager manager =
(CurrencyManager)dgvClientes.BindingContext[dgvClientes.DataSource];
manager.SuspendBinding();
string Filter = cmbBusqueda.Texts;
if (dgvClientes.Rows.Count > 0)
{
if (Filter.IsNullOrWhiteSpace() == true)
{
MessageBox.Show("Seleccione un criterio de búsqueda.",
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
}
else
{
foreach (DataGridViewRow row in dgvClientes.Rows)
{
if
(row.Cells[Filter].Value.ToString().Trim().ToLower().Contains(txbBuscar.Texts.
Trim().ToLower()))
{
row.Visible = true;
}
else
{
row.Visible = false;
}
}
}
}
manager.ResumeBinding();
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
152
FORMGASTOS.CS
using Microsoft.VisualStudio.Utilities.Internal;
using System;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormGastos : Form
{
public FormGastos()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
}
//Instancia de clase
Module module = new Module();
//Conexion SQL
conexionsql sql = new conexionsql();
//Variables;
bool editar;
string id;
//Método borrar textboxs
public void ClearTextBoxs()
{
txbValorGastos.Texts = "";
txbConceptoGastos.Texts = "";
txbFechaGastos.Texts = "";
}
private void FormGastos_Load(object sender, EventArgs e)
{
txbFechaGastos.Texts = DateTime.Now.ToString("dd/MM/yyyy");
try
{
dgvGastos.DataSource = sql.GetGastos();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
foreach (DataGridViewColumn column in dgvGastos.Columns)
{
cmbBusqueda.Items.Add(column.HeaderText);
153
}
cmbBusqueda.Texts = "Concepto";
try
{
if (editar == true)
{
sql.ActualizarGasto(txbValorGastos.Texts,
txbFechaGastos.Texts, txbConceptoGastos.Texts, cmbTipo.Texts, id);
editar = false;
}
else
{
sql.InsertarGasto(txbValorGastos.Texts,
txbFechaGastos.Texts, txbConceptoGastos.Texts, cmbTipo.Texts);
}
dgvGastos.DataSource = sql.GetGastos();
MessageBox.Show("Datos ingresados correctamente", "Acción
realizada", MessageBoxButtons.OK, MessageBoxIcon.Information);
ClearTextBoxs();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK,
MessageBoxIcon.Error);
}
}
else
{
MessageBox.Show("Debe completar todos los campos", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
txbConceptoGastos.Texts =
154
dgvGastos.CurrentRow.Cells["Concepto"].Value.ToString();
txbFechaGastos.Texts =
dgvGastos.CurrentRow.Cells["Fecha"].Value.ToString();
txbValorGastos.Texts =
dgvGastos.CurrentRow.Cells["Valor"].Value.ToString();
cmbTipo.Texts =
dgvGastos.CurrentRow.Cells["Tipo"].Value.ToString();
editar = true;
}
else
{
MessageBox.Show("Seleccione una fila.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
try
{
sql.EliminarGasto(int.Parse(id));
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
else
{
MessageBox.Show("Seleccione una fila.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
dgvGastos.DataSource = sql.GetGastos();
ClearTextBoxs();
155
}
else if
(!(id.Contains(dgvGastos.CurrentRow.Cells["IdGasto"].Value.ToString())))
{
id = id + ", " +
dgvGastos.CurrentRow.Cells["IdGasto"].Value.ToString();
}
}
}
(CurrencyManager)dgvGastos.BindingContext[dgvGastos.DataSource];
manager.SuspendBinding();
txbValorGastos.Texts = "0";
txbValorGastos.Select();
return;
}
txbValorGastos.Texts = (num + 1).ToString();
txbValorGastos.Select();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Error al conectar",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
158
FORMRESUMEN.CS
using Microsoft.Build.Framework;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Text;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormResumen : Form
{
private ResumenData model;
public FormResumen()
{
InitializeComponent();
dtpFechaInicio.Value = DateTime.Now.AddDays(-7);
dtpFechaFin.Value = DateTime.Now;
btn7dias.Select();
model.NumProductos.ToString();
chartIngresos.DataSource = model.IngresosBrutos;
chartIngresos.Series[0].XValueMember = "Fecha";
chartIngresos.Series[0].YValueMembers = "Monto";
chartIngresos.DataBind();
chartGastos.DataSource = model.GastosXFecha;
chartGastos.Series[0].XValueMember = "Fecha";
chartGastos.Series[0].YValueMembers = "Monto";
chartGastos.DataBind();
chartGananciasProds.DataSource = model.GananciaXProducto;
chartGananciasProds.Series[0].XValueMember = "Key";
chartGananciasProds.Series[0].YValueMembers = "Value";
chartGananciasProds.DataBind();
chartProds.DataSource = model.ProductosMasVendidos;
chartProds.Series[0].XValueMember = "Key";
chartProds.Series[0].YValueMembers = "Value";
chartProds.DataBind();
dgvBajoStock.DataSource = model.ProductosBajoStock;
dgvBajoStock.Columns["Key"].HeaderText = "Producto";
dgvBajoStock.Columns["Value"].HeaderText = "Cantidad";
Console.WriteLine("Vista cargada");
dgvBajoStock.ClearSelection();
}
else
{
Console.WriteLine("Vista no cargada");
}
}
dtpFechaFin.Value = DateTime.Now;
LoadData(DateTime.Now.AddDays(-7), DateTime.Now);
FORMSEGURIDAD.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormSeguridad : Form
{
public FormSeguridad()
{
InitializeComponent();
}
SecurityCheck check = new SecurityCheck();
private void btnAceptar_Click(object sender, EventArgs e)
{
if (check.CheckPasswd(txbContra.Texts))
{
this.DialogResult = DialogResult.OK;
txbContra.Texts = "";
this.Close();
}
else
{
MessageBox.Show("Contraseña incorrecta.", "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
txbContra.PasswordChar = false;
btnPWDChar.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.hidepwd;
}
else
{
txbContra.PasswordChar = true;
btnPWDChar.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.showpwd;
}
}
}
}
163
FORMSOPORTE.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormSoporte : Form
{
public FormSoporte()
{
InitializeComponent();
}
using Ingenieros_Commerce_Manager_v2._0.Entities;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormUsarMatPrim : Form
{
public FormUsarMatPrim()
{
InitializeComponent();
}
conexionsql sql = new conexionsql();
Module module = new Module();
MateriaPrima.ClearMatData();
this.Close();
}
}
}
167
FORMUSUARIO.CS
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Imaging;
using Ingenieros_Commerce_Manager_v2._0.Entities;
namespace Ingenieros_Commerce_Manager_v2._0
{
public partial class FormUsuario : Form
{
public FormUsuario()
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.DoubleBuffered = true;
}
//Instancia de clase
conexionsql sql = new conexionsql();
private void btnInfo_Click(object sender, EventArgs e)
{
MessageBox.Show("Esta información será incluida en la facturación
generada por el sistema.", "Información", MessageBoxButtons.OK,
MessageBoxIcon.Information);
}
private void UpdateForm()
{
txbUsername.Texts = Usuario.Username;
txbDenom.Texts = Usuario.Denominacion;
txbRUT.Texts = Usuario.RUT;
txbTel.Texts = Usuario.Telefono;
txbDir.Texts = Usuario.Direccion;
if (Usuario.Foto != null)
{
ImgUser.Image =
Image.FromStream(Usuario.ByteToImage(Usuario.Foto));
}
168
else
{
ImgUser.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.galeria;
}
txbClaveActual.Texts = "";
txbClaveNueva.Texts = "";
txbClaveActual.PasswordChar = false;
txbClaveNueva.PasswordChar = false;
btnPWDChar.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.hidepwd;
}
else
{
txbClaveActual.PasswordChar = true;
txbClaveNueva.PasswordChar = true;
btnPWDChar.Image =
Ingenieros_Commerce_Manager_v2._0.Properties.Resources.showpwd;
}
}
UpdateForm();
}
MessageBox.Show(ex.ToString(), "Error",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
RESUMENDATA.CS
using Ingenieros_Commerce_Manager_v2._0.Entities;
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Data;
using System.Globalization;
using System.Linq;
using System.Reflection;
namespace Ingenieros_Commerce_Manager_v2._0
{
public struct IngresosXFecha
{
public string Fecha { get; set; }
public float Monto { get; set; }
}
public class ResumenData : conexionsql
{
{
cmd.Connection = conexion;
while (reader.Read())
{
ListaResultadosVentas.Add(new KeyValuePair<DateTime,
float>((DateTime)reader[0], float.Parse(reader[1].ToString())));
TotalIngresos += float.Parse(reader[1].ToString());
}
reader.Close();
reader.Dispose();
cmd.Parameters.Clear();
}
foreach (var item in ListaResultadosGastos)
175
{
GastosXFecha.Add(new IngresosXFecha()
{
Fecha = item.Key.ToString("dd MMM yyyy"),
Monto = item.Value
});
}
else if(NroDias <= 92)
{
IngresosBrutos = (from orderList in
ListaResultadosVentas
group orderList by
CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
orderList.Key,
CalendarWeekRule.FirstDay, DayOfWeek.Monday)
into order
select new IngresosXFecha
{
Fecha = "Semana "+
order.Key.ToString(),
Monto = order.Sum(amount =>
amount.Value)
}).ToList();
GastosXFecha = (from orderList in
ListaResultadosGastos
group orderList by
CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(
orderList.Key,
CalendarWeekRule.FirstDay, DayOfWeek.Monday)
into order
select new IngresosXFecha
{
Fecha = "Semana " +
order.Key.ToString(),
Monto = order.Sum(amount =>
amount.Value)
}).ToList();
}
else if(NroDias <= (365 * 2))
{
IngresosBrutos = (from orderList in
ListaResultadosVentas
group orderList by
orderList.Key.ToString("MMM yyyy")
into order
176
Fecha = order.Key,
Monto = order.Sum(amount=>
amount.Value)
}).ToList();
GastosXFecha = (from orderList in
ListaResultadosGastos
group orderList by
orderList.Key.ToString("MMM yyyy")
into order
select new IngresosXFecha
{
Fecha = order.Key,
Monto = order.Sum(amount =>
amount.Value)
}).ToList();
}
else
{
IngresosBrutos = (from orderList in
ListaResultadosVentas
group orderList by
orderList.Key.ToString("yyyy")
into order
select new IngresosXFecha
{
Fecha = order.Key,
Monto = order.Sum(amount =>
amount.Value)
}).ToList();
GastosXFecha = (from orderList in
ListaResultadosGastos
group orderList by
orderList.Key.ToString("yyyy")
into order
select new IngresosXFecha
{
Fecha = order.Key,
Monto = order.Sum(amount =>
amount.Value)
}).ToList();
}
}
}
}
private void GetAnalisisProductos()
177
{
ProductosMasVendidos = new List<KeyValuePair<string, float>>();
GetNroItems();
GetAnalisisVentas();
GetAnalisisProductos();
Console.WriteLine("Datos correctamente actualizados.");
return true;
}
else
{
Console.WriteLine("Datos no actualizados.");
return false;
}
}
SECURITYCHECK.CS
using MySql.Data.MySqlClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Ingenieros_Commerce_Manager_v2._0.Entities;
namespace Ingenieros_Commerce_Manager_v2._0
{
public class SecurityCheck : conexionsql
{
public bool CheckPasswd(string passwd)
{
using(var conexion = GetMySqlConnection())
{
conexion.Open();
using(var cmd = new MySqlCommand())
{
cmd.Connection = conexion;
cmd.CommandText = "SELECT Contraseña from Usuario WHERE
AES_DECRYPT(Contraseña, @key) = @Passwd AND `ID.Usuario` = @UserID;";
cmd.Parameters.Add("@Passwd", MySqlDbType.VarChar).Value =
passwd;
cmd.Parameters.Add("@UserID", MySqlDbType.VarChar).Value =
Usuario.Id.ToString();
cmd.Parameters.AddWithValue("@key", Usuario.key);
var reader = cmd.ExecuteReader();
return reader.Read();
}
}
}
cmd.Parameters.AddWithValue("@Username", username);
cmd.Parameters.AddWithValue("@Passwd", passwd);
cmd.Parameters.AddWithValue("@key", Usuario.key);
var reader = cmd.ExecuteReader();
return reader.Read();
}
}
}
public int RegisterWEncrypt(string username, string passwd)
{
using (var conexion = GetMySqlConnection())
{
conexion.Open();
using (var cmd = new MySqlCommand())
{
cmd.Connection = conexion;
cmd.CommandText = "INSERT INTO usuario (Username,
Contraseña) VALUES (@Username, AES_ENCRYPT(@Passwd, @key));";
cmd.Parameters.AddWithValue("@Username", username);
cmd.Parameters.AddWithValue("@Passwd", passwd);
cmd.Parameters.AddWithValue("@key", Usuario.key);
return cmd.ExecuteNonQuery();
}
}
}
}
}
182
CLIENTE.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ingenieros_Commerce_Manager_v2._0.Entities
{
public class Cliente
{
public static int IDCLI { get; set; }
public static string Nombre { get; set; }
public static string Direccion { get; set; }
public static string Telefono { get; set; }
public static float Saldo { get; set; }
MATERIAPRIMA.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ingenieros_Commerce_Manager_v2._0.Entities
{
public class MateriaPrima
{
public static int Id { get; set; }
public static string Descripcion { get; set; }
public static float Stock { get; set; }
public static float Costo { get; set; }
}
}
184
PRODUCTO.CS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Ingenieros_Commerce_Manager_v2._0.Entities
{
public class Producto
{
public static int IDPROD { get; set; }
public static string Descripcion { get; set; }
public static float Stock { get; set; }
public static float PrecioUnitario { get; set; }
public static float CostoUnitario { get; set; }
}
}
185
USUARIO.CS
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing.Imaging;
namespace Ingenieros_Commerce_Manager_v2._0.Entities
{
public class Usuario
{
public static int Id { get; set; }
public static string Username { get; set; }
public static string Password { get; set; }
public static string Denominacion { get; set; }
public static string Direccion { get; set; }
public static string Telefono { get; set; }
public static string RUT { get; set; }
public static byte[] Foto { get; set; }
}
else if (img.RawFormat == ImageFormat.Bmp)
{
img.Save(ms, ImageFormat.Bmp);
}
return ms.ToArray();
}
public static void ClearData()
{
Id = 0;
Username = null;
Password = null;
Direccion = null;
Denominacion = null;
Telefono = null;
RUT = null;
Foto = null;
}
}
}
187
MANUAL DE
USUARIO
188
OBJETIVO
La implementación del manual de usuario presenta como objetivo el aprendizaje
y facilitación del uso del programa que se está pretende presentar, en este caso
“Ingenieros Commerce Manager” es un programa sencillo en cuanto a manejo,
pero, de todas maneras, aquí presentamos el manual para que el propietario
tenga una interacción más amena con el desarrollo del programa y con las
complicaciones que se vayan presentando.
Al momento de compilar los datos y manejar los detalles dentro del programa, se
le presenta una guía para la facilitación de la búsqueda de dichas herramientas,
también cabe mencionar que dentro del manual se presentan explicaciones de
los elementos que se podrán visualizar dentro del software.
189
REGISTRO DE SESIONES:
REGISTRO DE VENTAS:
En la pantalla de historial lo que se puede ver son las ventas realizadas con
su respectiva descripción y el cliente a quien se le realizo, así como su
fecha. También presenta la opción de buscar las ventas realizadas con un
atributo que las defina.
194
REGISTRO DE GASTOS
REGISTRO DE INVENTARIO
se deberá ingresar el precio, stock, descripción y el tipo que sea, ya sea materia
En
FORMULARIO DE RESUMEN
vez presenta graficas que presentan los ingresos brutos, los costos y los
productos que son más vendidos, a su vez presenta un apartado que
muestra los productos que se están agotando y su respectiva información.
201
REGISTRO DE CLIENTES
REGISTRO DE USUARIO
RED DE LA
EMPRESA
206
CONCLUSIÓN
211
BIBLIOGRAFÍA
213
• http://www.conabip.gob.ar/sites/default/files/comu
nicaciones/SAT/Guia_para_la_formulacion_y_pres
entacion_de_proyectos.pdf
• https://concepto.de/conclusion-de-un-proyecto
• https://es.scribd.com/document/316166475/Como-
Redactar-El-Titulo-de-Un-Proyecto
• www.academia.edu/8887467/Fundamentaci%C3%B
3n_y_Objetivos_de_un_Proyecto
• https://www.udemy.com/course/sql-curso-
completo-de-sql-aprende-desde-cero/
• www.academia.edu/8887467/Fundamentaci%C3%B
3n_y_Objetivos_de_un_Proyecto
• https://www.udemy.com/course/csharp_cursototal
_programador/?gclid=CjwKCA
ANEXO
215
receso cada 10 (diez) años a contar del presente retirándose de la sociedad y continuando
ésta con los restantes, debiendo comunicar su decisión mediante telegrama dirigido a la
SOFTWARE DE ADMNISTRACIÓN PARA “LA MILAGROSA” MILANESERÍA | INGENIEROS SOFTWARE
Escuela Superior Catalina Harriague de Castaños | 3ro EMT Informática
Sede social y a la sociedad con una antelación no menor a sesenta días a contar del
respectivo vencimiento.
NOVENO (Cesión de cuotas) – La cesión de cuotas se regirá por el régimen legal.
DÉCIMO (Toma de decisiones) – Las decisiones sociales se adoptarán conforme a lo
dispuesto por la normativa vigente.
DÉCIMO PRIMERO (Pacto de continuación) –En caso de fallecimiento o incapacidad de
cualquiera de los socios la sociedad se disolverá.
Si, es necesario.
#!/bin/bash
case $variable in
"Buscar Producto")
nombreproducto=$(zenity --entry --title="Ingrese ID del Producto" --
width=250 --height=160 --ok-label="Aceptar" --cancel-label="Cancelar" --
text="¿Cuál es el nombre del producto?")
read=$nombreproducto
echo "SELECT 'ID.Prod', Stock, Descripción, PrecioUnitario FROM
producto_venta where Descripcion='$nombreproducto'" | sudo mysql proyecto -N |
tr '\t' '\n' | zenity --list --title="Producto en venta" --text=" " --
column="ID.PROD" --column="Stock" --column="Descripcion" --column="Precio
Unitario" --height=180 --width=450;
;;
"Buscar Cliente")
nomcliente=$(zenity --entry \
--title="Ingrese ID" \
--width=250 \
--height=160 \
--ok-label="Aceptar" \
--cancel-label="Cancelar" \
--text="¿Cual es el nombre del cliente?")
read=$nomcliente
echo "SELECT 'ID.CLI', Nombre, Direccion, Telefono, Saldo FROM cliente where
Nombre='$nomcliente'" | sudo mysql proyecto -N | tr '\t' '\n' | zenity --list
--title="Cliente" --text=" " --column="ID Cliente" --column="Nombre" --
column="Direccion" --column="Telefono" --column="Saldo" --height=180 --
width=450;
;;
"Salir")
zenity --info --title="Saliendo..." --text="Adios"
;;
220
esac
Saluda atentamente,
https://github.com/luchoberaza/ingenierossoftware
SCRIPT ZENITY
https://github.com/luchoberaza/ingenierossoftware/blob/c73ce3b1efe60bc0b455
e0438b818a1407f13880/zenityproyecto.sh
222
https://drive.google.com/file/d/1S6PkqacXECrJ_1ZG2hbQvtTiqGCPbPU0/view?usp=s
hare_link
https://brunoguglielmone.wixsite.com/ingenieronsoftware
223