Exemplo n.º 1
0
        private void agregar()
        {
            bool   result  = false;
            string mensaje = string.Empty;

            if (txtNombre.Text != string.Empty && txtTelefono.Text != string.Empty && txtRfc.Text != string.Empty && txtCalle.Text != string.Empty && txtColonia.Text != string.Empty && txtDelegacion.Text != string.Empty && txtEstado.Text != string.Empty && numNoExt.Value > 0 && numNoInt.Value >= 0)
            {
                if (validacion.validarRazon(txtNombre.Text) || validacion.validarNombre(txtNombre.Text))
                {
                    if (validacion.validarTelefonoLocal(txtTelefono.Text) || validacion.validarTelefonoMob(txtTelefono.Text))
                    {
                        if ((rbPerFisica.Checked == true && validacion.validarRfcFisica(txtRfc.Text) == true) || (rbPerMoral.Checked == true && validacion.validarRfcMoral(txtRfc.Text) == true))
                        {
                            if (validacion.validarNombresAlfa(txtCalle.Text))
                            {
                                if (validacion.validarNombresAlfa(txtColonia.Text))
                                {
                                    if (validacion.validarNombres(txtDelegacion.Text))
                                    {
                                        if (validacion.validarNombres(txtEstado.Text))
                                        {
                                            if (this.tipo == 1) //el producto se va a guardar
                                            {
                                                this.clienteAct = new cliente(txtClave.Text, txtNombre.Text, txtTelefono.Text, "calle " + txtCalle.Text + " noInt " + numNoInt.Value.ToString() + " noExt " + numNoExt.Value.ToString() + " colonia " + txtColonia.Text + " delegacion " + txtDelegacion.Text + " estado " + txtEstado.Text, txtRfc.Text);
                                                result          = clienteAct.registroCliente();
                                                if (result == true)
                                                {
                                                    mensaje = "El Cliente Se Ha Agregado";
                                                }
                                                else
                                                {
                                                    mensaje = "El Cliente No Se Ha Podido Agregar, Intenta Mas Tarde";
                                                }
                                            }
                                            else if (this.tipo == 2) // se va a modificar
                                            {
                                                this.clienteAct = new cliente(txtClave.Text, txtNombre.Text, txtTelefono.Text, "calle " + txtCalle.Text + " noInt " + numNoInt.Value.ToString() + " noExt " + numNoExt.Value.ToString() + " colonia " + txtColonia.Text + " delegacion " + txtDelegacion.Text + " estado " + txtEstado.Text, txtRfc.Text);
                                                result          = clienteAct.modificarCliente();
                                                if (result == true)
                                                {
                                                    mensaje = "El Cliente Se Ha Modificado";
                                                }
                                                else
                                                {
                                                    mensaje = "El Cliente No Se Ha Podido Modificar, Intenta Mas Tarde";
                                                }
                                            }
                                        }
                                        else
                                        {
                                            mensaje = " Estado no valido";
                                        }
                                    }
                                    else
                                    {
                                        mensaje = " Colonia no valida";
                                    }
                                }
                                else
                                {
                                    mensaje = " Colonia no valida";
                                }
                            }
                            else
                            {
                                mensaje = " Calle no valida";
                            }
                        }
                        else
                        {
                            mensaje = " RFC no valido";
                        }
                    }
                    else
                    {
                        mensaje = " Telefono no valido";
                    }
                }
                else
                {
                    mensaje = "Nombre no valido";
                }
            }
            else
            {
                mensaje = "Llena todos los campos";
            }
            MessageBox.Show(mensaje);
            if (result == true)
            {
                this.Close();
            }
        }
Exemplo n.º 2
0
 public frmCliente(int tipo, cliente cliente)
 {
     this.tipo       = tipo;
     this.clienteAct = cliente;
     InitializeComponent();
 }
Exemplo n.º 3
0
 private void btnSeleccionar_Click(object sender, EventArgs e)
 {
     if (this.tipo == 1)// se va a modificar un producto
     {
         asignaProducto();
         frmProductos fp = new frmProductos(2, productoActual);
         fp.ShowDialog();
     }
     else if (this.tipo == 2)//se va a modificar un cliente
     {
         clienteActual = new cliente(dgvBusqueda.CurrentRow.Cells[0].Value.ToString(), dgvBusqueda.CurrentRow.Cells[1].Value.ToString(), dgvBusqueda.CurrentRow.Cells[2].Value.ToString(), dgvBusqueda.CurrentRow.Cells[3].Value.ToString(), dgvBusqueda.CurrentRow.Cells[4].Value.ToString());
         frmCliente fc = new frmCliente(2, clienteActual);
         fc.ShowDialog();
     }
     else if (this.tipo == 3)//se va a agregar una orden
     {
         if (numCantidad.Value > 0)
         {
             try
             {
                 if (producto.NuevaOrden(dgvBusqueda.CurrentRow.Cells[0].Value.ToString(), numCantidad.Value, DateTime.Now))
                 {
                     MessageBox.Show("Orden Exitosa");
                     this.Close();
                 }
                 else
                 {
                     MessageBox.Show("No se pudo realizar orden");
                 }
             }
             catch (Exception em)
             {
                 MessageBox.Show("Selecciona un producto");
             }
         }
         else
         {
             MessageBox.Show("Selecciona la cantidad");
         }
     }
     else if (this.tipo == 4) //se van a añadir productos (venta)
     {
         if (numCantidad.Value > 0)
         {
             if (cantSeleccionada(dgvBusqueda.CurrentRow.Cells[0].Value.ToString()) > 0) // ya existe el producto elegido, por lo tanto solo se añade la cantidad
             {
                 foreach (producto prod in productosActuales)
                 {
                     if (prod.Clave.Equals(dgvBusqueda.CurrentRow.Cells[0].Value.ToString()))
                     {
                         prod.Existencia += Convert.ToDecimal(numCantidad.Value);
                         break;
                     }
                 }
             }
             else //el producto no existe
             {
                 asignaProducto();
                 productosActuales.Add(productoActual);
             }
             this.Close();
         }
         else
         {
             MessageBox.Show("Selecciona la cantidad, sujeto a disponibilidad");
         }
     }
     else if (this.tipo == 5)
     {
         clienteActual.Clave   = dgvBusqueda.CurrentRow.Cells[0].Value.ToString();
         clienteActual.Nombre  = dgvBusqueda.CurrentRow.Cells[1].Value.ToString();
         clienteActual.Num     = dgvBusqueda.CurrentRow.Cells[2].Value.ToString();
         clienteActual.Dir     = dgvBusqueda.CurrentRow.Cells[3].Value.ToString();
         clienteActual.Rfc     = dgvBusqueda.CurrentRow.Cells[4].Value.ToString();
         clienteActual.TotFact = Convert.ToDecimal(dgvBusqueda.CurrentRow.Cells[5].Value);
         this.Close();
     }
     this.txtBusqueda.Text       = string.Empty;
     this.dgvBusqueda.DataSource = null;
     this.dgvBusqueda.Refresh();//accion despues de eliminar o modificar el producto
 }