Esempio n. 1
0
 private void btnGuardar_Click(object sender, EventArgs e)
 {
     Logica.Cliente c = new Logica.Cliente();
     c.Nombre = txtNombre.Text;
     c.Apellido = txtApellido.Text;
     c.Agregar();
     limpear();
     MessageBox.Show("Registro guardado con exito");
 }
Esempio n. 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            Cliente objCliente = new Cliente();
            if (textBox2.Text == string.Empty)
            {
                MessageBox.Show("Debe de ingresar un Nit o Cedula");
                textBox2.Focus();
                return;
            }

            if (textBox3.Text == string.Empty)
            {
                MessageBox.Show("Debe de ingresar un nombre de razon social");
                textBox3.Focus();
                return;
            }
            if (textBox4.Text == string.Empty)
            {
                MessageBox.Show("Debe de ingresar un telefono");
                textBox4.Focus();
                return;
            }
            if (textBox5.Text == string.Empty)
            {
                MessageBox.Show("Debe de ingresar una direccion");
                textBox5.Focus();
                return;
            }
            try
            {
                bool DatosCliente = objCliente.InsertarClientes(textBox2.Text,textBox3.Text,textBox4.Text,textBox5.Text);
                dataGridView1.DataSource = DatosCliente;
                MessageBox.Show("Se a guardado con exito");
                textBox2.Text = "";
                textBox3.Text = "";
                textBox4.Text = "";
                textBox5.Text = "";
            }
            catch (Exception exc)
            {
                MessageBox.Show("ERROR: " + exc.Message + objCliente.Mensaje);

            }
        }
Esempio n. 3
0
        private void button2_Click(object sender, EventArgs e)
        {
            // Consultar cliente por cedula
            Cliente objCliente = new Cliente();
            try
            {
                DataSet DatosCliente = objCliente.ConsultarClientePorNitCed(textBox1.Text);
                int numRegistro = DatosCliente.Tables["TablaConsultada"].Rows.Count;
                if (numRegistro == 0)
                    MessageBox.Show("No se encontro el cliente");
                else                {
                    dataGridView1.DataSource = DatosCliente.Tables["TablaConsultada"];}
            }
            catch (Exception exc)
            {
                MessageBox.Show("ERROR: " + exc.Message+objCliente.Mensaje);

            }
        }
Esempio n. 4
0
        private void button7_Click(object sender, EventArgs e)
        {
            Cliente objCliente = new Cliente();
            try
            {
                bool DatosCliente = objCliente.EliminarCliente(textBox6.Text);
                dataGridView2.DataSource = DatosCliente;
                dataGridView2.Visible = false;
            }
            catch (Exception exc)
            {
                MessageBox.Show("ERROR: " + exc.Message + objCliente.Mensaje);

            }
            button6.Visible = false;
            button5.Enabled = false;
        }
Esempio n. 5
0
        private void button6_Click(object sender, EventArgs e)
        {
            Cliente objCliente = new Cliente();
            if (textBox7.Text == string.Empty)
            {
                MessageBox.Show("Debe ingresar una razon social");
                textBox7.Focus();
                return;
            }
            if (textBox8.Text == string.Empty)
            {
                MessageBox.Show("Debe ingresar un telefono");
                textBox8.Focus();
                return;
            }
            if (textBox9.Text == string.Empty)
            {
                MessageBox.Show("Debe ingresar una direccion");
                textBox9.Focus();
                return;
            }
            try
            {
                bool DatosCliente = objCliente.ModificarClientes(textBox6.Text, textBox7.Text, textBox8.Text, textBox9.Text);
                dataGridView2.DataSource = DatosCliente;
                dataGridView2.Visible = false;
                MessageBox.Show("Se han modificado los datos con exito");
            }
            catch (Exception exc)
            {
                MessageBox.Show("ERROR: " + exc.Message + objCliente.Mensaje);

            }
        }
Esempio n. 6
0
        private void button4_Click(object sender, EventArgs e)
        {
            button5.Visible = true;
            dataGridView2.Visible = true;
            button7.Visible = true;

            if (textBox6.Text == string.Empty)
            {
                MessageBox.Show("Debe ingresar un Nit o una Cedula del cliente");
                textBox6.Focus();
                return;
            }

            Cliente objCliente = new Cliente();
            try
            {
                DataSet DatosCliente = objCliente.ConsultarClientePorNitCed(textBox6.Text);
                int numRegistro = DatosCliente.Tables["TablaConsultada"].Rows.Count;
                if (numRegistro == 0)
                    MessageBox.Show("No se encontro el cliente");
                else
                {
                    dataGridView2.DataSource = DatosCliente.Tables["TablaConsultada"];
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show("ERROR: " + exc.Message + objCliente.Mensaje);

            }
        }
Esempio n. 7
0
 public List<Cliente> ObtenerIdCliente()
 {
     List<Cliente> lista = new List<Cliente>();
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.Connection = BaseDatos.conn;
         cmd.CommandText = "SELECT IdCliente, Nombre, Apellido FROM Cliente";
         BaseDatos.conn.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         Cliente c;
         while (dr.Read())
         {
             c = new Cliente();
             c.IdCliente = Convert.ToInt32(dr["idProveedor"].ToString());
             c.Nombre = dr["Nombre"].ToString();
             c.Apellido = dr["Apellido"].ToString();
             lista.Add(c);
         }
         BaseDatos.conn.Close();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         BaseDatos.conn.Close();
     }
     return lista;
 }
Esempio n. 8
0
 public List<Cliente> ObtenerPorNombre(string nom)
 {
     List<Cliente> lista = new List<Cliente>();
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.Connection = BaseDatos.conn;
         cmd.CommandText = "SELECT * FROM Cliente WHERE Nombre = @nom";
         cmd.Parameters.AddWithValue("@nom", nom);
         BaseDatos.conn.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         Cliente c;
         while (dr.Read())
         {
             c = new Cliente();
             c.IdCliente = Convert.ToInt32(dr["IdCliente"].ToString());
             c.Nombre = dr["Nombre"].ToString();
             c.Apellido = dr["Apellido"].ToString();
             lista.Add(c);
         }
         BaseDatos.conn.Close();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         BaseDatos.conn.Close();
     }
     return lista;
 }
Esempio n. 9
0
 public List<Cliente> ObtenerListadoNombreCompleto()
 {
     List<Cliente> lista = new List<Cliente>();
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.Connection = BaseDatos.conn;
         cmd.CommandText = "SELECT IdCliente, Cliente.Nombre + ' ' + Cliente.Apellido AS NombreCompleto FROM Cliente";
         //cmd.Parameters.AddWithValue("@IdCliente", this.IdCliente);
         BaseDatos.conn.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         Cliente c;
         while (dr.Read())
         {
             c = new Cliente();
             c.IdCliente = Convert.ToInt32(dr["IdCliente"].ToString());
             c.NombreCompleto = dr["NombreCompleto"].ToString();
             lista.Add(c);
         }
         BaseDatos.conn.Close();
     }
     catch (Exception ex)
     {
         throw ex;
     }
     finally
     {
         BaseDatos.conn.Close();
     }
     return lista;
 }
Esempio n. 10
0
        public Cliente BuscarPorID(string cedula)
        {
            Cliente cliente = _context.Clientes.Find(cedula);

            return(cliente);
        }
Esempio n. 11
0
 public GuardarClienteResponse(Cliente cliente)
 {
     Error   = false;
     Cliente = cliente;
 }
Esempio n. 12
0
 public static void EditarCliente(Cliente Cliente, ApplicationDbContext _context)
 {
     _context.Entry(Cliente).State = EntityState.Modified;
     _context.SaveChanges();
 }
Esempio n. 13
0
 public static void GuardarCliente(Cliente Cliente, ApplicationDbContext _context)
 {
     Cliente.Activo = true;
     _context.Clientes.Add(Cliente);
     _context.SaveChanges();
 }