示例#1
0
    protected void btnAgregar_Click(object sender, EventArgs e)
    {
        lblErrores.Text = "";
        Familias familia = new Familias();

        familia.Unidad = txtClave.Text;
        familia.verificaExiste();
        bool existeFamilia = familia.Existe;

        if (!existeFamilia)
        {
            SqlDataSource1.InsertCommand = "insert into catfamilias(idFamilia,descripcionFamilia) values(@idFamilia,@descripcionFamilia)";
            SqlDataSource1.InsertParameters.Add("idFamilia", txtClave.Text);
            SqlDataSource1.InsertParameters.Add("descripcionFamilia", txtDescripcion.Text);
            try
            {
                SqlDataSource1.Insert();
                GridView1.DataBind();
                txtClave.Text = txtDescripcion.Text = "";
            }
            catch (Exception ex)
            {
                lblErrores.Text = "Error al agregar la familia " + txtClave.Text + ": " + ex.Message;
            }
        }
        else
        {
            lblErrores.Text = "La familia a ingresar ya se encuentra registrada";
        }
    }
示例#2
0
 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 {
     if (e.Row.RowType == DataControlRowType.DataRow)
     {
         checaSesiones();
         if (usuarioLog != null)
         {
             if (e.Row.RowState.ToString() == "Normal" || e.Row.RowState.ToString() == "Alternate")
             {
                 var      btnEliminar = e.Row.Cells[2].Controls[1].FindControl("btnEliminar") as Button;
                 string   clave       = DataBinder.Eval(e.Row.DataItem, "idFamilia").ToString();
                 Familias familia     = new Familias();
                 familia.Unidad = clave;
                 familia.verificaRelacion();
                 if (familia.Relacionado)
                 {
                     btnEliminar.Text     = "Elimina";
                     btnEliminar.Enabled  = false;
                     btnEliminar.CssClass = "btn-default ancho50px";
                 }
                 else
                 {
                     btnEliminar.OnClientClick = "return confirm('¿Está seguro de eliminar la Familia " + clave + "?')";
                     btnEliminar.Text          = "Elimina";
                     btnEliminar.Enabled       = true;
                     btnEliminar.CssClass      = "btn-danger ancho50px";
                 }
             }
         }
         else
         {
             Response.Redirect("Default.aspx");
         }
     }
 }
示例#3
0
        public async Task <IActionResult> Edit(int id, [Bind("IDFamilias,Nome,Telefone,Email,Morada,Rendimento,NumeroPessoasAgregado")] Familias familias)
        {
            var email     = familias.Email;
            var morada    = familias.Morada;
            var telefone  = familias.Telefone;
            var idFamilia = familias.IDFamilias;

            if (id != familias.IDFamilias)
            {
                return(NotFound());
            }

            //Validar Email
            if (emailrepetidoEditar(email, idFamilia) == true)
            {
                //Mensagem de erro se o email for repetido
                ModelState.AddModelError("Email", "Este email já existe");
            }

            //Validar morada
            if (moradarepetidaEditar(morada, idFamilia) == true)
            {
                //Mensagem de erro se a morada ja existir noutro registo
                ModelState.AddModelError("Morada", "Esta morada já foi utilizada");
            }
            //Validar Contacto
            if (contactorepetidoEditar(telefone, idFamilia))
            {
                //Mensagem de erro se o contacto ja existe
                ModelState.AddModelError("Telefone", "Contacto já utilizado");
            }


            if (ModelState.IsValid)
            {
                try
                {
                    if (!emailrepetidoEditar(email, idFamilia) || moradarepetidaEditar(morada, idFamilia) || contactorepetidoEditar(telefone, idFamilia))
                    {
                        _context.Update(familias);
                        await _context.SaveChangesAsync();

                        TempData["successEdit"] = "Registo alterado com sucesso";
                    }
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!FamiliasExists(familias.IDFamilias))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(familias));
        }
示例#4
0
        public async Task <ActionResult <Familias> > PostFamilias(Familias familias)
        {
            _context.Familias.Add(familias);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetFamilias", new { id = familias.ID }, familias));
        }
示例#5
0
        public async Task <IActionResult> PutFamilias(int id, Familias familias)
        {
            if (id != familias.ID)
            {
                return(BadRequest());
            }

            _context.Entry(familias).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FamiliasExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
示例#6
0
        private void BtnMaeFamilias_Click(object sender, EventArgs e)
        {
            Familias Fami = Familias.ObtenInstancia();

            MAE.FrmMae FrmConfMae = new LFVBNewTPV.MAE.FrmMae(Fami);
            FrmConfMae.MdiParent = this;
            FrmConfMae.Show();
        }
示例#7
0
        public ActionResult DeleteConfirmed(int id)
        {
            Familias familias = db.Familias.Find(id);

            db.Familias.Remove(familias);
            db.SaveChanges();
            DisplaySuccessMessage("Has delete a Familias record");
            return(JsonRedirectToAction("Index"));
        }
        //
        // GET: /CategoryPage/

        public ActionResult Category(string id)
        {
            StdBELista objList = PriEngine.Engine.Consulta("SELECT Descricao from FAMILIAS WHERE Familia LIKE '" + id + "'");
            Familias   fam     = new Familias {
                Familia = id, Descricao = objList.Valor("Descricao")
            };

            return(View(fam));
        }
示例#9
0
 /// <summary>
 /// Remove familia da lista
 /// </summary>
 /// <param name="idFamilia">Id da familia</param>
 /// <returns>
 /// -1  Familia atribuida em algum artigo
 /// 0   Familia não existe
 /// 1   Familia Removida
 /// </returns>
 public static int RemoveFamilia(int idFamilia)
 {
     if (Model.Artigos.DevolveArtigosPorFamilia(idFamilia).Count == 0)
     {
         if (Familias.RemoveFamilia(idFamilia))
         {
             return(1);
         }
         return(0);
     }
     return(-1);
 }
示例#10
0
        // GET: Familias/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Familias familias = db.Familias.Find(id);

            if (familias == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(familias));
        }
示例#11
0
 public ActionResult Edit([Bind(Include = "Id,CodFamilia,Familia,EstadoId,PadreId,Bienes,Estados,Familias1,Familias2,Historicos")] Familias familias)
 {
     if (ModelState.IsValid)
     {
         db.Entry(familias).State = EntityState.Modified;
         db.SaveChanges();
         DisplaySuccessMessage("Has update a Familias record");
         return(JsonRedirectToAction("Index"));
     }
     ViewBag.EstadoId = new SelectList(db.Estados, "Id", "Nombre", familias.EstadoId);
     ViewBag.PadreId  = new SelectList(db.Familias, "Id", "CodFamilia", familias.PadreId);
     DisplayErrorMessage();
     return(PartialView(familias));
 }
示例#12
0
        // GET: Familias/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Familias familias = db.Familias.Find(id);

            if (familias == null)
            {
                return(HttpNotFound());
            }
            ViewBag.EstadoId = new SelectList(db.Estados, "Id", "Nombre", familias.EstadoId);
            ViewBag.PadreId  = new SelectList(db.Familias, "Id", "CodFamilia", familias.PadreId);
            return(PartialView(familias));
        }
示例#13
0
        public void ConfiguraColumnasMae()
        {
            switch (this._maestro.GetType().Name)
            {
            case "TipoDocumentos":
                this.cFamilias.Visible   = false;
                this.cPorIva.Visible     = false;
                this.cVigenteIva.Visible = false;
                break;

            case "TipoPersonas":
                this.cFamilias.Visible   = false;
                this.cPorIva.Visible     = false;
                this.cVigenteIva.Visible = false;
                break;

            case "Familias":
                this.cFamilias.Visible   = false;
                this.cPorIva.Visible     = false;
                this.cVigenteIva.Visible = false;
                break;

            case "Subfamilias":
                this.cFamilias.Visible   = true;
                this.cPorIva.Visible     = false;
                this.cVigenteIva.Visible = false;
                Familias aux = Familias.ObtenInstancia();
                this.cFamilias.DataSource       = aux.Datos.Copy();
                this.cFamilias.ValueMember      = "COD_FAMI";
                this.cFamilias.DisplayMember    = "NOMBRE_FAMI";
                this.cFamilias.DataPropertyName = "COD_FAMI";
                break;

            case "IVA":
                this.cFamilias.Visible   = false;
                this.cPorIva.Visible     = true;
                this.cVigenteIva.Visible = true;
                break;

            case "EstadoReservas":
                this.cFamilias.Visible   = false;
                this.cPorIva.Visible     = false;
                this.cVigenteIva.Visible = false;
                break;
            }
        }
示例#14
0
        public async Task <IActionResult> Create([Bind("IDFamilias,Nome,Telefone,Email,Morada,Rendimento,NumeroPessoasAgregado")] Familias familias)
        {
            var email    = familias.Email;
            var morada   = familias.Morada;
            var telefone = familias.Telefone;


            //Validar Email
            if (emailrepetidoCriar(email) == true)
            {
                //Mensagem de erro se o email for inválido
                ModelState.AddModelError("Email", "Este email já existe");
            }

            //Validar morada
            if (moradarepetidaCriar(morada) == true)
            {
                //Mensagem de erro se a morada ja existir noutro registo
                ModelState.AddModelError("Morada", "Esta morada já foi utilizada");
            }
            //Validar Contacto
            if (contactorepetidoCriar(telefone))
            {
                //Mensagem de erro se o contacto ja existe
                ModelState.AddModelError("Telefone", "Contacto já utilizado");
            }



            if (ModelState.IsValid)
            {
                if (!emailrepetidoCriar(email) || moradarepetidaCriar(morada) || contactorepetidoCriar(telefone))
                {
                    _context.Add(familias);

                    await _context.SaveChangesAsync();

                    TempData["notice"] = "Registo inserido com sucesso!";
                    return(RedirectToAction(nameof(Index)));
                }
            }
            return(View(familias));
        }
示例#15
0
        private void InicializarBarraBusqueda()
        {
            this.listadoGenProd = Productos.ObtenInstancia();

            Subfamilias auxSF = Subfamilias.ObtenInstancia();

            this.CmbSubFamiliaDef.ComboBox.DataSource    = auxSF.Datos.Copy();
            this.CmbSubFamiliaDef.ComboBox.DisplayMember = "NOMBRE_SUFA";
            this.CmbSubFamiliaDef.ComboBox.ValueMember   = "COD_FAMI";

            Familias auxF = Familias.ObtenInstancia();

            this.CmbFamiliaDef.ComboBox.DataSource    = auxF.Datos.Copy();
            this.CmbFamiliaDef.ComboBox.DisplayMember = "NOMBRE_FAMI";
            this.CmbFamiliaDef.ComboBox.ValueMember   = "COD_FAMI";
            if (this.CmbFamiliaDef.ComboBox.SelectedValue != null)
            {
                ((DataTable)this.CmbSubFamiliaDef.ComboBox.DataSource).DefaultView.RowFilter = "COD_FAMI='" + this.CmbFamiliaDef.ComboBox.SelectedValue.ToString() + "'";
            }
        }
示例#16
0
        public void InicializarDesplegables()
        {
            Subfamilias aux2 = Subfamilias.ObtenInstancia();

            this.CmbSubfamilia.DataSource    = aux2.Datos.Copy();
            this.CmbSubfamilia.DisplayMember = "NOMBRE_SUFA";
            this.CmbSubfamilia.ValueMember   = "COD_SUFA";


            Familias aux = Familias.ObtenInstancia();

            this.CmbFamilia.DataSource    = aux.Datos.Copy();
            this.CmbFamilia.DisplayMember = "NOMBRE_FAMI";
            this.CmbFamilia.ValueMember   = "COD_FAMI";

            this._AuxIva = IVA.ObtenInstancia();
            this.CmbPorIva.DataSource    = this._AuxIva.Datos;
            this.CmbPorIva.ValueMember   = "COD_TIVA";
            this.CmbPorIva.DisplayMember = "DESCR_TIVA";
        }
示例#17
0
 public void InicializarDatos()
 {
     this.OEntrada = new ArrayList();
     try
     {
         this.LstProductos = Productos.ObtenInstancia();
         Familias MaeFam = Familias.ObtenInstancia();
         this.CCodFamilia.DataSource    = MaeFam.Datos.Copy();
         this.CCodFamilia.ValueMember   = "COD_FAMI";
         this.CCodFamilia.DisplayMember = "NOMBRE_FAMI";
         Subfamilias MaeSufa = Subfamilias.ObtenInstancia();
         this.cCodSufa.DataSource    = MaeSufa.Datos.Copy();
         this.cCodSufa.ValueMember   = "COD_SUFA";
         this.cCodSufa.DisplayMember = "NOMBRE_SUFA";
         this.DGDatos.DataSource     = this.LstProductos.Datos;
     }
     catch (Exception err)
     {
         SISTEMA.MENSAJES.FrmError FrmErr = new LFVBNewTPV.SISTEMA.MENSAJES.FrmError(err);
     }
 }
示例#18
0
 /// <summary>
 /// Devolve todas as familias
 /// </summary>
 /// <returns>Retorna uma lista de familias</returns>
 public static List <Familia> DevolveFamilias()
 {
     return(Familias.DevolveFamilias());
 }
示例#19
0
 /// <summary>
 /// Devolve todas as familias ordenadas descentemente
 /// </summary>
 /// <returns>Retorna uma lista de familias</returns>
 public static List <Familia> DevolveFamiliasOrdenadasDesc()
 {
     return(Familias.DevolveFamilias().OrderByDescending(a => a.DescCurta).ToList());
 }
示例#20
0
 /// <summary>
 /// Devolve familia por o id da familia
 /// </summary>
 /// <param name="idFamilia">Id da familia</param>
 /// <returns>Retorna uma familia ou null</returns>
 public static Familia DevolveFamiliaById(int idFamilia)
 {
     return(Familias.DevolveFamiliaPorId(idFamilia));
 }
示例#21
0
 /// <summary>
 /// Adiciona familia
 /// </summary>
 /// <param name="desc">descrição</param>
 /// <returns>
 /// True = Adicionou nova familia
 /// False = Familia ja existe
 /// </returns>
 public static bool AddFamilia(string desc, int ordImpressao)
 {
     return(Familias.AddFamilia(desc, ordImpressao));
 }
示例#22
0
 /// <summary>
 /// Verifica se existe familias
 /// </summary>
 /// <returns>retorna se encontra alguma familia</returns>
 public static bool ExisteFamilias()
 {
     return(Familias.DevolveFamilias().Count > 0 ? true : false);
 }