コード例 #1
0
        private void btnguardar_Click(object sender, EventArgs e)
        {
            try
            {
                string respuesta = "";
                if (this.txtnombre.Text == string.Empty || this.txtidcategoria.Text == string.Empty || this.txtcodigo.Text == string.Empty)
                {
                    Mensajeerror(" Faltan ingresar algunos datos");
                    erroricono.SetError(txtnombre, "Ingrese un valor");
                    erroricono.SetError(txtcodigo, "Ingrese un valor");
                    erroricono.SetError(txtcategoria, "Ingrese un valor");
                }
                else
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();
                    this.picimagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png);

                    byte[] imagen = ms.GetBuffer();
                    if (this.Isnuevo)
                    {
                        respuesta = Narticulo.Insertar(this.txtcodigo.Text, this.txtnombre.Text.Trim().ToUpper(), this.txtdescripcion.Text.Trim(),
                                                       imagen, Convert.ToInt32(this.txtidcategoria.Text),
                                                       Convert.ToInt32(this.cmbidpresentacion.SelectedValue));
                    }
                    else
                    {
                        respuesta = Narticulo.Editar(Convert.ToInt32(this.txtidarticulo.Text),
                                                     this.txtcodigo.Text, this.txtnombre.Text.Trim().ToUpper(), this.txtdescripcion.Text.Trim(),
                                                     imagen, Convert.ToInt32(this.txtidcategoria.Text),
                                                     Convert.ToInt32(this.cmbidpresentacion.SelectedValue));
                    }

                    if (respuesta.Equals("OK"))
                    {
                        if (this.Isnuevo)
                        {
                            this.Mensajeok(" Se inserto de forma correcta el registro");
                        }
                        else
                        {
                            this.Mensajeok(" Se actualizó de forma correcta el registro");
                        }
                    }
                    else
                    {
                        this.Mensajeerror(respuesta);
                    }

                    this.Isnuevo  = false;
                    this.Iseditar = false;
                    this.Botones();
                    this.limpiar();
                    this.mostrar();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #2
0
        private void btneliminar_Click(object sender, EventArgs e)
        {
            if (chkeliminar.Checked)
            {
                int Indice = 0;
                if (Convert.ToBoolean(datagridcategoria.Rows[Indice].Cells[0].Value) != false)
                {
                    try
                    {
                        DialogResult opcion;
                        opcion = MessageBox.Show(" Realmente desea eliminar los registros", "Sistema de ventas", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                        if (opcion == DialogResult.OK)
                        {
                            string codigo;
                            string respuesta = "";
                            foreach (DataGridViewRow row in datagridcategoria.Rows)
                            {
                                if (Convert.ToBoolean(row.Cells[0].Value))
                                {
                                    codigo    = Convert.ToString(row.Cells[1].Value);
                                    respuesta = Narticulo.Eliminar(Convert.ToInt32(codigo));

                                    if (respuesta.Equals("OK"))
                                    {
                                        this.Mensajeok(" Se elimino de forma correcta el registro");
                                    }
                                    else
                                    {
                                        this.Mensajeerror(respuesta);
                                    }
                                }
                            }
                            this.mostrar();
                            this.chkeliminar.Checked = false;
                        }
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message + ex.StackTrace);
                    }
                }
                else
                {
                    Mensajeerror("Debe Seleccionar un Articulo a Eliminar");
                    erroricono.SetError(datagridcategoria, "Seleccione un Articulo");
                }
            }
            else
            {
                Mensajeerror("Debe Checar la casilla de Eliminar");
                erroricono.SetError(chkeliminar, "Selecione la casilla");
            }
        }
コード例 #3
0
        private void btnEliminar_Click(object sender, EventArgs e)
        {
            try
            {
                DialogResult opcion =
                    MessageBox.Show("¿Realmente desea eliminar el/los artículos seleccionados?",
                    "Sistema de Ventas", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (opcion == DialogResult.Yes)
                {
                    int IdCategoria = 0;
                    string respuesta = "";

                    foreach (DataGridViewRow fila in dataListado.Rows)
                    {
                        if (Convert.ToBoolean(fila.Cells[0].Value))
                        {
                            IdCategoria = Convert.ToInt32(fila.Cells[1].Value);
                            respuesta = Narticulo.Eliminar(IdCategoria);

                            if (respuesta.Equals("Ok"))
                            {
                                Utilidades.MensajeOK("El artículo se elimino correctamente.");
                            }
                            else
                            {
                                Utilidades.MensajeError(respuesta);
                            }
                        }
                    }

                    Mostrar();
                    chkEliminar.Checked = false;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + ex.StackTrace);
            }
        }
コード例 #4
0
 //Metodo BuscarNombre
 private void BuscarNombre()
 {
     dataListado.DataSource = Narticulo.BuscarNombre(txtBuscar.Text);
     OcultarColumnas();
     lblTotal.Text = "Total Registros: " + dataListado.Rows.Count;
 }
コード例 #5
0
 //Metodo Mostrar
 private void Mostrar()
 {
     dataListado.DataSource = Narticulo.Mostrar();
     OcultarColumnas();
     lblTotal.Text = "Total Registros: " + dataListado.Rows.Count;
 }
コード例 #6
0
 public void buscarnombre()
 {
     this.datagridcategoria.DataSource = Narticulo.BuscarNombre(txtbuscar.Text);
     this.ocultarcolumnas();
     label2.Text = "Total de registros" + Convert.ToString(datagridcategoria.Rows.Count);
 }
コード例 #7
0
 public void mostrar()
 {
     this.datagridcategoria.DataSource = Narticulo.Mostrar();
     this.ocultarcolumnas();
     label2.Text = "Total de registros" + Convert.ToString(datagridcategoria.Rows.Count);
 }
コード例 #8
0
        private void btnGuardar_Click(object sender, EventArgs e)
        {
            try
            {
                string respuesta = "";

                if (txtNombre.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtNombre, "Ingrese un nombre");
                }
                else if (txtIdCategoria.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtCategoria, "Seleccione una Categoria");
                }
                else if (txtCodigos.Text == string.Empty)
                {
                    Utilidades.MensajeError("Falta ingresar algunos datos.");
                    errorIcono.SetError(txtCodigos, "Ingrese un valor");
                }
                else
                {
                    System.IO.MemoryStream ms = new System.IO.MemoryStream();

                    pxImagen.Image = Utilidades.CambiarTamanoImagen(pxImagen.Image, 50, 50);
                    pxImagen.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Png); //Formato de la imagen.

                    byte[] imagen = ms.GetBuffer();

                    if (isNuevo)
                    {
                        respuesta = Narticulo.Insertar(txtCodigos.Text, txtNombre.Text.Trim().ToUpper(), txtDescripcion.Text.Trim(), imagen, Convert.ToInt32(txtIdCategoria.Text), Convert.ToInt32(cbPresentacion.SelectedValue));
                    }
                    else
                    {
                        respuesta = Narticulo.Editar(Convert.ToInt32(txtIdArticulo.Text), txtCodigos.Text.Trim(), txtNombre.Text.Trim().ToUpper(), txtDescripcion.Text.Trim(), imagen, Convert.ToInt32(txtIdCategoria.Text), Convert.ToInt32(cbPresentacion.SelectedValue));
                    }

                    if (respuesta.Equals("Ok"))
                    {
                        if (isNuevo)
                        {
                            Utilidades.MensajeOK("El artículo se agregó correctamente");
                        }
                        else
                        {
                            Utilidades.MensajeOK("La artículo se editó correctamente");
                        }
                    }
                    else
                    {
                        Utilidades.MensajeError(respuesta);
                    }
                    isNuevo = false;
                    isEditar = false;
                    HabilitarBotones();
                    Limpiar();
                    Mostrar();
                }

            }
            catch (Exception ex)
            {
                Utilidades.MensajeError(ex.Message + ex.StackTrace);
            }
        }
コード例 #9
0
 //Metodo Mostrar
 private void Mostrar()
 {
     this.dataListado.DataSource = Narticulo.StockArticulos();
     lblTotal.Text = "Total Registros: " + dataListado.Rows.Count;
 }
コード例 #10
0
 public void Mostrararticulo()
 {
     Datagridcliente.DataSource = Narticulo.Mostrar();
 }