Example #1
0
        protected void btnAddMenu_Click(object sender, EventArgs e)
        {
            try
            {
                WebMenu oMenu = null;

                if (!string.IsNullOrEmpty(this.lblMenuId.Text))
                {
                    oMenu = new DataAccess.Web().GetMenu(int.Parse(this.lblMenuId.Text));
                    oMenu.Seccion = this.txtSeccion.Text;
                    oMenu.Descripcion = this.txtDesc.Text;
                    oMenu.Orden = Convert.ToInt32(this.txtOrden.Text);
                    oMenu.Url = this.txtUrl.Text;
                    oMenu.Estado = this.ddlActivo.SelectedValue == "1" ? true : false;

                    new DataAccess.Web().UpdateMenu(oMenu);
                }
                else
                {
                    oMenu = new WebMenu();

                    oMenu.Seccion = this.txtSeccion.Text;
                    oMenu.Descripcion = this.txtDesc.Text;
                    oMenu.Orden = Convert.ToInt32(this.txtOrden.Text);
                    oMenu.Url = this.txtUrl.Text;
                    oMenu.Estado = this.ddlActivo.SelectedValue == "1" ? true : false;

                    new DataAccess.Web().AddMenu(oMenu);
                }

                ClearForm();

                this.FillGridMenu();
            }
            catch (Exception ex)
            {
                this.lblErrorMenu.Text = ex.Message;
                SaveTechLog(System.Reflection.MethodBase.GetCurrentMethod().Name, LevelError.ERROR, ex,
                    "Sección: " + this.txtSeccion.Text +
                    "Orden: " + this.txtOrden.Text +
                    "Url: " + this.txtUrl.Text +
                    "Descripción: " + this.txtDesc.Text +
                    "Estado: " + this.ddlActivo.SelectedValue);
            }
        }
Example #2
0
File: Web.cs Project: GeraElem/VS
        public void AddMenu(WebMenu menu)
        {
            try
            {
                using (var context = new QuirofanoEntities())
                {
                    context.WebMenu.AddObject(menu);

                    context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                if (ex.InnerException.Message.Contains("23505"))
                    throw new Exception("Error: no puede asignar dos menus con el mismo nombre.");
                else
                    throw new Exception(ex.Message);
            }
        }
Example #3
0
File: Web.cs Project: GeraElem/VS
        public void UpdateMenu(WebMenu menu)
        {
            using (var context = new QuirofanoEntities())
            {
                //WebMenu menu2 = context.WebMenu.First(i => i.WebMenuId == menu.WebMenuId);

                //menu2.Descripcion = menu.Descripcion;
                //menu2.Orden = menu.Orden;
                //menu2.Url = menu.Url;
                //menu2.Estado = menu.Estado;

                context.WebMenu.Attach(context.WebMenu.Single(i => i.WebMenuId == menu.WebMenuId));

                context.WebMenu.ApplyCurrentValues(menu);

                int inte = context.SaveChanges(SaveOptions.DetectChangesBeforeSave);

                context.SaveChanges();
            }
        }
Example #4
0
        private void FixupWebMenu(WebMenu previousValue)
        {
            if (previousValue != null && previousValue.WebNoticias.Contains(this))
            {
                previousValue.WebNoticias.Remove(this);
            }

            if (WebMenu != null)
            {
                if (!WebMenu.WebNoticias.Contains(this))
                {
                    WebMenu.WebNoticias.Add(this);
                }
                if (WebMenuId != WebMenu.WebMenuId)
                {
                    WebMenuId = WebMenu.WebMenuId;
                }
            }
            else if (!_settingFK)
            {
                WebMenuId = null;
            }
        }