Beispiel #1
0
        private void TxtCodigo_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                if (e.KeyCode == Keys.Enter)
                {
                    DataTable Tabla = new DataTable();
                    Tabla = NArticulo.BuscarCodigo(txtCodigo.Text.Trim());

                    if (Tabla.Rows.Count <= 0)
                    {
                        this.MensajeError("No existe articulo con ese codigo de barras.");
                    }
                    else
                    {
                        //agregar al detalle
                        this.AgreagarDetalle(Convert.ToInt32(Tabla.Rows[0][0]), Convert.ToString(Tabla.Rows[0][1]), Convert.ToString(Tabla.Rows[0][2]), Convert.ToDecimal(Tabla.Rows[0][3]));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void textoCodigoBarras_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         switch (e.KeyCode)
         {
         case Keys.Enter:
             DataTable tabla = new DataTable();
             tabla = NArticulo.BuscarCodigo(textoCodigoBarras.Text.Trim());
             if (tabla.Rows.Count <= 0)
             {
                 this.MensajeError("No existe el articulo con ese codigo");
             }
             else
             {
                 this.agregarDetalle(Convert.ToInt32(tabla.Rows[0][0]), Convert.ToString(tabla.Rows[0][1]),
                                     Convert.ToString(tabla.Rows[0][2]), Convert.ToDecimal(tabla.Rows[0][3]));
             }
             break;
         }
     }
     catch (Exception exe)
     {
         MessageBox.Show(exe.Message + exe.StackTrace);
     }
 }
Beispiel #3
0
        //public static Image ByteArrayToImage(byte[] byteArrayIn)
        //{
        //    MemoryStream ms = new MemoryStream(byteArrayIn);
        //    return Image.FromStream(ms);
        //}


        private void dgvArticulo_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                DataTable tabla = new DataTable();


                if (dgvArticulo.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Editar"))
                {
                    int idarticulo = Convert.ToInt32(dgvArticulo.Rows[e.RowIndex].Cells[8].Value);
                    tabla = NArticulo.BuscarCodigo(idarticulo);
                    new frmArticulo().Show();
                    int numFilas = tabla.Rows.Count;
                    if (numFilas == 1)
                    {
                        frmArticulo.MyFormArt.txtCodigo.Text                = tabla.Rows[0]["codigo"].ToString();
                        frmArticulo.MyFormArt.txtNombre.Text                = tabla.Rows[0]["nombre"].ToString();
                        frmArticulo.MyFormArt.cboCategoria.SelectedValue    = tabla.Rows[0]["idcategoria"].ToString();
                        frmArticulo.MyFormArt.cboPresentacion.SelectedValue = tabla.Rows[0]["idpresentacion"].ToString();
                        frmArticulo.MyFormArt.txtNeto.Text        = tabla.Rows[0]["neto"].ToString();
                        frmArticulo.MyFormArt.txtDescripcion.Text = tabla.Rows[0]["Descripcion"].ToString();
                        //frmArticulo.MyFormArt.ImageToByteArray(tabla.Rows[0]["imagen"]);
                        byte[] img = (byte[])tabla.Rows[0]["imagen"];
                        var    ms  = new MemoryStream(img);
                        if (ms != null)
                        {
                            frmArticulo.MyFormArt.pbImagen.Image = Image.FromStream(ms);
                        }
                        else
                        {
                            frmArticulo.MyFormArt.pbImagen.Image = null;
                        }
                        frmArticulo.MyFormArt.idArticulo = int.Parse(tabla.Rows[0]["idarticulo"].ToString());
                        frmArticulo.MyFormArt._IsNew     = false;
                    }
                }
                if (dgvArticulo.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString().Equals("Eliminar"))
                {
                    int          idarticulo = Convert.ToInt32(dgvArticulo.Rows[e.RowIndex].Cells[8].Value);
                    DialogResult rspta      = MessageBox.Show("Desea Eliminar", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);
                    if (DialogResult.Yes == rspta)
                    {
                        //var empleado = new Clases.Empleado(id_personal);
                        bool objCat = NArticulo.Eliminar(idarticulo);
                        if (objCat)
                        {
                            dgvArticulo.Rows.RemoveAt(e.RowIndex);
                            MostrarArticulo();
                        }
                        else
                        {
                            MessageBox.Show("Error al eliminar ");
                        }
                    }
                }
            }
            //finish
        }
Beispiel #4
0
        private void dgvArticulo_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.RowIndex != -1)
            {
                DataTable tabla = new DataTable();

                int idarticulo = Convert.ToInt32(dgvArticulo.Rows[e.RowIndex].Cells[8].Value);
                tabla = NArticulo.BuscarCodigo(idarticulo);
                int numFilas = tabla.Rows.Count;
                if (numFilas == 1)
                {
                    frmIngresoArticulos.MyformIngresoArt.IdArticulo           = idarticulo;
                    frmIngresoArticulos.MyformIngresoArt.txtArticulo.Text     = tabla.Rows[0]["nombre"].ToString();
                    frmIngresoArticulos.MyformIngresoArt.txtCategoria.Text    = tabla.Rows[0]["categoria"].ToString();
                    frmIngresoArticulos.MyformIngresoArt.txtNeto.Text         = tabla.Rows[0]["neto"].ToString();
                    frmIngresoArticulos.MyformIngresoArt.txtPresentacion.Text = tabla.Rows[0]["presentacion"].ToString();
                    this.Close();
                }
            }
        }
Beispiel #5
0
        private void txtCodigo_KeyPress(object sender, KeyPressEventArgs e)
        {
            if (e.KeyChar == (13))
            {
                DataTable busquedaproducto;

                busquedaproducto = NArticulo.BuscarCodigo(this.txtCodigo.Text);

                if (busquedaproducto.Rows.Count > 0)
                {
                    MensajeError("Este artículo ya se encuentra registrado");
                    this.Limpiar();
                    this.txtCodigo.Focus();
                }
                else
                {
                    this.txtMarca.Focus();
                }
            }
        }
 //Método BuscarNombre
 private void BuscarCodigo()
 {
     this.dataListado.DataSource = NArticulo.BuscarCodigo(this.txtBuscar.Text);
     this.OcultarColumnas();
     lblTotal.Text = "Total de Registros: " + Convert.ToString(dataListado.Rows.Count);
 }
Beispiel #7
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string    rpta = "";
                DataTable busquedaproducto;
                string    articulo = "";
                if (this.txtMarca.Text == string.Empty || this.txtIdCategoria.Text == string.Empty)
                {
                    MensajeError("Falta ingresar algun dato");
                    errorIcono.SetError(txtMarca, "Ingrese un valor");
                    errorIcono.SetError(txtCategoria, "Ingrese un valor");
                }
                else
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    this.pxImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                    byte[] imagen = ms.GetBuffer();

                    busquedaproducto = NArticulo.BuscarCodigo(this.txtCodigo.Text);

                    if (busquedaproducto.Rows.Count > 0)
                    {
                        articulo = "Articulo encontrado";
                    }
                    else
                    {
                        articulo = "Articulo no encontrado";
                    }

                    if (this.IsNuevo)
                    {
                        string codigo;
                        if (this.txtDescuento.Text == null || this.txtDescuento.Text == string.Empty)
                        {
                            this.txtDescuento.Text = "0";
                        }
                        if (this.txtCodigo.Text == string.Empty)
                        {
                            codigo = "0";
                        }
                        else
                        {
                            codigo = this.txtCodigo.Text;
                        }
                        if (articulo == "Articulo no encontrado")
                        {
                            rpta = NArticulo.Insertar(codigo, this.txtMarca.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim().ToUpper(),
                                                      imagen, Convert.ToInt32(this.txtIdCategoria.Text), Convert.ToInt32(this.cbIdPresentacion.SelectedValue), this.txtContenido.Text.Trim().ToUpper(), Convert.ToInt32(this.txtDescuento.Text));
                        }
                        else
                        {
                            this.MensajeError("No se puede registrar el Artículo ya existe");
                        }
                    }
                    else
                    {
                        string codigo;
                        if (this.txtDescuento.Text == null || this.txtDescuento.Text == string.Empty)
                        {
                            this.txtDescuento.Text = "0";
                        }
                        if (this.txtCodigo.Text == string.Empty)
                        {
                            codigo = "0";
                        }
                        else
                        {
                            codigo = this.txtCodigo.Text;
                        }

                        rpta = NArticulo.Editar(Convert.ToInt32(this.txtIdArticulo.Text), codigo, this.txtMarca.Text.Trim().ToUpper(), this.txtDescripcion.Text.Trim().ToUpper(),
                                                imagen, Convert.ToInt32(this.txtIdCategoria.Text), Convert.ToInt32(this.cbIdPresentacion.SelectedValue), this.txtContenido.Text.Trim().ToUpper(), Convert.ToInt32(this.txtDescuento.Text));
                    }
                    if (rpta.Equals("OK"))
                    {
                        if (this.IsNuevo)
                        {
                            this.MensajeOk("Se inserto correctamente el registro");
                        }
                        else
                        {
                            this.MensajeOk("Se actualizó correctamente el registro");
                        }
                    }
                    else
                    {
                        this.MensajeError(rpta);
                    }
                    this.IsNuevo  = false;
                    this.IsEditar = false;
                    this.Botones();
                    this.Limpiar();
                    this.Mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }