Example #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //validaciones
                //verificar si hay existencias
                if (!verificaExistenciasProductos())
                {
                    return;
                }
                //verificar si hay detalle
                if (dgvLista.Rows.Count <= 0)
                {
                    MessageBox.Show(this, "Deben existir productos en la lista de salida", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                //asignacion de datos
                oEntrada.Total        = TOTAL;
                oEntrada.idUsuarioLog = Utilidades.clsUsuario.idUsuario;
                //llenar detalle
                foreach (DataGridViewRow dr in dgvLista.Rows)
                {
                    int cant = int.Parse(dr.Cells[1].Value.ToString());
                    for (int i = 0; i < cant; i++)
                    {
                        clsDetalleSalida de = new clsDetalleSalida();
                        de.CostoUnitario = decimal.Parse(dr.Cells[3].Value.ToString());
                        de.idProducto    = int.Parse(dr.Cells[0].Value.ToString());
                        oEntrada.lDetalle.Add(de);
                    }
                }
                //se guarda
                if (oEntrada.add())
                {
                    MessageBox.Show(this, "Registro agregado con éxito", "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    this.Close();
                }
                else
                {
                    MessageBox.Show(this, oProducto.getError(), "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (Exception EX)
            {
                MessageBox.Show(this, "Ocurrió un error de sistema " + EX.Message, "Aviso", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                //validaciones
                //verificar si hay existencias
                if (!verificaExistenciasProductos())
                {
                    return;
                }
                //verificar si hay detalle
                if(dgvLista.Rows.Count<=0){
                    MessageBox.Show("Deben existir productos en la lista de la salida");
                    return;
                }

                //asignacion de datos
                oEntrada.Total = TOTAL;
                oEntrada.idUsuarioLog = Utilidades.clsUsuario.idUsuario;
                //llenar detalle
                foreach (DataGridViewRow dr in dgvLista.Rows)
                {
                    int cant = int.Parse(dr.Cells[1].Value.ToString());
                    for (int i = 0; i < cant; i++)
                    {
                        clsDetalleSalida de= new clsDetalleSalida();
                        de.CostoUnitario = decimal.Parse(dr.Cells[3].Value.ToString());
                        de.idProducto = int.Parse(dr.Cells[0].Value.ToString());
                        oEntrada.lDetalle.Add(de);
                    }
                }
                //se guarda
                if (oEntrada.add())
                {
                    MessageBox.Show("Registro agregado con exito");
                    this.Close();
                }
                else
                    MessageBox.Show(oProducto.getError());

            }
            catch (Exception EX)
            {
                MessageBox.Show("Ocurrio un error de sistema " + EX.Message);
            }
        }