예제 #1
0
        private void Autocomplete()
        {
            var pFiltroCat    = new AutoCompleteStringCollection();
            var pFiltroSubCat = new AutoCompleteStringCollection();

            int j = 0;

            for (int i = 0; i <= ProductoDBM.ObtenerProductos().Count; i++)
            {
                if (j != ProductoDBM.ObtenerProductos().Count)
                {
                    pFiltroCat.Add(ProductoDBM.ObtenerProductos()[j].CATEGORIA);
                    pFiltroSubCat.Add(ProductoDBM.ObtenerProductos()[j].SUBCATEGORIA);

                    j++;
                }
            }
            txtCategoria.AutoCompleteCustomSource    = pFiltroCat;
            txtSubcategoria.AutoCompleteCustomSource = pFiltroSubCat;
        }
예제 #2
0
파일: SDL.cs 프로젝트: Ernesteins/sercor
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            Producto cargarProducto  = new Producto();
            Producto comparaProducto = new Producto();
            string   codigo;
            int      existencia;


            DialogResult existConfirm = MessageBox.Show("¿Sumar existencia de productos duplicados? Presione NO para sobreescribirlas", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            DialogResult result = MessageBox.Show("Esta operación puede causar cambios en Sercor. ¿Desea continuar?", "Confirmación", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == DialogResult.Yes)
            {
                for (int i = 0; i < dgvProducto.RowCount; i++)
                {
                    //MessageBox.Show(dgvProducto.Rows[i].Cells[0].Value.ToString());
                    codigo = dgvProducto.Rows[i].Cells[0].Value.ToString();

                    cargarProducto.COD          = codigo;
                    cargarProducto.NOMBRE       = dgvProducto.Rows[i].Cells[1].Value.ToString();
                    cargarProducto.DESCRIPCION  = dgvProducto.Rows[i].Cells[2].Value.ToString();
                    cargarProducto.CATEGORIA    = dgvProducto.Rows[i].Cells[3].Value.ToString();
                    cargarProducto.SUBCATEGORIA = dgvProducto.Rows[i].Cells[4].Value.ToString();
                    cargarProducto.EXISTENCIA   = Convert.ToInt32(dgvProducto.Rows[i].Cells[5].Value);
                    cargarProducto.PRECIO       = Convert.ToDecimal(dgvProducto.Rows[i].Cells[6].Value);
                    cargarProducto.ESTADO       = Convert.ToInt32(dgvProducto.Rows[i].Cells[7].Value);

                    comparaProducto = ProductoDBM.ObtenerProductoCod(codigo);

                    if (comparaProducto.COD != null)
                    {//EXISTE
                        existencia = comparaProducto.EXISTENCIA;
                        if (existConfirm == DialogResult.Yes)
                        {
                            cargarProducto.EXISTENCIA = existencia + Convert.ToInt32(dgvProducto.Rows[i].Cells[5].Value);
                        }
                        ProductoDBM.Modificar(cargarProducto, codigo);
                        contador = +1;
                        //MessageBox.Show(comparaProducto.COD);
                    }
                    else//NO EXISTE
                    {
                        ProductoDBM.Agregar(cargarProducto);
                        //MessageBox.Show("Es nulo");
                    }
                    Registro nregistro = new Registro();
                    nregistro.ID_PRODUCTO = cargarProducto.COD;
                    nregistro.FECHA       = FacturaDBM.obtenerFechaSistema();
                    nregistro.CANTIDAD    = cargarProducto.EXISTENCIA;
                    nregistro.IDREGISTRO  = RegistroDBM.UltimoRegistro() + 1;
                    RegistroDBM.Agregar(nregistro);
                }
                mensaje = "Se modificaron " + contador.ToString() + " productos existentes";
                this.Close();
            }
            else if (result == DialogResult.No)
            {
                MessageBox.Show("Se ha cancelado la transferencia de productos", "Sercor", MessageBoxButtons.OK, MessageBoxIcon.Information);
                mensaje = "Se canceló la operación";
            }
            else
            {
                //...
            }
        }
예제 #3
0
        private void btnAceptar_Click(object sender, EventArgs e)
        {
            if (txtCodigo.Text == "" | txtNombre.Text == "" | txtDescripcion.Text == "" | txtCategoria.Text == "" | txtSubcategoria.Text == "" | txtExistencia.Text == "" | txtPrecio.Text == "")
            {
                MessageBox.Show("Todos los campos son obligatorios");
            }
            else
            {
                try
                {
                    Producto pProducto = new Producto();
                    pProducto.COD    = txtCodigo.Text.Trim();
                    pProducto.NOMBRE = txtNombre.Text.Trim();

                    string concat;
                    if (rd3.Checked == true)
                    {
                        concat = "ARMA|";
                    }
                    else if (rd4.Checked == true)
                    {
                        concat = "LUNA|";
                    }
                    else
                    {
                        concat = "";
                    }

                    pProducto.DESCRIPCION = concat + txtDescripcion.Text.Trim();


                    pProducto.CATEGORIA    = txtCategoria.Text.Trim();
                    pProducto.SUBCATEGORIA = txtSubcategoria.Text.Trim();
                    pProducto.EXISTENCIA   = Convert.ToInt32(txtExistencia.Text);

                    txtPrecio.Text = txtPrecio.Text.Replace(",", ".");

                    pProducto.PRECIO = Decimal.Round(Convert.ToDecimal(txtPrecio.Text), 2);
                    //MessageBox.Show(pProducto.PRECIO.ToString());

                    int estado;
                    if (rd1.Checked == true)
                    {
                        estado = 1;
                    }
                    else
                    {
                        estado = 0;
                    }

                    pProducto.ESTADO = estado;
                    //pCliente.Fecha_Nac = dtpFechaNacimiento.Value.Year + "/" + dtpFechaNacimiento.Value.Month + "/" + dtpFechaNacimiento.Value.Day;

                    int resultado = ProductoDBM.Agregar(pProducto);
                    if (resultado > 0)
                    {
                        Registro nregistro = new Registro();
                        nregistro.ID_PRODUCTO = pProducto.COD;
                        nregistro.FECHA       = FacturaDBM.obtenerFechaSistema();
                        nregistro.CANTIDAD    = pProducto.EXISTENCIA;
                        nregistro.IDREGISTRO  = RegistroDBM.UltimoRegistro() + 1;
                        RegistroDBM.Agregar(nregistro);

                        //MessageBox.Show("Producto guardado con exito!", "Guardado", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        mensaje = "Producto guardado con exito";
                        this.Close();
                    }
                    else
                    {
                        //MessageBox.Show("No se pudo guardar el producto", "Fallo!!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        mensaje = "No es posible guardar el producto";
                        this.Close();
                    }
                }
                catch (System.FormatException)
                {
                    MessageBox.Show("Valores incorrectos");
                }
                catch (MySql.Data.MySqlClient.MySqlException) {
                    MessageBox.Show("Producto existente");
                }
            }
        }