Exemple #1
0
        public void AlterarDados(Comercio obj)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Db"].ConnectionString))
            {
                string strSQL = @"UPDATE CadastroComercio SET
                                    nomeComercio = @nomeComercio,
                                    cnpj = @cnpj,
                                    bairro = @bairro,
                                    rua = @rua,
                                    numero = @numero,
                                    cep = @cep,
                                    complemento = @complemento,
                                    estiloDoLanche = @estiloDoLanche,
                                    horarioAbertura = @horarioAbertura,
                                    horarioEnceramento = @horarioEnceramento,
                                    DescricaoComercio = @DescricaoComercio
                                 WHERE idCadComercio = @idCadComercio;";

                using (SqlCommand cmd = new SqlCommand(strSQL))
                {
                    cmd.Connection = conn;
                    cmd.Parameters.Add("@idCadComercio", SqlDbType.Int).Value          = obj.Id;
                    cmd.Parameters.Add("@nomeComercio", SqlDbType.VarChar).Value       = obj.NomeComercio;
                    cmd.Parameters.Add("@cnpj", SqlDbType.VarChar).Value               = obj.Cnpj;
                    cmd.Parameters.Add("@bairro", SqlDbType.VarChar).Value             = obj.Bairro;
                    cmd.Parameters.Add("@rua", SqlDbType.VarChar).Value                = obj.Rua;
                    cmd.Parameters.Add("@numero", SqlDbType.Int).Value                 = obj.Numero;
                    cmd.Parameters.Add("@cep", SqlDbType.VarChar).Value                = obj.Cep;
                    cmd.Parameters.Add("@complemento", SqlDbType.VarChar).Value        = obj.Complemento;
                    cmd.Parameters.Add("@estiloDoLanche", SqlDbType.VarChar).Value     = obj.EstiloDoLanche;
                    cmd.Parameters.Add("@horarioAbertura", SqlDbType.VarChar).Value    = obj.HorarioAbertura;
                    cmd.Parameters.Add("@horarioEnceramento", SqlDbType.VarChar).Value = obj.HorarioEncerramento;
                    cmd.Parameters.Add("@DescricaoComercio", SqlDbType.VarChar).Value  = obj.DescricaoComercio;

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    conn.Close();
                }
            }
        }
Exemple #2
0
        private static void TraerPorCategoria(Comercio c)
        {
            Console.WriteLine("Seleccione el codigo de categoria a listar: ");
            int cod = int.Parse(Console.ReadLine());


            List <int> lst = new List <int>();

            foreach (Repuesto r in c.Repuestos)
            {
                lst.Add(r.Categoria.Codigo);
            }

            if (!lst.Contains(cod))
            {
                Console.WriteLine("La categoria no pertenece a un respuesto del comercio.");
            }
            else
            {
                c.TraerPorCategoria(cod);
            }
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (!Comercio.ListaProductos.Any())
            {
                Comercio.PrecargaListaProductos();
            }

            if (!Comercio.ListaClientes.Any())
            {
                Comercio.PrecargaListaClientes();
            }

            if (!Comercio.ListaVentas.Any())
            {
                Comercio.PrecargaListaVentas();
            }

            splayer = new SoundPlayer(@"..\Sounds\cajaResgistradora.wav");
            this.menuStrip1.Visible  = false;
            dgvProductos.DataSource  = Comercio.ListaProductos;
            this.txbPrecioFinal.Text = "";
        }
Exemple #4
0
        public int Inserir(Comercio obj)
        {
            using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["Db"].ConnectionString))
            {
                string strSQL = @"INSERT INTO CadastroComercio (cnpj, nomeComercio, bairro, rua, numero, cep, complemento, nomeRepresentante, emailRepresentante, senhaRepresentante, 
                                                                  cpfRepresentante, telefoneRepresentante, estiloDoLanche, horarioAbertura, horarioEnceramento, DescricaoComercio) 
                                                          VALUES (@cnpj, @nomeComercio, @bairro, @rua, @numero, @cep, @complemento, @nomeRepresentante, @emailRepresentante, @senhaRepresentante, 
                                                                  @cpfRepresentante, @telefoneRepresentante, @estiloDoLanche, @horarioAbertura, @horarioEnceramento, @DescricaoComercio);
                                 SELECT SCOPE_IDENTITY();";

                using (SqlCommand cmd = new SqlCommand(strSQL))
                {
                    cmd.Connection = conn;
                    cmd.Parameters.Add("@cnpj", SqlDbType.VarChar).Value                  = obj.Cnpj;
                    cmd.Parameters.Add("@nomeComercio", SqlDbType.VarChar).Value          = obj.NomeComercio;
                    cmd.Parameters.Add("@bairro", SqlDbType.VarChar).Value                = obj.Bairro ?? string.Empty;
                    cmd.Parameters.Add("@rua", SqlDbType.VarChar).Value                   = obj.Rua ?? string.Empty;
                    cmd.Parameters.Add("@numero", SqlDbType.Int).Value                    = obj.Numero;
                    cmd.Parameters.Add("@cep", SqlDbType.VarChar).Value                   = obj.Cep ?? string.Empty;
                    cmd.Parameters.Add("@complemento", SqlDbType.VarChar).Value           = obj.Complemento ?? string.Empty;
                    cmd.Parameters.Add("@nomeRepresentante", SqlDbType.VarChar).Value     = obj.Nome ?? string.Empty;
                    cmd.Parameters.Add("@emailRepresentante", SqlDbType.VarChar).Value    = obj.Email ?? string.Empty;
                    cmd.Parameters.Add("@senhaRepresentante", SqlDbType.VarChar).Value    = obj.Senha ?? string.Empty;
                    cmd.Parameters.Add("@cpfRepresentante", SqlDbType.VarChar).Value      = obj.CpfRepresentante ?? string.Empty;
                    cmd.Parameters.Add("@telefoneRepresentante", SqlDbType.VarChar).Value = obj.TelefoneRepresentante ?? string.Empty;
                    cmd.Parameters.Add("@estiloDoLanche", SqlDbType.VarChar).Value        = obj.EstiloDoLanche ?? string.Empty;
                    cmd.Parameters.Add("@horarioAbertura", SqlDbType.VarChar).Value       = obj.HorarioAbertura ?? string.Empty;
                    cmd.Parameters.Add("@horarioEnceramento", SqlDbType.VarChar).Value    = obj.HorarioEncerramento ?? string.Empty;
                    cmd.Parameters.Add("@DescricaoComercio", SqlDbType.VarChar).Value     = obj.DescricaoComercio ?? string.Empty;

                    conn.Open();
                    obj.Id = Convert.ToInt32(cmd.ExecuteScalar());
                    conn.Close();

                    return(obj.Id);
                }
            }
        }
Exemple #5
0
 private void btnQuitar_Click(object sender, EventArgs e)
 {
     if (lstCarrito.Items.Count == 0)
     {
         MessageBox.Show("No hay productos en el carrito.");
     }
     else
     {
         ListView.SelectedListViewItemCollection productosARestar = lstCarrito.SelectedItems;
         int nroProducto;
         foreach (ListViewItem item in productosARestar)
         {
             nroProducto = int.Parse(item.SubItems[0].Text);
             Producto productoAgregadoAlCarrito = Comercio.ObtenerProductoPorId(nroProducto);
             Comercio.QuitarProductoACarrito(productoAgregadoAlCarrito);
             acumuladorSubtotal = (acumuladorSubtotal - productoAgregadoAlCarrito.Precio);
             Comercio.AgregarProductoAInventario(nroProducto, 1);
             ActualizarInventario();
         }
         lblNroSubtotal.Text = acumuladorSubtotal.ToString("#.##");
         ActualizarCarrito();
     }
 }
        public List <T> RetrieveAllDatosByComercioId <T>(int comercioId)
        {
            var      lstEmpleados = new List <T>();
            Comercio comercio     = new Comercio {
                Id = comercioId
            };

            var lstResult = dao.ExecuteQueryProcedure(mapper.GetRetriveAllDatosByComercioIdStatement(comercio));
            var dic       = new Dictionary <string, object>();

            if (lstResult.Count > 0)
            {
                foreach (var row in lstResult)
                {
                    var empleadoViewModel = new EmpleadoViewModel {
                        Id             = Convert.ToInt32(row["ID"]),
                        IdUsuario      = Convert.ToInt32(row["ID_USUARIO"]),
                        Cedula         = row["CEDULA"].ToString(),
                        UsuarioNombre  = row["USUARIO_NOMBRE"].ToString(),
                        Apellido       = row["APELLIDO"].ToString(),
                        Correo         = row["CORREO"].ToString(),
                        Telefono       = row["TELEFONO"].ToString(),
                        IdRol          = Convert.ToInt32(row["ID_ROL"]),
                        RolNombre      = row["ROL_NOMBRE"].ToString(),
                        IdSucursal     = Convert.ToInt32(row["ID_SUCURSAL"]),
                        SucursalNombre = row["SUCURSAL_NOMBRE"].ToString(),
                        IdComercio     = Convert.ToInt32(row["ID_COMERCIO"]),
                        NombreComercio = row["NOMBRE_COMERCIO"].ToString(),
                        Estado         = Convert.ToInt32(row["ESTADO"])
                    };

                    lstEmpleados.Add((T)Convert.ChangeType(empleadoViewModel, typeof(T)));
                }
            }

            return(lstEmpleados);
        }
 /// <summary>
 /// Al cerrar el formulario aborta los hilos y guarda las Ventas pendientes
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void FrmPrincipal_FormClosing(object sender, FormClosingEventArgs e)
 {
     CerrarNegocio();
     try
     {
         Comercio.GuardarVentasPendientesXml();
     }
     catch (ArchivoException miEx)
     {
         MessageBox.Show(miEx.Message,
                         "Error",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Warning);
         miEx.Guardar();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message,
                         "Error",
                         MessageBoxButtons.OK,
                         MessageBoxIcon.Warning);
         ex.Guardar();
     }
 }
        private void btn_AgregarProducto_Click(object sender, EventArgs e)
        {
            FrmAltaProducto frmAltaProducto = new FrmAltaProducto();

            if (frmAltaProducto.ShowDialog() == DialogResult.OK)
            {
                if (!Comercio.AgregarProducto(frmAltaProducto.MiProducto))
                {
                    MessageBox.Show("No se puede agregar un producto con un número de artículo ya existente.",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show($"Se agregó correctamente el artículo: \n\n {frmAltaProducto.MiProducto.ToString()}",
                                    "Éxito",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }

            RefrescarDgvProductos(Comercio.MisProductos);
        }
        private void FrmAltaEmpleado_Load(object sender, EventArgs e)
        {
            switch (this.Text)
            {
            case "Productos con menos de 10 unidades:":

                this.lblDatos.Text     = "PRODUCTOS:";
                this.richTbxDatos.Text = Comercio.Inventario.MostrarStockMenos10();
                break;

            case "Listado de Productos:":

                this.lblDatos.Text     = "PRODUCTOS:";
                this.richTbxDatos.Text = Comercio.Inventario.MostrarStock();
                break;

            case "Listado de Compras:":

                this.lblDatos.Text     = "COMPRAS:";
                this.richTbxDatos.Text = Comercio.MostrarCompras();
                break;


            case "Listado de Clientes:":

                this.lblDatos.Text     = "CLIENTES:";
                this.richTbxDatos.Text = Comercio.MostrarPersonas("clientes");
                break;

            case "Listado de Empleados:":

                this.lblDatos.Text     = "EMPLEADOS:";
                this.richTbxDatos.Text = Comercio.MostrarPersonas("empleados");
                break;
            }
        }
        private void btn_AgregarCliente_Click(object sender, EventArgs e)
        {
            FrmAltaCliente frmAltaCliente = new FrmAltaCliente();

            if (frmAltaCliente.ShowDialog() == DialogResult.OK)
            {
                if (!Comercio.AgregarCliente(frmAltaCliente.MiCliente))
                {
                    MessageBox.Show("No se puede agregar un cliente con un número de dni ya existente.",
                                    "Error",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Warning);
                }
                else
                {
                    MessageBox.Show("Se agregó correctamente",
                                    "Éxito",
                                    MessageBoxButtons.OK,
                                    MessageBoxIcon.Information);
                }
            }

            RefrescarDgvClientes(Comercio.MisClientes);
        }
        /// <summary>
        /// IMPLEMENTACION DE BD, EVENTOS, ARCHIVOS.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnConfirmarCompra_Click(object sender, EventArgs e)
        {
            if (ventaParcial.Carrito.Count > 0)
            {
                ventaParcial.Ticket = miComercio.Ventas.Count;
                Venta ventaConfirmada = NuevaVenta.Invoke(miComercio, ventaParcial);
                Comercio.Guardar(ventaConfirmada);

                ProductoDB.ActualizarStockProducto(ventaConfirmada.Carrito);

                miComercio.Inventario = ProductoDB.TraerProductos();
                listaAuxiliar.Clear();
                ventaParcial.Carrito.Clear();

                CargarListaProducto();

                LimpiarPantalla();
                MessageBox.Show("Su venta fue registrada correctamente.");
            }
            else
            {
                MessageBox.Show("El carrito esta vacio.");
            }
        }
Exemple #12
0
        private static void QuitarStock(Comercio c)
        {
            Console.WriteLine("Seleccione el codigo de repuesto a quitarle stock: ");
            int cod = int.Parse(Console.ReadLine());

            Console.WriteLine("Seleccione la cantidad de stock a quitar: ");
            int cant = int.Parse(Console.ReadLine());

            List <int> lst = new List <int>();

            foreach (Repuesto r in c.Repuestos)
            {
                lst.Add(r.Codigo);
            }

            if (!lst.Contains(cod))
            {
                Console.WriteLine("El repuesto no pertenece al Comercio.");
            }
            else
            {
                c.QuitarStock(cod, cant);
            }
        }
Exemple #13
0
        private static void ModificarPrecio(Comercio c)
        {
            Console.WriteLine("Seleccione el codigo de repuesto a modificar el precio: ");
            int cod = int.Parse(Console.ReadLine());

            Console.WriteLine("Seleccione el nuevo precio: ");
            double p = double.Parse(Console.ReadLine());

            List <int> lst = new List <int>();

            foreach (Repuesto r in c.Repuestos)
            {
                lst.Add(r.Codigo);
            }

            if (!lst.Contains(cod))
            {
                Console.WriteLine("El repuesto no pertenece al Comercio.");
            }
            else
            {
                c.ModificarPrecio(cod, p);
            }
        }
Exemple #14
0
        private void btnRealizarCompra_Click(object sender, EventArgs e)
        {
            if (cmbClientes.SelectedItem == null || txtPersonaResponsable.Text == "")
            {
                MessageBox.Show("Revise los datos faltantes.");
            }
            else
            {
                if (cmbEnvio.SelectedIndex == 0 && (txtCalle.Text == "" || txtAltura.Text == ""))
                {
                    MessageBox.Show("Revise los datos faltantes.");
                }
                else
                {
                    DateTime fechaHora = new DateTime();
                    fechaHora = DateTime.Now;
                    int          idCliente = cmbClientes.SelectedIndex;
                    int          nroCompra = Comercio.RegistrarNuevaCompra(int.Parse(datosEmpleado[0]), idCliente, Comercio.Carrito);
                    int          nroEnvio;
                    StreamWriter sw = File.CreateText($"Ticket Nro{nroCompra}.txt");
                    sw.WriteLine("Kwik-E-Mart - Recibo X");
                    sw.WriteLine("---------------------------");
                    sw.WriteLine($"{fechaHora}");
                    sw.WriteLine("---------------------------");
                    sw.WriteLine($"Usted ha sido atendido por: {lblDataNombreVendedor.Text} {lblDataApellidoVendedor.Text}");
                    sw.WriteLine("---------------------------");
                    sw.WriteLine($"Cliente: {cmbClientes.SelectedItem.ToString()}");
                    sw.WriteLine("---------------------------");
                    sw.WriteLine("Producto Nro Descripcion Cantidad PrecioU Subtotal");
                    foreach (Producto item in Comercio.Carrito)
                    {
                        sw.WriteLine($"{item.NroProducto} {item.Descripcion} {item.Cantidad} {item.Precio} {item.Subtotal}");
                    }
                    switch (cmbEnvio.SelectedIndex)
                    {
                    case 0:
                        nroEnvio = Comercio.EnvioADomicilio.Count;
                        EnvioADomicilio aDomicilio = new EnvioADomicilio(nroEnvio, nroCompra, txtPersonaResponsable.Text, txtCalle.Text, int.Parse(txtAltura.Text), envio);
                        Comercio.AgregarEnvioDomicilio(aDomicilio);
                        sw.WriteLine(aDomicilio.ObtenerEnvio());
                        break;

                    case 1:
                        nroEnvio = Comercio.EnvioRetLocal.Count;
                        EnvioRetLocal retiraEnLocal = new EnvioRetLocal(nroEnvio, nroCompra, txtPersonaResponsable.Text);
                        Comercio.AgregarRetiroEnLocal(retiraEnLocal);
                        sw.WriteLine(retiraEnLocal.ObtenerEnvio());
                        break;

                    default:
                        break;
                    }
                    sw.WriteLine("---------------------------");
                    sw.WriteLine($"Subtotal: {subTotal.ToString("#.##")}");
                    sw.WriteLine($"Descuentos: {descuento.ToString("#.##")}");
                    sw.WriteLine($"Total: {total.ToString("#.##")}");
                    sw.WriteLine("---------------------------");
                    sw.WriteLine("Gracias, vuelva prontossss!");
                    sw.WriteLine("---------------------------");
                    sw.Close();
                    System.Diagnostics.Process.Start($"Ticket Nro{nroCompra}.txt");
                    SoundPlayer sp = new SoundPlayer($"{path}\\resources\\audio\\CompraFinalizada.wav");
                    sp.Play();
                    MessageBox.Show($"Gracias, vuelva prontossss!");
                    Close();
                }
            }
        }
Exemple #15
0
 /// <summary>
 /// Constructor que obtiene la instancia del comercio
 /// </summary>
 /// <param name="c"></param>
 public FrmAgregarCliente(Comercio c) : this()
 {
     this.comercio = c;
 }
 public void AgregarArchivoComercio(Comercio comercio)
 {
     comercioFactory.CrearArchivo(comercio);
 }
 public void ModificarEstadoComercio(Comercio comercio)
 {
     comercioFactory.UpdateState(comercio);
 }
 public void EliminarComercio(Comercio comercio)
 {
     comercioFactory.Delete(comercio);
 }
 public void ModificarComercio(Comercio comercio)
 {
     comercioFactory.Update(comercio);
 }
Exemple #20
0
        static void Main(string[] args)
        {
            bool continuarActivo = true;

            string menu = "1) Agregar Repuesto \n2) Quitar Repuesto \n3) Modificar precio de repuesto " +
                          "\n4) Agregar Stock \n5) Quitar Stock \n6) Traer repuestos de una categoria \n7) Limpiar Consola \nX) Salir";

            Comercio c = new Comercio("Wonderland", "Calle Falsa 123");

            Console.WriteLine("Bienvenido a " + c.NombreComercio);

            do
            {
                Console.WriteLine(menu);

                try
                {
                    string opcionSeleccionada = Console.ReadLine();


                    if (ConsolaHelper.EsOpcionValida(opcionSeleccionada, "1234567X"))
                    {
                        if (opcionSeleccionada.ToUpper() == "X")
                        {
                            continuarActivo = false;
                            continue;
                        }

                        switch (opcionSeleccionada)
                        {
                        case "1":
                            Program.AgregarRepuesto(c);
                            break;

                        case "2":
                            Program.QuitarRepuesto(c);
                            break;

                        case "3":
                            Program.ModificarPrecio(c);
                            break;

                        case "4":
                            Program.AgregarStock(c);
                            break;

                        case "5":
                            Program.QuitarStock(c);
                            break;

                        case "6":
                            Program.TraerPorCategoria(c);
                            break;

                        case "7":
                            Console.Clear();
                            break;

                        default:
                            Console.WriteLine("Opción inválida.");
                            break;
                        }
                    }

                    else
                    {
                        Console.WriteLine("Opción inválida.");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Error durante la ejecución del comando. Por favor intente nuevamente. Mensaje: " + ex.Message);
                }
                Console.WriteLine("Ingrese una tecla para continuar.");

                Console.ReadKey();
                Console.Clear();
            }while (continuarActivo);

            Console.ReadKey();
        }
 public List <Comercio> ObtenerTodoComercio(Comercio comercio)
 {
     return(comercioFactory.RetrieveAll <Comercio>(comercio));
 }
 public void CrearComercio(Comercio comercio)
 {
     comercioFactory.Create(comercio);
 }
 public void Cadastrar(Comercio NovoComercio)
 {
     ctx.Comercio.Add(NovoComercio);
     ctx.SaveChanges();
 }
        protected void btnProximoCad3_Click(object sender, EventArgs e)
        {
            var obj = new Comercio();

            obj.Id                    = Convert.ToInt32(Request.QueryString["id"]);
            obj.Nome                  = txtNomeCompleto.Text;
            obj.Email                 = txtEmail.Text;
            obj.Senha                 = txtSenha.Text;
            obj.CpfRepresentante      = txtCPF.Text;
            obj.TelefoneRepresentante = txtCelular.Text;

            if (string.IsNullOrWhiteSpace(obj.Nome))
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O campo Nome deve ser preenchido";
                txtNomeCompleto.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(obj.Email))
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O campo Email deve ser preenchido";
                txtEmail.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(obj.Senha))
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O campo Senha deve ser preenchido";
                txtSenha.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(obj.CpfRepresentante))
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O campo Cpf deve ser preenchido";
                txtCPF.Focus();
                return;
            }

            if (string.IsNullOrWhiteSpace(obj.TelefoneRepresentante))
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O campo Celular deve ser preenchido";
                txtCelular.Focus();
                return;
            }

            var vdCpf = new ComercioDAO().ValidarCPF(txtCPF.Text);

            if (vdCpf == false)
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O Cpf é Invalido";
                txtCPF.Focus();
                return;
            }

            var vdEmail = new ComercioDAO().ValidarEmail(txtEmail.Text);

            if (vdEmail == false)
            {
                pnlMSG.Visible = true;
                lblMSG.Text    = "O Email é Invalido";
                txtEmail.Focus();
                return;
            }

            new ComercioDAO().Atualizar3(obj);

            Response.Redirect(string.Format("CadastroAnunciante4.aspx?id={0}", obj.Id));
        }
 public void AgregarComercio(Comercio comercio)
 {
     db.Comercios.Add(comercio);
     db.SaveChanges();
 }
 public NotificationResult Salvar(Comercio entidade)
 {
     return(comercioServico.Salvar(entidade));
 }
        /// <summary>
        /// Hace la compra del producto
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Btn_Comprar_Click_1(object sender, EventArgs e)
        {
            double suma        = 0;
            double numeroCelda = 0;
            string productoCelda;
            double sumaSimpson = 0;

            string[]       arreglo;
            string[]       usuarioConectado = new string[2];
            frm_Login_Prin formLogin        = new frm_Login_Prin();
            bool           retorno          = false;
            SoundPlayer    sonido;

            string[] nombreProducto   = new string[nuevosProductos.Count];
            int[]    unidadesProducto = new int[nuevosProductos.Count];

            for (int i = 0; i < dGV_Prod_Comp.RowCount - 1; i++)
            {
                if (dGV_Prod_Comp.Rows[i].Cells[1].Value != null && dGV_Prod_Comp.Rows[i].Cells[0].Value != null &&
                    Validaciones.ValidoCelda(dGV_Prod_Comp.Rows[i].Cells[1].Value.ToString()))
                {
                    double.TryParse(dGV_Prod_Comp.Rows[i].Cells[1].Value.ToString(), out numeroCelda);
                    productoCelda = dGV_Prod_Comp.Rows[i].Cells[0].Value.ToString();
                    for (int j = 0; j < nuevosProductos.Count; j++)
                    {
                        if (productoCelda == nuevosProductos[j].Nombre)
                        {
                            if (Comercio.ValidoUnidadesComprar(productoCelda, numeroCelda))
                            {
                                nombresProductos.Add(nuevosProductos[j].Nombre);
                                nombreProducto[j]   = nuevosProductos[j].Nombre;
                                unidadesProducto[j] = (int)numeroCelda;
                                numeroCelda         = numeroCelda * nuevosProductos[j].Precio;
                                suma    = suma + numeroCelda;
                                retorno = true;
                            }
                            else
                            {
                                MessageBox.Show("supera las unidades en stock");
                            }
                        }
                    }
                }
                else
                {
                    break;
                }
            }
            if (retorno == true)
            {
                usuarioConectado = Comercio.retornoUsuarioYContraseña();
                for (int i = 0; i < usuarioConectado.Length; i++)
                {
                    if (i == 0)
                    {
                        clienteCompra.Usuario = usuarioConectado[0];
                    }
                    else if (i == 1)
                    {
                        clienteCompra.Contraseña = usuarioConectado[1];
                        break;
                    }
                }
                clienteCompra = Comercio.buscoClienteYLoretorno(clienteCompra);

                arreglo = lbl_Nombre_Empleado.Text.Split();
                for (int i = 0; i < arreglo.Length; i++)
                {
                    if (i == 0)
                    {
                        empleadoCompra.Nombre = arreglo[0];
                    }
                    else if (i == 1)
                    {
                        empleadoCompra.Apellido = arreglo[1];
                        break;
                    }
                    else if (i == 2)
                    {
                        empleadoCompra.Legajo = arreglo[2];
                        break;
                    }
                }
                empleadoCompra = Comercio.buscoEmpleadoYLoretorno(empleadoCompra);
                if (clienteCompra.Apellido == "simpson")
                {
                    sumaSimpson = Comercio.descuentoSimpson(suma);
                    nuevaCompra = new Compra(empleadoCompra, clienteCompra, sumaSimpson, nombresProductos);
                    sonido      = new SoundPlayer(Application.StartupPath + @"\musica\compraSimpson.wav");
                    sonido.Play();
                }
                else
                {
                    nuevaCompra = new Compra(empleadoCompra, clienteCompra, suma, nombresProductos);
                    sonido      = new SoundPlayer(Application.StartupPath + @"\musica\graciasVuelva.wav");
                    sonido.Play();
                    MessageBox.Show("Graciass!!! Vuelva Prontosss");
                }
                for (int i = 0; i < nuevosProductos.Count; i++)
                {
                    if (nombreProducto[i] == nuevosProductos[i].Nombre)
                    {
                        nuevosProductos[i].Stock = nuevosProductos[i].Stock - unidadesProducto[i];
                    }
                }
                this.iBtn_Descarga_Arch.Visible = true;
            }
            else
            {
                MessageBox.Show("Hubo un error al hacer la compra.\nREINTENTE");
            }
        }
 public Comercio ObtenerComercio(Comercio comercio)
 {
     return(comercioFactory.Retrieve <Comercio>(comercio));
 }
        /// <summary>
        /// Muestra legajo en el form
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Frm_Agregar_Empleado_Load(object sender, EventArgs e)
        {
            string legajo = Comercio.generoLegajoEmpleadoNuevo();

            lbl_Legajo_Emp.Text = legajo;
        }
 public NotificationResult Excluir(Comercio entidade)
 {
     return(comercioServico.Excluir(entidade));
 }