Пример #1
0
 private void DgvMaterias_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     if (DgvDetalle.Columns.Count > 2 && DgvDetalle.RowCount > 0)
     {
         string codMat = "";
         codMat     = DgvDetalle.GetFocusedRowCellValue(DgvDetalle.Columns["CodMateria"]).ToString();
         codMateria = codMat;
     }
 }
Пример #2
0
        private void DgvDetalleAlumno_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            BtnPrint.Enabled = false;

            DgvDetalle.DataSource = null;
            DgvDetalle.Rows.Clear();
            DgvDetalle.Refresh();

            int idAlumno = 0;

            foreach (DataGridViewRow row in DgvDetalleAlumno.SelectedRows)
            {
                nombreAlumno   = row.Cells[0].Value.ToString();
                apellidoAlumno = row.Cells[1].Value.ToString();
                idAlumno       = Convert.ToInt32(row.Cells[2].Value);
            }
            using (ModelContainer conexion = new ModelContainer())
            {
                this.DgvDetalleExamen.DataSource = conexion.Examenes.Where(p => p.alumnoIdAlumno == idAlumno && p.preguntasResueltas == p.numeroDePreguntas).Select(p => new { p.nombreExamen, p.fecha, p.IdExamen, p.numeroDePreguntas }).OrderByDescending(p => p.fecha).ToList();
            }

            DataTable dt = new DataTable();

            dt.Columns.AddRange(new DataColumn[6] {
                new DataColumn("Examen"), new DataColumn("Fecha"), new DataColumn("Correctas"),
                new DataColumn("Total"), new DataColumn("Porcentaje"), new DataColumn("idExamen")
            });


            foreach (DataGridViewRow row in DgvDetalleExamen.Rows)
            {
                int idExamen = Convert.ToInt32(row.Cells[2].Value);

                contarCorrectas(idExamen);

                examen          = row.Cells[0].Value.ToString();
                fecha           = row.Cells[1].Value.ToString();
                numeroPreguntas = row.Cells[3].Value.ToString();

                double calculoPorcentaje = (double)(preguntasCorrectas * 100) / Convert.ToInt32(numeroPreguntas);
                double aproxPorcentaje   = Math.Round(calculoPorcentaje, 2);

                porcentaje = aproxPorcentaje.ToString() + " %";



                dt.Rows.Add(examen, fecha, preguntasCorrectas, numeroPreguntas, porcentaje, idExamen);
            }

            this.DgvDetalleExamen.DataSource = dt;
            this.DgvDetalleExamen.Columns["idExamen"].Visible = false;
            this.DgvDetalleExamen.Refresh();
        }
        private async void BtnCancelar_Click(object sender, EventArgs e)
        {
            grid = true;
            TxtDescripcion.Clear();
            TxtIdentificacion.Clear();
            TxtTrabajador.Clear();
            TxtNumeroContrato.Clear();
            DgvDetalle.ClearSelection();
            DgvDetalle.Rows.Clear();
            btnAceptar.Enabled      = true;
            CboEstado.SelectedValue = 1;
            CboEstado.Enabled       = true;
            btnAceptar.Text         = "Aceptar";
            await LoadContratos(this.empresa, "");

            DgvEmpresa.ClearSelection();
        }
        private async void formContrato_Load(object sender, EventArgs e)
        {
            btnAceptar.IconChar = FontAwesome.Sharp.IconChar.CheckSquare;
            BtnNuevo.IconChar   = FontAwesome.Sharp.IconChar.PlusSquare;

            await LoadContratos(this.empresa, "");

            var estado = await db.EstadoContrato.ToListAsync();

            CboEstado.DataSource    = estado;
            CboEstado.DisplayMember = "est_descripcion";
            CboEstado.ValueMember   = "est_id";

            DgvDetalleColMotivo.DataSource = await db.Motivo.ToListAsync();

            DgvDetalleColMotivo.DisplayMember = "mot_descipcion";
            DgvDetalleColMotivo.ValueMember   = "mot_id";


            DgvEmpresa.ClearSelection();
            DgvDetalle.ClearSelection();
        }
Пример #5
0
        private void AgregarProducto(Producto producto)
        {
            var entry = new DetalleFactura()
            {
                Cantidad       = 1,
                Producto       = producto,
                IdProducto     = producto.Id,
                PrecioUnitario = producto.Precio,
                Subtotal       = producto.Precio * 1
            };
            int index = 0;

            foreach (var entity in detalleFacturaBindingSource)
            {
                if (((DetalleFactura)entity).IdProducto == entry.IdProducto)
                {
                    ((DetalleFactura)entity).Cantidad += 1;
                    ((DetalleFactura)entity).Subtotal  = ((DetalleFactura)entity).Cantidad * ((DetalleFactura)entity).PrecioUnitario;
                    index = detalleFacturaBindingSource.IndexOf(entity);
                    SumarTotal();
                    goto Refresh;
                }
            }
            detalleFacturaBindingSource.Add(entry);
            displayMemberDataGridViewTextBoxColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
            SumarTotal();
            DgvDetalle.CurrentCell = DgvDetalle.Rows[detalleFacturaBindingSource.Count - 1].Cells[3];
            DgvDetalle.BeginEdit(true);
            return;

Refresh:
            DgvDetalle.CurrentCell = DgvDetalle.Rows[index].Cells[5];
            DgvDetalle.RefreshEdit();
            DgvDetalle.CurrentCell = DgvDetalle.Rows[index].Cells[3];
            DgvDetalle.BeginEdit(true);
        }
Пример #6
0
        private void button2_Click(object sender, EventArgs e)
        {
            DgvDetalle.DataSource = null;

            DgvDetalle.Refresh();
        }
Пример #7
0
        public void LlenarGridConsulta2()
        {
            dsConsulta2.Tables.Clear();

            if (dsConsulta2.Tables.Count == 0)
            {
                dsConsulta2.Tables.Add(dtConsulta2Cab);
                dsConsulta2.Tables.Add(dtConsulta2Det);

                if (dsConsulta2.Relations.Count == 0)
                {
                    DataColumn keyColumn        = dsConsulta2.Tables["Cabecera"].Columns["CodArea"];
                    DataColumn foreignKeyColumn = dsConsulta2.Tables["Detalle"].Columns["CodArea"];

                    dsConsulta2.Relations.Add("Relacion", new DataColumn[] { keyColumn }, new DataColumn[] { foreignKeyColumn }, true);
                }
            }

            GctrlMaterias.DataSource = dsConsulta2.Tables["Cabecera"];
            GctrlMaterias.ForceInitialize();
            DgvMaterias.OptionsDetail.AllowExpandEmptyDetails       = true;
            DgvMaterias.OptionsDetail.AllowOnlyOneMasterRowExpanded = true;
            DgvMaterias.OptionsDetail.AllowZoomDetail             = true;
            DgvMaterias.OptionsDetail.SmartDetailExpand           = true;
            DgvMaterias.OptionsDetail.SmartDetailExpandButtonMode = DevExpress.XtraGrid.Views.Grid.DetailExpandButtonMode.CheckAllDetails;

            GctrlMaterias.LevelTree.Nodes.Add("Relacion", DgvDetalle);
            DgvDetalle.SynchronizeClones = false;
            DgvDetalle.ViewCaption       = "Materia(s)";


            #region Cabecera

            DgvMaterias.RefreshData();
            DgvMaterias.Columns.Clear();
            DgvMaterias.OptionsView.ColumnAutoWidth         = false;
            DgvMaterias.OptionsBehavior.AutoPopulateColumns = false;

            string[] captionsCab = new[] { "CodCurso", "CodArea", "NombreArea", "TotalPorcentaje" };

            GridColumn[] colCab = new GridColumn[dsConsulta2.Tables["Cabecera"].Columns.Count];
            for (int i = 0; i < dsConsulta2.Tables["Cabecera"].Columns.Count; i++)
            {
                colCab[i] = DgvMaterias.Columns.AddField(dsConsulta2.Tables["Cabecera"].Columns[i].Caption.Trim());
                colCab[i].VisibleIndex = i;
                colCab[i].Caption      = captionsCab[i];
                colCab[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

                if (i == 0 || i == 1)
                {
                    colCab[i].Visible = false;
                }
            }

            DgvMaterias.Columns[2].Width = 528;
            DgvMaterias.Columns[3].Width = 100;

            DevExpress.XtraEditors.Repository.RepositoryItemTextEdit numerico = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
            numerico.Mask.MaskType = DevExpress.XtraEditors.Mask.MaskType.Numeric;
            numerico.Mask.EditMask = "P0";
            numerico.Mask.UseMaskAsDisplayFormat = true;
            colCab[3].ColumnEdit = numerico;


            Funciones.getInstancia().Configurar_Grid(DgvMaterias);
            //DgvMaterias.OptionsCustomization.AllowSort = true;
            DgvMaterias.OptionsView.ColumnAutoWidth = false;


            #endregion

            #region detalle

            DgvDetalle.RefreshData();
            DgvDetalle.PopulateColumns(dsConsulta2.Tables["Detalle"]);
            DgvDetalle.Columns.Clear();
            DgvDetalle.OptionsBehavior.AutoPopulateColumns = false;

            string[] captions = new[] { "CodCurso", "CodMateria", "Materia", "IHS", "Porc. (%)", "CodProfesor", "Profesor", "CodArea" };

            GridColumn[] col = new GridColumn[dsConsulta2.Tables["Detalle"].Columns.Count];
            for (int i = 0; i < dsConsulta2.Tables["Detalle"].Columns.Count; i++)
            {
                col[i] = DgvDetalle.Columns.AddField(dsConsulta2.Tables["Detalle"].Columns[i].Caption.Trim());
                col[i].VisibleIndex = i;
                col[i].Caption      = captions[i];
                col[i].AppearanceHeader.TextOptions.HAlignment = DevExpress.Utils.HorzAlignment.Center;

                if (i == 0 || i == 1 || i == 5 || i == 7)
                {
                    col[i].Visible = false;
                }
            }

            DgvDetalle.Columns[2].Width = 240;
            DgvDetalle.Columns[3].Width = 50;
            DgvDetalle.Columns[4].Width = 60;
            DgvDetalle.Columns[6].Width = 245;

            col[4].ColumnEdit = numerico;

            Funciones.getInstancia().Configurar_Grid(DgvDetalle);
            DgvDetalle.OptionsCustomization.AllowSort = true;
            DgvDetalle.OptionsView.ColumnAutoWidth    = false;

            #endregion
        }