/// <summary> /// Implementa Save_button_Click /// </summary> protected override void SaveAction() { _entity.FechaCreacion = DateTime.Now; _entity.FechaEmision = DateTime.MaxValue; if (!FExamen_DTP.Checked) { _entity.FechaExamen = DateTime.MaxValue; } foreach (KeyValuePair <string, PromocionInfo> info in _promociones_select) { bool esta = false; foreach (ExamenPromocion expr in _entity.Promociones) { if (expr.OidPromocion == info.Value.Oid) { esta = true; break; } } if (!esta) { ExamenPromocion item = _entity.Promociones.NewItem(_entity); item.OidPromocion = info.Value.Oid; } } _action_result = SaveObject() ? DialogResult.OK : DialogResult.Ignore; }
private void Promocion_BT_Click(object sender, EventArgs e) { if (promociones == null) { return; } if (this is ExamenViewForm) { return; } try { PromocionSelectForm form = new PromocionSelectForm(this, promociones); if (form.ShowDialog(this) == DialogResult.OK) { if (form.Selected is PromocionInfo) { PromocionInfo info = form.Selected as PromocionInfo; ExamenPromocion item = Entity.Promociones.GetItem(new FCriteria <long>("OidPromocion", info.Oid)); if (item == null) { ExamenPromocion nuevo = Entity.Promociones.NewItem(Entity); nuevo.OidPromocion = info.Oid; } } else if (form.Selected is SortedBindingList <PromocionInfo> ) { SortedBindingList <PromocionInfo> promos = form.Selected as SortedBindingList <PromocionInfo>; foreach (PromocionInfo info in promos) { ExamenPromocion item = Entity.Promociones.GetItem(new FCriteria <long>("OidPromocion", info.Oid)); if (item == null) { ExamenPromocion nuevo = Entity.Promociones.NewItem(Entity); nuevo.OidPromocion = info.Oid; } } } RellenaPromociones(); } } catch { throw new iQException("Promocion_BT_Click"); } }
private void Promociones_CLB_ItemCheck(object sender, ItemCheckEventArgs e) { if (this is ExamenViewForm) { return; } if (e.NewValue == e.CurrentValue) { return; } try { PromocionInfo promo = _promociones_todas[Promociones_CLB.Items[e.Index].ToString()]; if (e.NewValue == CheckState.Unchecked) { ExamenPromocion item = Entity.Promociones.GetItem(new FCriteria <long>("OidPromocion", promo.Oid)); foreach (Alumno_Examen alumno in Entity.Alumnos) { if (alumno.OidPromocion == promo.Oid) { MessageBox.Show("No se puede eliminar un curso que tiene alumnos incluidos en el examen."); return; } } Entity.Promociones.Remove(item); RellenaPromociones(); } else if (e.NewValue == CheckState.Checked) { ExamenPromocion esta = Entity.Promociones.GetItem(new FCriteria <long>("OidPromocion", promo.Oid)); if (esta == null) { ExamenPromocion item = Entity.Promociones.NewItem(Entity); item.OidPromocion = promo.Oid; RellenaPromociones(); } } } catch { throw new iQException("Promociones_CLB_ItemCheck"); } }