Esempio n. 1
0
        public string Modify(HttpContext context)
        {
            string name       = context.Request.QueryString["name"];
            string id         = context.Request.QueryString["id"];
            string url        = context.Request.QueryString["url"];
            string sort       = context.Request.QueryString["sort"];
            string opt        = context.Request.QueryString["opt"];
            string IconPath   = context.Request.QueryString["IconPath"];
            string IconName   = context.Request.QueryString["IconName"];
            string RowsButton = context.Request.QueryString["RowsButton"];

            string see = context.Request.QueryString["seeCharge"];
            string s   = "1";
            //Sys_Menu menumodel = bll.Find(id);
            Sys_Menu menumodel = bll.Get(p => p.MenuID == id);

            if (menumodel == null)
            {
                s = "0";
            }
            else
            {
                // menumodel.MenuID = id;

                menumodel.Menu_Name     = name;
                menumodel.Menu_Url      = url;
                menumodel.Menu_Sequence = int.Parse(sort);
                //menumodel.Menu_Operation = opt;
                menumodel.Menu_IconName = IconName;
                menumodel.Menu_IconPath = IconPath;

                List <Sys_MenuOperatingButton> OperatingButtonList = new List <Sys_MenuOperatingButton>();
                if (!string.IsNullOrEmpty(RowsButton))
                {
                    string Menu_Operation = string.Empty;
                    List <Sys_MenuOperatingButton> ButtonJsonList = JsonConvert.DeserializeObject <List <Sys_MenuOperatingButton> >(RowsButton);
                    foreach (var item in ButtonJsonList)
                    {
                        Sys_MenuOperatingButton ButtonModel = new Sys_MenuOperatingButton();
                        ButtonModel        = item;
                        ButtonModel.Id     = Guid.NewGuid().ToString();
                        ButtonModel.MenuId = menumodel.MenuID;
                        OperatingButtonList.Add(ButtonModel);
                        Menu_Operation += item.Name + ",";
                    }
                    if (Menu_Operation.Length > 0)
                    {
                        Menu_Operation = Menu_Operation.Substring(0, Menu_Operation.Length - 1);
                    }
                    menumodel.Menu_Operation = Menu_Operation;
                }

                List <Sys_SeeCharge> seList = new List <Sys_SeeCharge>();
                var da = see.Split('|');
                for (int i = 0; i < da.Count(); i++)
                {
                    var ds = da[i].Split('^');
                    if (!string.IsNullOrEmpty(ds[0]))
                    {
                        Sys_SeeCharge se = new Sys_SeeCharge();
                        se.SeeChargeID    = Guid.NewGuid().ToString();
                        se.SeeCharge_Name = ds[0].ToString();
                        se.SeeCharge_Code = ds[1].ToString();

                        se.SeeCharge_MenuID = menumodel.Menu_Code;

                        se.SeeCharge_Sort = i;

                        seList.Add(se);
                    }
                }


                //string msg = string.Empty;
                //if (seList.Count > 0)
                //{
                //    Sys_SeeChargeBLL bllSee = new Sys_SeeChargeBLL();

                //    bllSee.Delete(p => p.SeeCharge_MenuID == menumodel.Menu_Code);

                //    if (bllSee.Add(seList))
                //    {
                //        s = "1";
                //    }
                //    else
                //    {
                //        s = "0";
                //    }
                //}
                //else
                //{
                //    Sys_SeeChargeBLL bllSee = new Sys_SeeChargeBLL();

                //    bllSee.Delete(p => p.SeeCharge_MenuID == menumodel.Menu_Code);

                //}

                if (bll.UpdateMenuButton(menumodel, OperatingButtonList, seList))//bll.Update(menumodel)
                {
                    s = "1";
                }
                else
                {
                    s = "0";
                }
            }
            return(s);
        }
Esempio n. 2
0
        /// <summary>
        /// 新增
        /// </summary>
        public string Add(HttpContext context)
        {
            string name       = context.Request.QueryString["name"];
            string pcode      = context.Request.QueryString["pcode"];
            string url        = context.Request.QueryString["url"];
            string sort       = context.Request.QueryString["sort"];
            string opt        = context.Request.QueryString["opt"];
            string see        = context.Request.QueryString["seeCharge"];
            string IconPath   = context.Request.QueryString["IconPath"];
            string IconName   = context.Request.QueryString["IconName"];
            string RowsButton = context.Request.QueryString["RowsButton"];

            Sys_Menu menumodel = new Sys_Menu();

            menumodel.MenuID           = Guid.NewGuid().ToString();
            menumodel.Menu_ParentCode  = pcode;
            menumodel.Menu_Name        = name;
            menumodel.Menu_Level       = (bll.Get(p => p.Menu_Code == pcode).Menu_Level + 1);
            menumodel.Menu_Url         = url;
            menumodel.Menu_Description = "";
            menumodel.Menu_Sequence    = int.Parse(sort);
            menumodel.Menu_Code        = bll.GetMaxNum(pcode, "bh");
            menumodel.Menu_AddTime     = DateTime.Now;
            menumodel.Menu_AddUserID   = "";
            //menumodel.Menu_Operation = opt;
            menumodel.Menu_IconName = IconName;
            menumodel.Menu_IconPath = IconPath;

            List <Sys_MenuOperatingButton> OperatingButtonList = new List <Sys_MenuOperatingButton>();

            if (!string.IsNullOrEmpty(RowsButton))
            {
                string Menu_Operation = string.Empty;
                List <Sys_MenuOperatingButton> ButtonJsonList = JsonConvert.DeserializeObject <List <Sys_MenuOperatingButton> >(RowsButton);
                foreach (var item in ButtonJsonList)
                {
                    Sys_MenuOperatingButton ButtonModel = new Sys_MenuOperatingButton();
                    ButtonModel        = item;
                    ButtonModel.Id     = Guid.NewGuid().ToString();
                    ButtonModel.MenuId = menumodel.MenuID;
                    OperatingButtonList.Add(ButtonModel);
                    Menu_Operation += item.Name + ",";
                }
                if (Menu_Operation.Length > 0)
                {
                    Menu_Operation = Menu_Operation.Substring(0, Menu_Operation.Length - 1);
                }
                menumodel.Menu_Operation = Menu_Operation;
            }

            List <Sys_SeeCharge> seList = new List <Sys_SeeCharge>();
            var da = see.Split('|');

            for (int i = 0; i < da.Count(); i++)
            {
                var ds = da[i].Split('^');
                if (!string.IsNullOrEmpty(ds[0]))
                {
                    Sys_SeeCharge se = new Sys_SeeCharge();
                    se.SeeChargeID      = Guid.NewGuid().ToString();
                    se.SeeCharge_Name   = ds[0].ToString();
                    se.SeeCharge_Code   = ds[1].ToString();
                    se.SeeCharge_MenuID = menumodel.Menu_Code;
                    se.SeeCharge_Sort   = i;
                    seList.Add(se);
                }
            }

            bool abl = bll.AddMenuButton(menumodel, OperatingButtonList, seList);
            //bool abl = bll.Add(menumodel);

            string s = "1";

            //if (seList.Count > 0)
            //{
            //    Sys_SeeChargeBLL bllSee = new Sys_SeeChargeBLL();
            //    bllSee.Delete(p => p.SeeCharge_MenuID == menumodel.Menu_Code); //" SeeCharge_MenuID='" + menumodel.Menu_Code + "'"
            //    if (bllSee.Add(seList))
            //    {
            //        s = "1";
            //    }
            //    else
            //    {
            //        s = "0";
            //    }
            //}
            //else
            //{
            //    Sys_SeeChargeBLL bllSee = new Sys_SeeChargeBLL();
            //    bllSee.Delete(p => p.SeeCharge_MenuID == menumodel.Menu_Code);//" SeeCharge_MenuID='" + menumodel.Menu_Code + "'"
            //}


            if (abl)
            {
                s = "1";
            }
            else
            {
                s = "0";
            }

            return(s);
        }