private void FrmEntradaPCP_Load(object sender, EventArgs e) { try { using (var context = new Profit_RGEntities()) { timer1.Start(); timer1.Interval = 10000; grdentradaPCP.DataSource = ""; grdentradaPCP.AutoGenerateColumns = false; CargarEntradas(); //var X = Screen.PrimaryScreen.Bounds.Width; //var Y = Screen.PrimaryScreen.Bounds.Height; //this.DesktopLocation = new Point(X - this.Width, Y - this.Height - 235); var oo = context.pConfirmarEntradaPCP2().Count(); if (oo <= 0) { lbl_entradas.Text = "No hay Entradas para Hoy"; buttonX1.Enabled = false; } else { lbl_entradas.Visible = true; buttonX1.Enabled = true; } } } catch (EntityException ex) { MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex1) { MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
void CargarEntradas() { try { using (Profit_RGEntities context = new Profit_RGEntities()) { var G = context.pConfirmarEntradaPCP2().ToList(); entradaPCP.Clear(); foreach (var item in G) { entradaPCP.Add(new EntradaPCP { id_mov = item.ID, empleado = item.Empleado, activo = item.Activo, descripcion = item.Descripcion_del_Activo, serial = item.serial, fecha_entrega = Convert.ToDateTime(item.Hasta).ToShortDateString(), }); } grdentradaPCP.DataSource = ""; grdentradaPCP.DataSource = entradaPCP; grdentradaPCP.AutoGenerateColumns = false; grdentradaPCP.Refresh(); } } catch (EntityException ex) { MessageBox.Show(ex.InnerException.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex1) { MessageBox.Show(ex1.Message, "Profit Expansion", MessageBoxButtons.OK, MessageBoxIcon.Error); } }