コード例 #1
0
        public bool Edit(remotasDTO Editedclass)
        {
            bool aux = false;
            var  x   = Editedclass;

            try
            {
                using (var db = new Data())
                {
                    var pac = (from p in db.Remotas where p.remotaid == Editedclass.remotaid select p).FirstOrDefault();
                    if (pac != null)
                    {
                        pac.remotaid = Editedclass.remotaid;
                        pac.remota   = x.remota;
                        pac.nombre   = x.nombre;
                    }
                    db.Entry(pac).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            catch (DbEntityValidationException e)
            {
                aux = false;
            }
            return(aux);
        }
コード例 #2
0
        public void InsertClase(remotasDTO NewClase)
        {
            var x = NewClase;

            using (var db = new Data())
            {
                db.Remotas.Add(new remotas()
                {
                    remota = NewClase.remota,
                    nombre = NewClase.nombre
                });

                db.SaveChanges();
            }
        }
コード例 #3
0
        public remotasDTO GetRemotaDTO(int id)
        {
            remotasDTO B     = new remotasDTO();
            remotas    query = null;

            using (var db = new Data())
            {
                query = (from x in db.Remotas where x.remotaid == id select x).FirstOrDefault();
            }
            if (query != null)
            {
                B = new remotasDTO {
                    remotaid = query.remotaid, remota = query.remota, nombre = query.nombre
                }
            }
            ;
            return(B);
        }
コード例 #4
0
        private void Carga_Busqueda()
        {
            Search_Params Sp = new Search_Params();

            Sp.data       = remotaManager.GetAll();
            Sp.palabra    = "";
            Sp.parametros = new List <string>();
            Sp.parametros.Add("Nombre");

            BusquedaFrm BF = new BusquedaFrm(Sp);

            BF.ShowDialog();
            var seleccion = BF.GetValue();

            if (seleccion > -1)
            {
                currentindex  = seleccion;
                currentRemota = remotaManager.GetRemotaDTO(currentindex);
                DespliegaCampos();
            }
        }
コード例 #5
0
        public void SeleccionoBarra()
        {
            this.textoBoxp2.Focus();
            if (comandBar1.Status == RecordAction.Search)
            {
                Carga_Busqueda();
            }
            if (comandBar1.Status == RecordAction.None)
            {
                this.panel1.Enabled = false;
            }
            if (comandBar1.Status == RecordAction.Insert || (comandBar1.Status == RecordAction.Update))
            {
                this.panel1.Enabled = true;
                this.panel1.Select();
                if (comandBar1.Status == RecordAction.Insert)
                {
                    initField();
                }
                textoBoxp2.Focus();
            }

            if (comandBar1.Status == RecordAction.Delete && comandBar1.confirma)
            {
                remotaManager.Delete(currentRemota.remotaid);
                this.comandBar1.confirma = false;
                initField();
                panel1.Enabled = false;
                Utilities.Mensaje(errorBar1, "El registro fue Borrado", errorType.Error);
            }
            if (comandBar1.Status == RecordAction.Save)
            {
                var aux = validaforma();
                if (aux != "")
                {
                    errorBar1.Mensaje = aux;
                    errorBar1.Status  = errorType.Error;
                    this.comandBar1.Novalido();
                    return;
                }
                if (comandBar1.Status == RecordAction.Save && comandBar1.previo == RecordAction.Insert && aux == "")
                {
                    var remota = new remotas {
                        remota = textoBoxp3.Text, remotaid = 0, nombre = textoBoxp2.Text
                    };
                    var remotaDTO = new remotasDTO {
                        remota = textoBoxp3.Text, remotaid = 0, nombre = textoBoxp2.Text
                    };
                    var aux1 = validarRegistro(remota);
                    if (aux1.Length > 0)
                    {
                        Utilities.Mensaje(errorBar1, aux1, errorType.Error);
                        return;
                    }
                    remotaManager.InsertClase(remotaDTO);
                    this.comandBar1.previo = RecordAction.None;
                    Utilities.Controles(this, "Reset");
                    panel1.Enabled = false;
                }

                if (comandBar1.Status == RecordAction.Save && comandBar1.previo == RecordAction.Update && aux == "")
                {
                    var remota = new remotas {
                        remota = textoBoxp3.Text, remotaid = Convert.ToInt16(labelindex.Text), nombre = textoBoxp2.Text
                    };
                    var remotaDTO = new remotasDTO {
                        remota = textoBoxp3.Text, remotaid = Convert.ToInt16(labelindex.Text), nombre = textoBoxp2.Text
                    };
                    var aux1 = validarRegistro(remota);
                    if (aux1.Length > 0)
                    {
                        Utilities.Mensaje(errorBar1, aux1, errorType.Error);
                        return;
                    }
                    remotaManager.Edit(remotaDTO);
                    this.comandBar1.previo = RecordAction.None;
                    Utilities.Controles(this, "Reset");
                    panel1.Enabled = false;
                }
            }
        }