Beispiel #1
0
 public SingleTipoCombustible(SaveAction action)
 {
     InitializeComponent();
     currentAction = action;
     TypeInit();
     currentType = new CombustiblesTipos();
 }
Beispiel #2
0
        public void Save(CombustiblesTipos tipo, SaveAction accion)
        {
            using (var ctx = new GrullonRCEntities())
            {
                if (accion == SaveAction.Agregar)
                {
                    ctx.CombustiblesTipos.Add(tipo);
                }

                if (accion == SaveAction.Editar)
                {
                    var toUpdate = ctx.CombustiblesTipos.FirstOrDefault(x => x.Id == tipo.Id);
                    toUpdate.Descripcion = tipo.Descripcion;
                    toUpdate.Estado      = tipo.Estado;
                }

                if (accion == SaveAction.Eliminar)
                {
                    var toDelete = ctx.CombustiblesTipos.FirstOrDefault(x => x.Id == tipo.Id);
                    toDelete.Deleted = true;
                }

                ctx.SaveChanges();
            }
        }
Beispiel #3
0
        public SingleTipoCombustible(SaveAction action, CombustiblesTipos tipo)
        {
            InitializeComponent();
            currentAction = action;
            TypeInit();

            //Codigo de asignación
            textBox1.Text     = tipo.Descripcion;
            checkBox1.Checked = tipo.Estado;
            //

            currentType = tipo;
        }