Beispiel #1
0
        private void btnBuscarNombreCliente_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtBuscarNombre.Text == string.Empty && txtBuscarApellido.Text == string.Empty)
                {
                    MessageBox.Show("Debe ingresar al menos un criterio de búsqueda.");
                    CargarDGVClientes(this.m.Clientes);
                }
                else
                {
                    CargarDGVClientes(this.m.SC.BuscarClientes(Validaciones.StringValidation(txtBuscarNombre.Text, lblBuscarNombre.Text), Validaciones.StringValidation(txtBuscarApellido.Text, lblBuscarApellido.Text)));
                }

                LimpiarCampos();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #2
0
 private void Aceptar_Modificar_Click(object sender, EventArgs e)
 {
     if (!(string.IsNullOrEmpty(txt_nombre.Text)) && Validaciones.ValidarCargaDoubleForms(txt_precio.Text, double.MaxValue, 0) && Validaciones.ValidarCargaEnteroForms(txt_capacidad.Text, int.MaxValue, 0))
     {
         lb_error.Text = "";
         if (primeraCarga)
         {
             menuPrincipal = new MenuPrincipal(txt_nombre.Text, int.Parse(txt_capacidad.Text), double.Parse(txt_precio.Text));
         }
         else
         {
             estacionamiento.SetearNombre(txt_nombre.Text);
             estacionamiento.SetearPrecio(double.Parse(txt_precio.Text));
             menuPrincipal = new MenuPrincipal(estacionamiento);
         }
         menuPrincipal.Show();
         this.Hide();
     }
     else
     {
         lb_error.ForeColor = Color.DarkRed;
         lb_error.Text      = "Al menos uno de los datos es invalido";
     }
 }
 private void MobilePhoneTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = (char)Validaciones.Telefonos(e.KeyChar);
 }
 private void TxtTelefono_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Numeros(e);
 }
 private void TxtProfesión_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Letras(e);
 }
        private void btnAgregarClientes_Click(object sender, EventArgs e)
        {
            try
            {
                string _STRdni             = txtDNI.Text;
                int    _dni                = 0;
                string _nombre             = txtNombre.Text;
                string _apellido           = txtApellido.Text;
                string _direccion          = txtDireccion.Text;
                string _email              = txtEmail.Text;
                string _STRtelefono        = txtTelefono.Text;
                long   _telefono           = 0;
                string _STRfechaNacimiento = datetimePickerNacimiento.Text;
                bool   _activo             = false;


                int edad = DateTime.Today.Year - datetimePickerNacimiento.Value.Year;

                if (DateTime.Today < datetimePickerNacimiento.Value.AddYears(edad))
                {
                    edad--;
                }

                if (checkActivo.Checked)
                {
                    _activo = true;
                }

                string msj = "";

                msj += Validaciones.ValidarDNI(_STRdni, "Dni", ref _dni);
                msj += Validaciones.ValidarSTRING(_nombre, "Nombre");
                msj += Validaciones.ValidarSTRING(_apellido, "Apellido");
                msj += Validaciones.ValidarSTRING(_direccion, "Direccion");
                msj += Validaciones.ValidarSTRING(_email, "Email");
                msj += Validaciones.ValidarTelefono(_STRtelefono, "Telefono", ref _telefono);

                if (!string.IsNullOrWhiteSpace(msj))
                {
                    MessageBox.Show(msj, "ERRORES");
                }
                else if (edad < 18)
                {
                    throw new EdadInsuficienteException();
                }
                else
                {
                    Cliente C = new Cliente(_dni, _nombre, _apellido, _direccion, _telefono, _email, _activo, _STRfechaNacimiento);

                    int salida = _clienteServicio.InsertarCliente(C);

                    MessageBox.Show("Cliente Agregado con exito ID: " + salida, "Mensaje del sistema");

                    LimpiarBotones();
                }
            }
            catch (EdadInsuficienteException ez)
            {
                MessageBox.Show(ez.Message, "Mensaje del sistema");
            }
            catch (Exception xe)
            {
                MessageBox.Show(xe.Message);
                LimpiarBotones();
            }
        }
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            DateTime fecha    = dtpFecha.Value;
            int      nro_comp = 0;

            try
            {
                nro_comp = Convert.ToInt32(tbNumeroComp.Text);
            }
            catch (Exception)
            {
                Funciones.mError(this, "Número de comprobante incorrecto");
            }
            int id_proveedor = cbProveedor.SelectedIndex;

            Validaciones.MensajesError.Clear();

            if (!Validaciones.ValidarComprobante(nro_comp, fecha, id_proveedor))
            {
                Compra compra = new Compra(nro_comp, fecha, id_proveedor);

                if (compra.Error)
                {
                    foreach (string msj in compra.Mensajes)
                    {
                        Funciones.mError(this, msj);
                    }
                }
                else
                {
                    int id_comprobante = 0;
                    try
                    {
                        id_comprobante = compra.Guardar();
                    }
                    catch (Exception ew)
                    {
                        Funciones.mError(this, "Error al guardar comprobante: " + ew.Message);
                    }

                    IList <Detalle_compra> listaDetalle = new List <Detalle_compra>();

                    // Validación de cada detalle de comprobante
                    Validaciones.MensajesError.Clear();
                    for (int i = 0; i < dgvCompra.Rows.Count - 1; i++)
                    {
                        if (!Validaciones.ValidarDetalleComprobante(Convert.ToInt32(dgvCompra.Rows[i].Cells[0].Value), Convert.ToDouble(dgvCompra.Rows[i].Cells[2].Value), Convert.ToInt32(dgvCompra.Rows[i].Cells[3].Value)))
                        {
                        }
                        else
                        {
                            foreach (string msj in Validaciones.MensajesError)
                            {
                                Funciones.mError(this, msj);
                            }
                            return;
                        }
                    }

                    for (int i = 0; i < dgvCompra.Rows.Count - 1; i++)
                    {
                        listaDetalle.Add(new Detalle_compra(new Producto_simple(Convert.ToInt32(dgvCompra.Rows[i].Cells[0].Value)), Convert.ToDouble(dgvCompra.Rows[i].Cells[2].Value), Convert.ToInt32(dgvCompra.Rows[i].Cells[3].Value), id_comprobante));
                    }

                    foreach (Detalle_compra dc in listaDetalle)
                    {
                        try
                        {
                            dc.Guardar();
                            if (dc.Producto.ActualizarStock(dc.Cantidad))
                            {
                            }
                            else
                            {
                                Funciones.mError(this, "Error al actualizar stock del producto: " + dc.Producto.Descripcion);
                            }
                            if (dc.Producto.ActualizarCosto((float)dc.Precio))
                            {
                            }
                            else
                            {
                                Funciones.mError(this, "Error al actualizar el precio del producto: " + dc.Producto.Descripcion);
                            }
                        }
                        catch (Exception)
                        {
                            compra.Eliminar(id_comprobante);
                        }
                    }

                    Funciones.mError(this, "Registro exitoso");
                    tbNumeroComp.Text = "";
                    dgvCompra.Rows.Clear();
                }
            }
            else
            {
                foreach (string msj in Validaciones.MensajesError)
                {
                    Funciones.mError(this, msj);
                }
            }
        }
Beispiel #8
0
 private void txtFolio_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.SoloNumeros(e);
 }
 private void ObtenerValores(Marcas marca)
 {
     marca.MarcaId     = Validaciones.Entero(MarcaIdTextBox.Text);
     marca.Descripcion = DescripcionTextBox.Text;
 }
 void TxtrfcKeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = Validaciones.valida("U", e.KeyChar);
 }
 void TxtBuscarKeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = Validaciones.valida("T", e.KeyChar);
 }
 void TxttelefonoKeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = Validaciones.valida("N", e.KeyChar);
 }
 void TxtcorreoKeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = Validaciones.validaCorreo(txtcorreo, e.KeyChar);
 }
 void Txtid_proveedorKeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = Validaciones.valida("N", e.KeyChar);
 }
Beispiel #15
0
 private void textBoxProductoCantidad_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Clear();
 }
Beispiel #16
0
        public static System.Drawing.Image obtenerImagen(string ruta, string nombre, string strAncho, string strAlto, string strColor, bool boolAlto)
        {
            string RutaCompleta = Constantes.cRaizArchivos + @"\archivos\" + ruta + @"\";
            string RutaCompletaNombreArchivo = RutaCompleta + nombre;

            if (System.IO.File.Exists(RutaCompletaNombreArchivo) && Validaciones.IsNumeric(strAncho) && Validaciones.IsNumeric(strAlto))
            {
                try
                {
                    Color objColor;
                    if (strColor != string.Empty)
                    {
                        objColor = System.Drawing.ColorTranslator.FromHtml(strColor);
                    }
                    else
                    {
                        objColor = Color.Empty;//Color.White;
                    }
                    string[] listaParteNombre      = nombre.Split('.');
                    string   CacheNombreArchivo    = string.Empty;
                    string   CacheExtencionArchivo = string.Empty;
                    for (int i = 0; i < listaParteNombre.Length - 1; i++)
                    {
                        CacheNombreArchivo += listaParteNombre[i];
                    }
                    CacheExtencionArchivo = listaParteNombre[listaParteNombre.Length - 1];
                    string ChacheRutaDeImagenRedimencionada       = RutaCompleta + "resize" + @"\";
                    string ChacheRutaYNombreArchivoRedimencionado = ChacheRutaDeImagenRedimencionada + CacheNombreArchivo + "_" + strAncho + "x" + strAlto + "_" + boolAlto.ToString() + "_" + strColor + "." + CacheExtencionArchivo;
                    if (System.IO.File.Exists(ChacheRutaYNombreArchivoRedimencionado))
                    {
                        System.Drawing.Image oImgCache = System.Drawing.Image.FromFile(ChacheRutaYNombreArchivoRedimencionado);
                        return(oImgCache);
                    }
                    else
                    {
                        int ancho = Convert.ToInt32(strAncho);
                        int alto  = Convert.ToInt32(strAlto);
                        System.Drawing.Image origImagen = System.Drawing.Image.FromFile(RutaCompletaNombreArchivo);
                        int anchoRelacion;
                        int altoRelacion;
                        if (ancho == -1)
                        {
                            ancho = origImagen.Width;
                        }
                        if (alto == -1)
                        {
                            alto = origImagen.Height;
                        }
                        if (!boolAlto)
                        {
                            // Default
                            // el ancho predomina
                            if (origImagen.Width > ancho)
                            {
                                altoRelacion  = (origImagen.Height * ancho) / origImagen.Width;
                                anchoRelacion = ancho;
                                if (altoRelacion > alto)
                                {
                                    anchoRelacion = (origImagen.Width * alto) / origImagen.Height;
                                    altoRelacion  = alto;
                                }
                            }
                            else if (origImagen.Height > alto)
                            {
                                anchoRelacion = (origImagen.Width * alto) / origImagen.Height;
                                altoRelacion  = alto;
                                if (anchoRelacion > ancho)
                                {
                                    altoRelacion  = (origImagen.Height * ancho) / origImagen.Width;
                                    anchoRelacion = ancho;
                                }
                            }
                            else
                            {
                                anchoRelacion = origImagen.Width;  // ancho;
                                altoRelacion  = origImagen.Height; // alto;
                            }
                        }
                        else
                        {
                            // alto es predomina
                            if (origImagen.Height > alto)
                            {
                                anchoRelacion = (origImagen.Width * alto) / origImagen.Height;
                                altoRelacion  = alto;
                                if (anchoRelacion > ancho)
                                {
                                    altoRelacion  = (origImagen.Height * ancho) / origImagen.Width;
                                    anchoRelacion = ancho;
                                }
                            }
                            else if (origImagen.Width > ancho)
                            {
                                altoRelacion  = (origImagen.Height * ancho) / origImagen.Width;
                                anchoRelacion = ancho;
                                if (altoRelacion > alto)
                                {
                                    anchoRelacion = (origImagen.Width * alto) / origImagen.Height;
                                    altoRelacion  = alto;
                                }
                            }
                            else
                            {
                                anchoRelacion = origImagen.Width;  // ancho;
                                altoRelacion  = origImagen.Height; // alto;
                            }
                        }
                        //
                        DirectoryInfo DIR = new DirectoryInfo(ChacheRutaDeImagenRedimencionada);
                        if (!DIR.Exists)
                        {
                            DIR.Create();
                        }
                        System.Drawing.Image oImg = objColor == Color.Empty ? RedimencionarImagen(origImagen, anchoRelacion, altoRelacion) : RedimencionarImagen(origImagen, anchoRelacion, altoRelacion, ancho, alto, objColor);
                        oImg.Save(ChacheRutaYNombreArchivoRedimencionado);
                        return(oImg);
                    }
                }
                catch (Exception ex)
                {
                    //return null;
                }
            }
            return(null);
        }
Beispiel #17
0
 private void text_AbonaCon_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Clear();
 }
Beispiel #18
0
 private void BtnAceptar_Click(object sender, EventArgs e)
 {
     if (Validaciones.ContieneLetras(this.TxtNombre.Text) && Validaciones.ContieneLetras(this.TxtApellido.Text) && Validaciones.EsNumerico(this.TxtDni.Text) && Validaciones.EsNumerico(this.TbxId.Text))
     {
         int.TryParse(TxtDni.Text, out int auxDni);
         int.TryParse(TbxId.Text, out int auxId);
         KwikEMart.AgregarEmpleado(new Empleado(this.TxtNombre.Text, this.TxtApellido.Text, auxDni, auxId));
     }
     else
     {
         MessageBox.Show("Error en los datos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
     this.DialogResult = DialogResult.OK;
 }
Beispiel #19
0
 private void txtxDniCliente_KeyUp(object sender, KeyEventArgs e)
 {
     Validaciones.ValidarCampoEntero((TextBox)sender);
 }
Beispiel #20
0
        private bool BindGrid()
        {
            SisPackController.AdministrarGrillas.Configurar(dtgHojasRuta, "HojaRutaID", this.CantidadOpciones);

            IHojaRuta hojaRuta = HojaRutaFactory.GetHojaRuta();

            hojaRuta.AgenciaOrigenID = this.AgenciaConectadaID;
            hojaRuta.Fecha           = this.txtFecha.Text == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(this.txtFecha.Text);
            hojaRuta.oServicioTransporte.ServicioTransporteDescrip = this.txtServicioTransporteDescrip.Text == "" ? null : this.txtServicioTransporteDescrip.Text;
            DsHojaRutaConsul ds = hojaRuta.GetHojaRutaConsultaDataSet();

            if (this.txtHojaRuta.Text != "")
            {
                this.dtgHojasRuta.DataSource = (DsHojaRutaConsul.DatosRow[])ds.Datos.Select("NroHojaRuta = " + Validaciones.obtieneEntero(this.txtHojaRuta.Text));
            }
            else
            {
                this.dtgHojasRuta.DataSource = ds;
            }


            this.dtgHojasRuta.DataMember = "Datos";
            this.dtgHojasRuta.DataBind();

            return(true);
        }
 private void TxtApellido_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Letras(e);
 }
Beispiel #22
0
 /// <summary>
 /// Al recibir click sobre el boton adecuado valida los campos de textBox e instancia un Producto.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAltaProducto_Click(object sender, EventArgs e)
 {
     if (Validaciones.ValidarString(txtNombreProducto.Text) && Validaciones.ValidarInt(txtCantidadProducto.Text) != -1 && Validaciones.ValidarDouble(txtPrecioUnidadProducto.Text) != -1)
     {
         producto          = new Producto(txtNombreProducto.Text, Validaciones.ValidarInt(txtCantidadProducto.Text), Validaciones.ValidarDouble(txtPrecioUnidadProducto.Text));
         this.DialogResult = DialogResult.OK;
     }
     else
     {
         this.DialogResult = DialogResult.No;
     }
 }
 private void TxtCelular_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Numeros(e);
 }
Beispiel #24
0
 private void txt_Telefono_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Clear();
 }
        private void btnAltaTarjeta_Click(object sender, EventArgs e)
        {
            try
            {
                if (cbxCliente.SelectedIndex == -1)
                {
                    throw new Exception("Debe seleccionar un cliente");
                }

                else if (cbxTipoTarjeta.SelectedIndex == -1)
                {
                    throw new Exception("Debe seleccionar un tipo de tarjeta");
                }
                else if (cbxPeriodoVencimiento.SelectedIndex == -1)
                {
                    throw new Exception("Debe seleccionar un vencimiento");
                }
                else
                {
                    var obj = cbxCliente.SelectedItem;

                    string[] vector = obj.ToString().Split('-');

                    int idcliente = Convert.ToInt32(vector[0]);

                    int tipotarjeta = 0;

                    if (cbxTipoTarjeta.SelectedItem.ToString() == "Visa")
                    {
                        tipotarjeta = 1;
                    }
                    if (cbxTipoTarjeta.SelectedItem.ToString() == "MasterCard")
                    {
                        tipotarjeta = 2;
                    }
                    if (cbxTipoTarjeta.SelectedItem.ToString() == "American")
                    {
                        tipotarjeta = 3;
                    }

                    int peridovencimiento = 0;

                    if (cbxPeriodoVencimiento.SelectedItem.ToString() == "Primera Semana")
                    {
                        peridovencimiento = 1;
                    }
                    if (cbxPeriodoVencimiento.SelectedItem.ToString() == "Segunda Semana")
                    {
                        peridovencimiento = 2;
                    }
                    if (cbxPeriodoVencimiento.SelectedItem.ToString() == "Tercera Semana")
                    {
                        peridovencimiento = 3;
                    }
                    if (cbxPeriodoVencimiento.SelectedItem.ToString() == "Cuarta Semana")
                    {
                        peridovencimiento = 4;
                    }

                    double limitecompra = 0;
                    string strLimite    = txtLimiteCompra.Text;

                    string msj = Validaciones.ValidarMonto(strLimite, "Limite de compra", ref limitecompra);

                    if (!string.IsNullOrWhiteSpace(msj))
                    {
                        MessageBox.Show(msj);
                    }
                    else
                    {
                        _tarjetaServicio.DarDeAltaTarjeta(idcliente, tipotarjeta, peridovencimiento, limitecompra);

                        MessageBox.Show("Se dio de alta correctamente la tajerta");

                        LimpiarCampos();

                        List <Tarjeta> lsttar = _tarjetaServicio.TraerTarjetadeunCliente(idcliente);

                        lstTarjetas.DataSource = lsttar;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Beispiel #26
0
 private void txt_Domicilio_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Clear();
 }
 private void IdNumberTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = (char)Validaciones.Numeros(e.KeyChar);
 }
Beispiel #28
0
 private void txt_Nombre_KeyPress(object sender, KeyPressEventArgs e)
 {
     Validaciones.Clear();
 }
 private void EmailTextBox_KeyPress(object sender, KeyPressEventArgs e)
 {
     e.KeyChar = (char)Validaciones.Correos(e.KeyChar);
 }
Beispiel #30
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            float auxPrecio;
            int   auxStock;


            if (float.TryParse(this.txtPrecio.Text, out auxPrecio) && int.TryParse(this.txtStock.Text, out auxStock) && !Validaciones.ValidarString(this.txtNombreProducto.Text))
            {
                Producto producto1 = new Producto(txtNombreProducto.Text, float.Parse(txtPrecio.Text), int.Parse(txtStock.Text));
                TiendaApu.AgregarProducto(producto1);
                MessageBox.Show("Se agrego correctamente el producto", "Agregado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Verificar Campos...", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }