Exemplo n.º 1
0
        public bool Editar(vendedor ved)
        {
            bool val = false;

            using (siimnEntities bd = new siimnEntities())
            {
                try
                {
                    var query = bd.vendedor.Where(ven => ven.idvendedor == ved.idvendedor).First();
                    query.cedula         = ved.cedula;
                    query.nombrevendedor = ved.nombrevendedor;
                    query.tipo           = ved.tipo;
                    query.telefono       = ved.telefono;
                    query.emailvend      = ved.emailvend;
                    query.direcvend      = ved.direcvend;
                    query.activo         = ved.activo;
                    query.comisionrango  = ved.comisionrango;
                    query.comision       = ved.comision;
                    query.idcompania     = ved.idcompania;
                    bd.SaveChanges();
                    val = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(val);
        }
Exemplo n.º 2
0
        public void Eliminarvendedor(vendedor vendedor)
        {
            string Query = "DELETE FROM VENDEDOR WHERE ID_VENDEDOR = @IdVendedor";


            using (ComandoSQL = new SqlCommand())
            {
                ComandoSQL.CommandText = Query;
                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.Text;

                try
                {
                    ComandoSQL.Parameters.AddWithValue("@IdVendedor", vendedor.ID_VENDEDOR);
                    ComandoSQL.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    throw;
                }

                finally
                {
                    AccesoDatos.CerrarConexion();
                }
            }
        }
Exemplo n.º 3
0
            public void cargar()
            {
                vendedor    vende = new vendedor();
                encabezados tit   = new encabezados();

                Console.Clear();
                tit.patos();

                string nombre;
                string c = ",";
                string b = ",";
                int    cantidad;
                double precio;



                StreamWriter archivo = File.AppendText("inventario.txt");

                Console.WriteLine();
                Console.Write("nombre del producto: ");
                nombre = Console.ReadLine();

                Console.Write("ingrese la cantidad: ");
                cantidad = int.Parse(Console.ReadLine());

                Console.Write("ingrese precio del producto: ");
                precio = Double.Parse(Console.ReadLine());

                archivo.WriteLine(nombre + c + cantidad + b + precio);
                archivo.Close();

                Console.Clear();
                tit.patos();
                Console.WriteLine("producto agregado con exito");
            }
Exemplo n.º 4
0
        public void Actualizarvendedor(vendedor vendedor)
        {
            string Query = "UPDATE VENDEDOR SET NOMB_VENDEDOR =@NombVendedor," +
                           "COMISION = @Comision " +
                           "WHERE ID_VENDEDOR = @IdVendedor";


            using (ComandoSQL = new SqlCommand())
            {
                ComandoSQL.CommandText = Query;
                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.Text;

                try
                {
                    ComandoSQL.Parameters.AddWithValue("@IdVendedor", vendedor.ID_VENDEDOR);
                    ComandoSQL.Parameters.AddWithValue("@NombVendedor", vendedor.NOMB_VENDEDOR);
                    ComandoSQL.Parameters.AddWithValue("@Comision", vendedor.COMISION);

                    ComandoSQL.ExecuteNonQuery();
                }
                catch (Exception ex)
                {
                    throw;
                }

                finally
                {
                    AccesoDatos.CerrarConexion();
                }
            }
        }
Exemplo n.º 5
0
        private void BTNIngresar_Click(object sender, EventArgs e)
        {
            sisVdatos     sisV = new sisVdatos();
            SqlDataReader dr   = sisV.cargarlogin();

            while (dr.Read())
            {
                if (TBusuario.Text == dr["NombreUsuario"].ToString())
                {
                    if (TBcontraseña.Text == dr["contraseña"].ToString())
                    {
                        if (dr["tipoVendedor"].ToString() == "Administrador")
                        {
                            vendedor venAdmin = new vendedor();
                            venAdmin.estadoBTN      = true;
                            venAdmin.loginUsuario   = this;
                            venAdmin.cedulaVendedor = dr["cedula"].ToString();
                            venAdmin.Visible        = true;
                            this.Visible            = false;
                            return;
                        }
                        else
                        {
                            vendedor venNormal = new vendedor();
                            venNormal.loginUsuario   = this;
                            venNormal.cedulaVendedor = dr["cedula"].ToString();
                            venNormal.Visible        = true;
                            this.Visible             = false;
                            return;
                        }
                    }
                }
            }
            MessageBox.Show("Usuario o contraseña incorrecta");
        }
        private void toolStripLabel3_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtCodigo.Text))
            {
                if (Validar(txtComision.Text))
                {
                    var v = new vendedor
                    {
                        ID_VENDEDOR   = int.Parse(txtCodigo.Text),
                        NOMB_VENDEDOR = txtNombre.Text,
                        COMISION      = float.Parse(txtComision.Text)
                    };

                    vendedorBL.ActualizarVendedores(v);
                    MessageBox.Show("Vendedor actualizado con exito!");
                    toolStripLabel1_Click(null, null);
                    return;
                }
            }
            else
            {
                MessageBox.Show("debe de tener el codigo de vendedor");
                return;
            }
        }
Exemplo n.º 7
0
        public void InsertarVendedores(vendedor vendedor)
        {
            string Query = "INSERT INTO VENDEDOR VALUES (@NombVendedor," +
                           "@Comision)";


            using (ComandoSQL = new SqlCommand())
            {
                ComandoSQL.CommandText = Query;
                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.Text;

                try
                {
                    ComandoSQL.Parameters.AddWithValue("@NombVendedor", vendedor.NOMB_VENDEDOR);
                    ComandoSQL.Parameters.AddWithValue("@Comision", vendedor.COMISION);

                    ComandoSQL.ExecuteNonQuery();
                }
                catch (Exception)
                {
                    throw;
                }

                finally
                {
                    AccesoDatos.CerrarConexion();
                }
            }
        }
Exemplo n.º 8
0
        private void dataGridViewVendedor_DoubleClick(object sender, EventArgs e)
        {
            int vendedorid = Convert.ToInt32(dataGridViewVendedor.CurrentRow.Cells[0].Value);

            Vendedor          = vendedorBL.ObtenerVendedorPorId(vendedorid);
            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Exemplo n.º 9
0
 public void Modificar(vendedor obj)
 {
     using (var ctx = new HTGVentasMVCConect())
     {
         ctx.Entry(obj).State = System.Data.Entity.EntityState.Modified;
         ctx.SaveChanges();
     }
 }
Exemplo n.º 10
0
        }         //GravarVendedor

        private void selecionaVendedor()
        {
            ComboBoxItem cmbItem = new ComboBoxItem();

            cmbItem  = (ComboBoxItem)cmbNome.SelectedItem;
            veiculos = new Veiculos();
            veiculos.ArquivoConexao = sArquivoConexao;
            vendedor cVendedor = veiculos.pesquisaVendedor(int.Parse(cmbItem.Value.ToString()));

            exibirDadosVendedor(cVendedor);
        }//selecionaVendedor
 public ActionResult Update(vendedor obj)
 {
     if (ModelState.IsValid)
     {
         new VendedorManager().Modificar(obj);
         return(RedirectToAction("Index"));
     }
     else
     {
         return(View("Create", obj));
     }
 }
Exemplo n.º 12
0
        public bool Guardar(VendedorDataSource vend)
        {
            bool     val = false;
            vendedor ved = new vendedor();

            ved = this.CambiarTipoE(vend);
            try
            {
                val = this.persistencia.Guardar(ved);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(val);
        }
Exemplo n.º 13
0
        }//selecionaVendedor

        private void lostVendedor()
        {
            limparCampos(2);
            if (cmbNome.Text.Length > 0)
            {
                ComboBoxItem cmbItem = new ComboBoxItem();
                cmbItem = (ComboBoxItem)cmbNome.SelectedItem;
                if (cmbItem != null)
                {
                    veiculos = new Veiculos();
                    veiculos.ArquivoConexao = sArquivoConexao;
                    vendedor cVendedor = veiculos.pesquisaVendedor(int.Parse(cmbItem.Value.ToString()));
                    exibirDadosVendedor(cVendedor);
                }
            }
        }//lostVendedor
Exemplo n.º 14
0
        private vendedor CambiarTipoE(VendedorDataSource vend)
        {
            vendedor ved = new vendedor();

            ved.idvendedor     = vend.Codigo;
            ved.tipo           = vend.Tipo;
            ved.nombrevendedor = vend.Nombre;
            ved.cedula         = vend.Cedula;
            ved.telefono       = vend.Telefono;
            ved.emailvend      = vend.Email;
            ved.direcvend      = vend.Direccion;
            ved.activo         = vend.Activo;
            ved.comisionrango  = vend.ComisionR;
            ved.comision       = vend.Comision;
            return(ved);
        }
Exemplo n.º 15
0
        public VendedorDataSource DevolverVendedor(int codigvend)
        {
            VendedorDataSource vend   = new VendedorDataSource();
            vendedor           vendda = new vendedor();

            try
            {
                vendda = this.persistencia.DevolverVendedor(codigvend);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            vend = this.CambiarTipoT(vendda);
            return(vend);
        }
Exemplo n.º 16
0
    public static void Main(string[] args)
    {
        vendedor carlos = new vendedor(200.34, 1.34, "Carlos");
        veiculo  uno    = new veiculo("Fiat", 2020, 0, 50000);
        double   soma   = 0;

        mostruario secaoA = new mostruario(carlos);

        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);

        soma = secaoA.CalculaValor();
        Console.WriteLine("SOMA >> {0}", soma);
    }
Exemplo n.º 17
0
        private VendedorDataSource CambiarTipoT(vendedor vendda)
        {
            VendedorDataSource vend = new VendedorDataSource();

            vend.Compania  = vendda.idcompania;
            vend.Codigo    = vendda.idvendedor;
            vend.Tipo      = vendda.tipo = vendda.tipo;
            vend.Nombre    = vendda.nombrevendedor;
            vend.Cedula    = vendda.cedula;
            vend.Telefono  = vendda.telefono;
            vend.Email     = vendda.emailvend;
            vend.Direccion = vendda.direcvend;
            vend.Activo    = vendda.activo;
            vend.ComisionR = vendda.comisionrango;
            vend.Comision  = vendda.comision;

            return(vend);
        }
Exemplo n.º 18
0
        private void toolStripLabel4_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtCodigo.Text))
            {
                var mensaje = MessageBox.Show("Desea eliminar este registro", "Aviso", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (mensaje == DialogResult.Yes)
                {
                    var v = new vendedor {
                        ID_VENDEDOR = int.Parse(txtCodigo.Text)
                    };
                    vendedorBL.EliminarVendedores(v);
                    MessageBox.Show("El registro se ha eliminado correctamente!!");
                    toolStripLabel1_Click(null, null);
                    return;
                }
            }
        }
Exemplo n.º 19
0
        public vendedor DevolverVendedor(int codigvend)
        {
            vendedor vend = new vendedor();

            using (siimnEntities bd = new siimnEntities())
            {
                try
                {
                    var query = bd.vendedor.Where(ven => ven.idvendedor == codigvend).First();
                    vend = query;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            return(vend);
        }
Exemplo n.º 20
0
    public static void Main(string[] args)
    {
        double valor;
        string pend;
        int    ano;

        // veiculo v1 = new veiculo();
        // veiculo v2 = new veiculo(2020 , "Branco", 20000);
        veiculo  v3    = new veiculo(4, "preto", 2021, "SLK", 50000, "sim", "nao");
        vendedor vend1 = new vendedor(2500.50, 0.5);

        /* Console.WriteLine("Carro 1 : {0} {1} {2} {3} {4} {5} {6} ", v1.GetRodas(), v1.GetCor(), v1.GetAno(), v1.GetModelo(), v1.GetSeguro(), v1.GetPendencia(), v1.GetValor() );
         *
         * Console.WriteLine("Carro 2 : {0} {1} {2} {3} {4} {5} {6} ", v2.GetRodas(), v2.GetCor(), v2.GetAno(), v2.GetModelo(), v2.GetSeguro(), v2.GetPendencia(), v2.GetValor() );
         *
         * Console.WriteLine("Carro 3 : {0} {1} {2} {3} {4} {5} {6} ", v3.GetRodas(), v3.GetCor(), v3.GetAno(), v3.GetModelo(), v3.GetSeguro(), v3.GetPendencia(), v3.GetValor() );
         *
         *
         * Console.WriteLine("digite o valor do carro 1 : ");
         * valor = double.Parse(Console.ReadLine());
         * v1.SetValor(valor);
         *
         * Console.WriteLine("digite a pendencia do carro 1 : ");
         * pend = Console.ReadLine();
         * v1.SetPendencia(pend);
         *
         * Console.WriteLine("Carro 1 : {0} {1} {2} {3} {4} {5} {6} ", v1.GetRodas(), v1.GetCor(), v1.GetAno(), v1.GetModelo(), v1.GetSeguro(), v1.GetPendencia(), v1.GetValor() );*/

        Console.Write("Digite o ano para atualizar valor :   ");
        ano = int.Parse(Console.ReadLine());
        Console.Write("O valor do carro atualizado é :   R${0} ", v3.Atualiza(ano));
        Console.ReadLine();
        Console.Clear();

        v3.relatorio2();
        Console.ReadLine();
        Console.Clear();

        Console.Write("Digite o valor das vendas do vendedor :   ");
        valor = double.Parse(Console.ReadLine());
        Console.Write("O valor que o vendedor deve receber é :   R${0} ", vend1.receber(valor));
        Console.ReadLine();
        Console.Clear();
    }
Exemplo n.º 21
0
        public bool Guardar(vendedor ved)
        {
            bool val = false;

            using (siimnEntities bd = new siimnEntities())
            {
                try
                {
                    bd.vendedor.Add(ved);
                    bd.SaveChanges();
                    val = true;
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }

            return(val);
        }
Exemplo n.º 22
0
        private void toolStripLabel2_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(txtCodigo.Text))
            {
                MessageBox.Show("no se puede agregar un vendedor porque esta en modo edicion");
                return;
            }
            if (Validar(txtComision.Text))
            {
                vendedor v = new vendedor
                {
                    NOMB_VENDEDOR = txtNombre.Text,
                    COMISION      = float.Parse(txtComision.Text)
                };

                vendedorBL.InsertarVendedores(v);
                MessageBox.Show("El vendedor ha sido insertardo con exito!", "informacion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                toolStripLabel1_Click(null, null);
                return;
            }
        }
Exemplo n.º 23
0
        public vendedor ComprobarForanea(int ID_VENDEDOR)
        {
            vendedor v = new vendedor();

            string Query = "SELECT ID_VENDEDOR,NOMB_VENDEDOR,COMISION FROM VENDEDOR WHERE ID_VENDEDOR= @IdVendedor";


            using (ComandoSQL = new SqlCommand())
            {
                ComandoSQL.CommandText = Query;
                ComandoSQL.Connection  = AccesoDatos.ObtenerConexion();
                ComandoSQL.CommandType = CommandType.Text;

                try
                {
                    ComandoSQL.Parameters.AddWithValue("@IdVendedor", ID_VENDEDOR);

                    using (var lector = ComandoSQL.ExecuteReader(CommandBehavior.CloseConnection))
                    {
                        if (lector.Read())
                        {
                            v.ID_VENDEDOR   = lector.GetInt32(0);
                            v.NOMB_VENDEDOR = lector.GetString(1);
                            v.COMISION      = (float)Convert.ToDouble(2);
                        }

                        return(v);
                    }
                }
                catch (Exception)
                {
                    throw;
                }

                finally
                {
                    AccesoDatos.CerrarConexion();
                }
            }
        }
Exemplo n.º 24
0
    public static void Main(string[] args)
    {
        vendedor carlos = new vendedor("Carlos", 2000.34, 1.34);
        veiculo  uno    = new veiculo("Fiat", 2020, 0, 50000);

        mostruario secaoA = new mostruario(carlos);

        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);

        double soma = 0;

        for (int i = 0; i < secaoA.carros.Count; i++)
        {
            soma += secaoA.carros[i].getValor();
        }

        Console.WriteLine("SOMA >> {0}", soma);



        /* EXPLICACAO LISTA */
        List <int> meuNumeros = new List <int> {
            10, 20, 30, 40
        };

        meuNumeros.Add(100);
        Console.WriteLine(meuNumeros.Count);

        int tot = 0;

        for (int i = 0; i < meuNumeros.Count; i++)
        {
            //Console.WriteLine("Elemento {0} >> {1}", i, meuNumeros[i]);
            tot += meuNumeros[i];
        }
        Console.WriteLine(tot);
    }
Exemplo n.º 25
0
    public static void Main(string[] args)
    {
        vendedor   joao   = new vendedor("João", 20.3, 1.2);
        veiculo    uno    = new veiculo("fiat", 10, 50, 122864000.01);
        mostruario secaoA = new mostruario();
        exibirMenu menu   = new exibirMenu();

        secaoA.setRepresentante(joao);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        secaoA.carros.Add(uno);
        double total = 0;

        /* While (true) {
         * string resposta = "";
         * menu.menu();
         * Console.ReadLine("Escolha uma opção ou outra tecla para sair:")
         * resposta = Console.ReadLine();
         *
         * if (resposta == "1") {
         *   string modelo;
         *   string marca;
         *   int ano;
         *   int km;
         *   int valor;
         *
         *   veiculo modelo = new veiculo(marca,ano,km,valor);
         *
         * }
         *
         * };*/
        total = secaoA.calculaValor(total);
        Console.WriteLine("Valor total: {0}", total);
    }
Exemplo n.º 26
0
 public mostruario(vendedor goku)
 {
     Representante = goku;
     carros        = new List <veiculo>();
 }
Exemplo n.º 27
0
 public void setRepresentante(vendedor goku)
 {
     Representante = goku;
 }
Exemplo n.º 28
0
        public void ActualizarVendedores(vendedor entidad)
        {
            vendedorDAL Actualizar = new vendedorDAL();

            Actualizar.Actualizarvendedor(entidad);
        }
Exemplo n.º 29
0
        public void EliminarVendedores(vendedor entidad)
        {
            vendedorDAL Eliminar = new vendedorDAL();

            Eliminar.Eliminarvendedor(entidad);
        }
Exemplo n.º 30
0
        public void InsertarVendedores(vendedor entidad)
        {
            vendedorDAL Insertar = new vendedorDAL();

            Insertar.InsertarVendedores(entidad);
        }