Example #1
0
        private void RefaccionesGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (RefaccionesGridView.Columns[e.ColumnIndex].DataPropertyName == "Salida")
                {
                    object valor = RefaccionesGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;

                    if (valor == null)
                    {
                        throw new Exception("No se pueden ingresar valores nulos");
                    }

                    Entities.Vista_OrdenesServiciosRefaccionesAlmacen osr = (Entities.Vista_OrdenesServiciosRefaccionesAlmacen)RefaccionesGridView.Rows[e.RowIndex].DataBoundItem;
                    if (Convert.ToInt32(valor) < 0)
                    {
                        throw new Exception("No se pueden ingresar valores negativos");
                    }

                    if (Convert.ToInt32(valor) > osr.PorSurtir)
                    {
                        throw new Exception("Se esta dando salida a un numero mayor de lo que se debe surtir");
                    }
                }
            }
            catch (Exception ex)
            {
                RefaccionesGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value = 0;
                AppHelper.Error(ex.Message);
            }
        }
Example #2
0
        private void RefaccionesGridView_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            AppHelper.Try(
                delegate
            {
                if (vista_OrdenesServiciosRefaccionesAlmacenBindingSource.DataSource != null)
                {
                    this.SurtirTodasButton.Enabled         = true;
                    this.RegistrarMovimientoButton.Enabled = true;

                    bool FaltaInventario = false;
                    int cont, totalrows;

                    totalrows = this.RefaccionesGridView.Rows.Count;
                    cont      = 0;

                    foreach (DataGridViewRow row in RefaccionesGridView.Rows)
                    {
                        Entities.Vista_OrdenesServiciosRefaccionesAlmacen osr =
                            (Entities.Vista_OrdenesServiciosRefaccionesAlmacen)row.DataBoundItem;

                        if (osr.PorSurtir.Value > osr.CantidadInventario.Value)
                        {
                            row.DefaultCellStyle.BackColor = Color.Red;
                            row.DefaultCellStyle.ForeColor = Color.White;

                            FaltaInventario = true;

                            cont++;
                        }
                    }

                    if (FaltaInventario)
                    {
                        AppHelper.Info(@"Existen refacciones que no se pueden surtir por falta de inventario
- Resaltadas en rojo -");
                    }

                    if (cont == totalrows)
                    {
                        AppHelper.Error(@"Ninguna refacción puede surtirse por falta de inventario");
                        this.SurtirTodasButton.Enabled         = false;
                        this.RegistrarMovimientoButton.Enabled = false;
                    }
                }
            }
                );
        }