Ejemplo n.º 1
0
        public bool registrarFactura(Entities.Producto pro, Entities.Cliente cli, Entities.Vendedor ven, int cantidad)
        {
            int estado = 0;
            //rel = obtenerRel();
            SqlConnection c = con.getConexion();

            String sql = "INSERT INTO detalleFactura (facEstado, codigoProd, cantidadProd, usuarioVen, cliDocumento, facRel) VALUES (@estado, @codigo, @cantidad, @vendedor, @cliente, @rel)";

            try
            {
                SqlCommand comando = new SqlCommand(sql, c);
                comando.Parameters.AddWithValue("@estado", estado);
                comando.Parameters.AddWithValue("@codigo", pro.Codigo);
                comando.Parameters.AddWithValue("@cantidad", cantidad);
                comando.Parameters.AddWithValue("@vendedor", ven.User);
                comando.Parameters.AddWithValue("@cliente", cli.Documento);
                comando.Parameters.AddWithValue("@rel", rel);
                comando.ExecuteNonQuery();
                registrarVentas(pro.Codigo, cantidad);

                return(true);
            }catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                c.Close();
            }
        }
Ejemplo n.º 2
0
        private void btnDeleteCli_Click(object sender, EventArgs e)
        {
            if (this.txtDocDel.Text == "")
            {
                MessageBox.Show("Escoja un Cliente");
            }
            else
            {
                String documento = this.txtDocDel.Text;

                Entities.Cliente cli = new Entities.Cliente();
                cli.Documento = documento;

                if (controller.eliminarCliente(cli))
                {
                    MessageBox.Show("Cliente Eliminado");
                    limiparDel();
                    actualizarGrid();
                }
                else
                {
                    MessageBox.Show("Error al eliminar cliente");
                }
            }
        }
Ejemplo n.º 3
0
        private void btnAgregarFac_Click(object sender, EventArgs e)
        {
            Entities.Producto p = (Entities.Producto) this.cbxFacProd.SelectedItem;
            if (p.Cantidad > 0)
            {
                Entities.Cliente  c  = (Entities.Cliente) this.cbxCliFac.SelectedItem;
                Entities.Vendedor ve = (Entities.Vendedor) this.cbxFacVen.SelectedItem;
                int cant             = Convert.ToInt32(this.numCan.Value);



                if (ve.User == "Seleccione el vendedor")
                {
                    MessageBox.Show("Seleccione el vendedor");
                }
                else
                {
                    if (this.numCan.Value != 0)
                    {
                        if (controller.registrarFactura(p, c, ve, cant))
                        {
                            MessageBox.Show("Produto Registrado");
                            double valT = Convert.ToDouble(this.txtValProd.Text);
                            this.gridFactura.DataSource = controller.gridFacturando();
                            sum = sum + (Convert.ToDouble(this.txtValProd.Text));
                            this.txtValTotal.Text = sum.ToString();
                        }
                        else
                        {
                            MessageBox.Show("Error al registrar producto");
                        }
                    }
                }
            }
        }
Ejemplo n.º 4
0
        //----------------------------------
        //Clientes

        //cliNumero, cliDocumento, cliNombre, cliDireccion, cliTelefono, cliCorreo
        public bool registrarCliente(Entities.Cliente cli)
        {
            SqlConnection c = con.getConexion();

            String sql = "INSERT INTO dbo.clientes (cliDocumento, cliNombre, cliDireccion, cliTelefono, cliCorreo) VALUES (@documento, @nombre, @direccion, @telefono, @correo)";

            try
            {
                SqlCommand comando = new SqlCommand(sql, c);
                comando.Parameters.AddWithValue("@documento", cli.Documento);
                comando.Parameters.AddWithValue("@nombre", cli.Nombre);
                comando.Parameters.AddWithValue("@direccion", cli.Direccion);
                comando.Parameters.AddWithValue("@telefono", cli.Telefono);
                comando.Parameters.AddWithValue("@correo", cli.Correo);
                comando.ExecuteNonQuery();
                return(true);
            }catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                c.Close();
            }
        }
Ejemplo n.º 5
0
        //cliNumero, cliDocumento, cliNombre, cliDireccion, cliTelefono, cliCorreo
        public bool actualizarCliente(Entities.Cliente cli)
        {
            SqlConnection c = con.getConexion();

            String sql = "UPDATE clientes SET cliDocumento = @documento, cliNombre = @nombre, cliDireccion = @direccion, cliTelefono = @telefono, cliCorreo = @correo WHERE cliNumero = @numero";

            try
            {
                SqlCommand comando = new SqlCommand(sql, c);
                comando.Parameters.AddWithValue("@documento", cli.Documento);
                comando.Parameters.AddWithValue("@nombre", cli.Nombre);
                comando.Parameters.AddWithValue("@direccion", cli.Direccion);
                comando.Parameters.AddWithValue("@telefono", cli.Telefono);
                comando.Parameters.AddWithValue("@correo", cli.Correo);
                comando.Parameters.AddWithValue("@numero", cli.Numero);
                comando.ExecuteNonQuery();
                return(true);
            }catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                c.Close();
            }
        }
Ejemplo n.º 6
0
        private void CboCliente_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cboCliente.SelectedIndex != -1)
            {
                cliente_seleccionado = service.consultarCliente((int)cboCliente.SelectedValue);

                if (cliente_seleccionado != null)
                {
                    txtDOC.Text  = cliente_seleccionado.tipoDoc + " - " + cliente_seleccionado.nroDoc.ToString();
                    txtPlan.Text = cliente_seleccionado.plan;
                }
            }
        }
Ejemplo n.º 7
0
        private Entities.Cliente CargarEntity(Entities.Cliente entity)
        {
            entity.nombre   = TxtNombre.Text;
            entity.apellido = TxtApellido.Text;
            entity.fk_id_tipo_doc_identidad = (int)ddlTipoDoc.SelectedValue;
            entity.num_documento            = TxtDocumento.Text;
            entity.fecha_nacimiento         = dtpNacimiento.Value;
            entity.direccion = txtDireccion.Text;
            entity.telefono  = txtTel.Text;
            entity.mail      = txtMail.Text;

            return(entity);
        }
Ejemplo n.º 8
0
        public async Task Salvar(Cliente cliente)
        {
            var entity = new Entities.Cliente()
            {
                Id    = cliente.Id,
                Nome  = cliente.Nome,
                Cpf   = cliente.Cpf,
                Senha = cliente.Senha
            };

            await context.Clientes.AddAsync(entity);

            await context.SaveChangesAsync();
        }
Ejemplo n.º 9
0
        public async Task <GenericCommandResult> Handle(NewClienteCommand request, CancellationToken cancellationToken)
        {
            var validator = new NewClienteValidator();
            var results   = validator.Validate(request);

            if (!results.IsValid)
            {
                return(GenericCommandResult.Failure(results.Errors));
            }
            var cliente = new Entities.Cliente(request.Nome, request.Idade);
            await _clientRepository.Create(cliente);

            return(GenericCommandResult.Success(cliente));
        }
 private void metroGrid1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
 {
     try
     {
         Entities.Cliente cli = bll.GetById(GetId());
         contrato.Ejecutar(cli);
     }
     catch (Exception ex)
     {
         InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Error, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Error carga de datos", ex.StackTrace, ex.Message));
         Notifications.FrmError.ErrorForm(Language.SearchValue("errorBuscarDatos") + "\n" + ex.Message);
     }
     this.Close();
 }
Ejemplo n.º 11
0
        private void gridElimCli_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            String val = gridElimCli.CurrentCell.Value.ToString();

            Entities.Cliente cliente = controller.agregarObjetoCliente(val);

            try
            {
                this.txtNomDel.Text    = cliente.Nombre;
                this.txtDocDel.Text    = cliente.Documento;
                this.txtNumeroDel.Text = Convert.ToString(cliente.Numero);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Seleccione el número del cliente");
            }
        }
Ejemplo n.º 12
0
        private void gridCliUp_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            String val = gridCliUp.CurrentCell.Value.ToString();

            Entities.Cliente cli = controller.agregarObjetoCliente(val);
            try
            {
                this.txtNumUp.Text = Convert.ToString(cli.Numero);
                this.txtDocUp.Text = cli.Documento;
                this.txtNomUp.Text = cli.Nombre;
                this.txtTelUp.Text = cli.Telefono;
                this.txtDirUp.Text = cli.Direccion;
                this.txtCorUp.Text = cli.Correo;
            }catch (Exception ex)
            {
                MessageBox.Show("Seleccione el número del cliente");
            }
        }
Ejemplo n.º 13
0
 public static bool CambiaClave(Entities.Cliente cliente, string password, string correo)
 {
     try
     {
         var database = DatabaseFactory.CreateDatabase();
         var cmd      = database.GetStoredProcCommand("UpdPasswordCliente");
         database.AddInParameter(cmd, "id", DbType.Decimal, cliente.Id);
         database.AddInParameter(cmd, "pass", DbType.String, password);
         database.AddInParameter(cmd, "correo", DbType.String, correo);
         database.ExecuteNonQuery(cmd);
         return(true);
     }
     catch (Exception exception)
     {
         //insertar log de error
         Log.InsLog("Cliente", "CambiaClave", exception.Message);
         return(false);
     }
 }
Ejemplo n.º 14
0
 private void CargaDatosEnForm()
 {
     try
     {
         entity                   = bll.GetById(Convert.ToInt32(id));
         TxtNombre.Text           = entity.nombre;
         TxtApellido.Text         = entity.apellido;
         ddlTipoDoc.SelectedValue = entity.fk_id_tipo_doc_identidad;
         TxtDocumento.Text        = entity.num_documento;
         dtpNacimiento.Text       = entity.fecha_nacimiento.ToString();
         txtDireccion.Text        = entity.direccion;
         txtTel.Text              = entity.telefono;
         txtMail.Text             = entity.mail;
     }
     catch (Exception ex)
     {
         InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Error, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Error carga de datos", ex.StackTrace, ex.Message));
         Notifications.FrmError.ErrorForm(Language.SearchValue("errorBuscarDatos") + "\n" + ex.Message);
     }
 }
Ejemplo n.º 15
0
        private void BtnCargar_Click(object sender, EventArgs e)
        {
            Entities.Cliente cliente = new Entities.Cliente();
            cliente.DNI       = txtDNI.Text;
            cliente.NOMBRE    = txtNOMBRE.Text;
            cliente.APELLIDO  = txtAPELLIDO.Text;
            cliente.DIRRECIOn = txtDIRECCION.Text;
            cliente.TELEFONO  = txtTELEFONO.Text;
            cliente.EMAIL     = txtEMAIL.Text;
            bool state = cliente_action.Create(cliente);

            if (state)
            {
                MessageBox.Show("El cliente fue agregado correctamente.", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("El cliente no pudo ser cargado correctamente.", "Guardar", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 16
0
 private void BtnBUSCAR_Click(object sender, EventArgs e)
 {
     try
     {
         Entities.Cliente cliente = cliente_action.Read(txtDNI.Text);
         //txtBuscarDNI.Text
         txtDNI.Text = cliente.DNI;
         if (txtDNI.Text != null)
         {
             txtNOMBRE.Text    = cliente.NOMBRE;
             txtAPELLIDO.Text  = cliente.APELLIDO;
             txtDIRECCION.Text = cliente.DIRRECIOn;
             txtTELEFONO.Text  = cliente.TELEFONO;
             txtEMAIL.Text     = cliente.EMAIL;
         }
     }
     catch
     {
         MessageBox.Show("El cliente no existe", "Mostrar cliente", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Ejemplo n.º 17
0
 private void CargaDatosEnForm(int id)
 {
     try
     {
         entity = bll.GetById(Convert.ToInt32(id));
         lblNombreValue.Text    = entity.nombre;
         lblApellidoValue.Text  = entity.apellido;
         lblTipoDocValue.Text   = entity.doc_identidad;
         lblDocValue.Text       = entity.num_documento;
         lblFechaValue.Text     = entity.fecha_nacimiento.Date.ToString();
         lblDireccionValue.Text = entity.direccion;
         lblTelValue.Text       = entity.telefono;
         lblMailValue.Text      = entity.mail;
         lblEdadValue.Text      = entity.edad.ToString();
     }
     catch (Exception ex)
     {
         InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Error, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Error carga de datos", ex.StackTrace, ex.Message));
         Notifications.FrmError.ErrorForm(Language.SearchValue("errorBuscarDatos") + "\n" + ex.Message);
     }
 }
        public IActionResult Post(Entities.Cliente eEntidad)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            bool resul = _Cliente.Guardar(eEntidad);

            if (resul)
            {
                return(Ok(new
                {
                    Mensaje = "Se inserto correctamente!!!",
                    Cliente = eEntidad
                }));
            }
            else
            {
                return(BadRequest("Erro al crear una nueva persona"));
            }
        }
Ejemplo n.º 19
0
        public bool eliminarCliente(Entities.Cliente cli)
        {
            SqlConnection c = con.getConexion();

            String sql = "DELETE FROM dbo.clientes WHERE cliDocumento = @doc";

            try
            {
                SqlCommand comando = new SqlCommand(sql, c);
                comando.Parameters.AddWithValue("@doc", cli.Documento);
                Console.WriteLine(cli.Documento);
                comando.ExecuteNonQuery();
                return(true);
            }catch (Exception ex)
            {
                return(false);
            }
            finally
            {
                c.Close();
            }
        }
        public IActionResult Put(Entities.Cliente eEntidad)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            bool resul = _Cliente.Modificar(eEntidad);

            if (resul)
            {
                return(Ok(new
                {
                    Mensaje = "Se actulizo correctamente!!",
                    Cliente = eEntidad
                }));
            }
            else
            {
                return(BadRequest("Erro al modificar una persona"));
            }
        }
Ejemplo n.º 21
0
 public async Task Update(Entities.Cliente cliente)
 {
     _context.Entry(cliente).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 22
0
 public void AddCliente(Entities.Cliente cliente)
 {
     _session.SaveOrUpdate(cliente);
 }
Ejemplo n.º 23
0
 public async Task Delete(Entities.Cliente cliente)
 {
     _context.Clientes.Remove(cliente);
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 24
0
        private void BtnGuardar_Click(object sender, EventArgs e)
        {
            if (id == null)
            {
                entity = new Entities.Cliente();
            }

            CargarEntity(entity);

            var  validation = new Helps.DataValidations(entity).Validate();
            bool valid      = validation.Item1;

            if (valid == true)
            {
                if (id == null)
                {
                    try
                    {
                        entity = bll.Insert(entity);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Insert, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Cliente: " + entity.num_documento, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("guardadoOK"));

                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == EValidaciones.existe)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorExiste"));
                        }
                        else if (ex.Message == EValidaciones.menor)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorMenor"));
                        }
                        else
                        {
                            InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.InsertError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Cliente: " + entity.num_documento, ex.StackTrace, ex.Message));
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("guardadoError") + "\n" + ex.Message);
                        }
                    }
                }
                else
                {
                    try
                    {
                        bll.Update(entity);

                        InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.Update, 1, this.GetType().FullName, MethodInfo.GetCurrentMethod().Name, "Cliente: " + entity.num_documento, "", ""));

                        Notifications.FrmSuccess.SuccessForm(Helps.Language.SearchValue("editadoOK"));

                        this.Close();
                    }
                    catch (Exception ex)
                    {
                        if (ex.Message == EValidaciones.existe)
                        {
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("errorExiste"));
                        }
                        if (ex.Message == EValidaciones.menor)
                        {
                            Notifications.FrmInformation.InformationForm(Helps.Language.SearchValue("errorMenor"));
                        }
                        else
                        {
                            InvokeCommand.InsertLog().Execute(CreateLog.Clog(ETipoLog.UpdateError, 1, ex.TargetSite.DeclaringType.FullName, ex.TargetSite.Name, "Cliente: " + entity.num_documento, ex.StackTrace, ex.Message));
                            Notifications.FrmError.ErrorForm(Helps.Language.SearchValue("editadoError") + "\n" + ex.Message);
                        }
                    }
                }
            }
            else
            {
                string messageValid = validation.Item2;
                Notifications.FrmInformation.InformationForm(messageValid);
            }
        }
Ejemplo n.º 25
0
        public async Task Create(Entities.Cliente cliente)
        {
            await _context.Clientes.AddAsync(cliente);

            await _context.SaveChangesAsync();
        }
Ejemplo n.º 26
0
        public static Entities.Cliente ValidaCliente(string login, string password)
        {
            var cliente = new Entities.Cliente();

            try
            {
                var database = DatabaseFactory.CreateDatabase();
                var cmd      = database.GetStoredProcCommand("ValidaCliente");
                database.AddInParameter(cmd, "login", DbType.String, login);
                database.AddInParameter(cmd, "password", DbType.String, password);

                using (var dataReader = database.ExecuteReader(cmd))
                {
                    if (dataReader.Read())
                    {
                        if (!(dataReader["Id"] is DBNull) && (dataReader["Id"] != null))
                        {
                            cliente.Id = (decimal)dataReader["Id"];
                        }
                        if (!(dataReader["Id_Rol"] is DBNull) && (dataReader["Id_Rol"] != null))
                        {
                            cliente.IdRol = (decimal)dataReader["Id_Rol"];
                        }
                        if (!(dataReader["Nombre"] is DBNull) && (dataReader["Nombre"] != null))
                        {
                            cliente.Nombre = (string)dataReader["Nombre"];
                        }
                        if (!(dataReader["Direccion"] is DBNull) && (dataReader["Direccion"] != null))
                        {
                            cliente.Direccion = (string)dataReader["Direccion"];
                        }
                        if (!(dataReader["Rut"] is DBNull) && (dataReader["Rut"] != null))
                        {
                            cliente.Rut = (string)dataReader["Rut"];
                        }
                        if (!(dataReader["Telefono"] is DBNull) && (dataReader["Telefono"] != null))
                        {
                            cliente.Telefono = (string)dataReader["Telefono"];
                        }
                        if (!(dataReader["Estado"] is DBNull) && (dataReader["Estado"] != null))
                        {
                            cliente.Estado = (int)dataReader["Estado"];
                        }
                        if (!(dataReader["Cambio_Clave"] is DBNull) && (dataReader["Cambio_Clave"] != null))
                        {
                            cliente.CambioClave = (int)dataReader["Cambio_Clave"];
                        }
                        if (!(dataReader["Correo"] is DBNull) && (dataReader["Correo"] != null))
                        {
                            cliente.Correo = (string)dataReader["Correo"];
                        }
                        if (!(dataReader["Total_Centro_Cultivo"] is DBNull) && (dataReader["Total_Centro_Cultivo"] != null))
                        {
                            cliente.TotalCentroCultivo = (int)dataReader["Total_Centro_Cultivo"];
                        }
                        cliente.Login    = login;
                        cliente.Password = password;
                    }
                }
            }
            catch (Exception exception)
            {
                //insertar log de error
                Log.InsLog("Cliente", "ValidaCliente", exception.Message);
            }

            return(cliente);
        }