예제 #1
0
 private void AddMenu()
 {
     try
     {
         this.dbo = new DB_OPT();
         this.dbo.Open();
         this.dbo.TranFar();
         if (this.txtMenuName.Text.Trim() == "")
         {
             Const.ShowMessage("请输入菜单名称!", this.Page);
         }
         else
         {
             MenuModel model = new MenuDal();
             MenuModel model2 = new MenuDal();
             if (model2.Exists(this.txtfwqxbm.Text.Trim(), this.dbo) > 0)
             {
                 Const.ShowMessage("菜单权限编码已经存在!", this.Page);
             }
             else
             {
                 string oldpath = "";
                 if (this.fl1.LoadFile.HasFile)
                 {
                     string menuUrl = ConfigMenu.MenuUrl;
                     oldpath = ConfigMenu.MenuUrl;
                     string str3 = Public.UpFile(base.Server.MapPath(Public.RelativelyPath(oldpath)), this.fl1.LoadFile.PostedFile);
                     if (menuUrl != "")
                     {
                         oldpath = menuUrl + "/" + str3;
                     }
                     else
                     {
                         oldpath = str3;
                     }
                 }
                 else
                 {
                     oldpath = this.fl1.ImageUrl;
                 }
                 model.FatherPK = this.FartherMenuPK.Value;
                 if (model.FatherPK != "")
                 {
                     model.MemuPK = model.FatherPK;
                     model = model.GetModel(false, this.dbo);
                     if (model.IsHasBaby == "0")
                     {
                         model2.MemuPK = model.MemuPK;
                         model2.UpdateHasBaby(this.dbo);
                     }
                     model2.PKPath = model.PKPath + model.MemuPK + "|";
                     model2.Grade = model.Grade + 1;
                 }
                 else
                 {
                     model2.Grade = 0;
                 }
                 model2.FatherPK = this.FartherMenuPK.Value.Trim();
                 model2.IsHasBaby = "0";
                 model2.PowerCode = this.txtfwqxbm.Text.Trim();
                 model2.Discription = this.txtMenuMemo.Text;
                 model2.MenuName = this.txtMenuName.Text;
                 model2.ImgUrl = oldpath;
                 model2.PageUrl = this.txtMenuUrl.Text;
                 model2.VisitPoint = int.Parse(this.txtTally.Text);
                 model2.OrderBy = int.Parse(this.txtMenuPX.Text);
                 model2.OpenType = this.drpdWindow.SelectedValue;
                 model2.IsCheckPower = this.drpdPodomZT.SelectedValue;
                 model2.IsShow = this.drpdIsList.SelectedValue;
                 model2.MenuType = this.DrpType.SelectedValue;
                 model2.pk_corp = this.Session["pk_corp"].ToString();
                 model2.Add(this.dbo);
                 this.dbo.Commit();
                 Const.DoSuccessOpen("", this.Page);
             }
         }
     }
     catch (Exception exception)
     {
         this.dbo.RollBack();
         this.el = new ExceptionLog.ExceptionLog();
         this.el.ErrClassName = base.GetType().ToString();
         this.el.ErrMessage = exception.Message.ToString();
         this.el.ErrMethod = "AddMenu()";
         this.el.WriteExceptionLog(true);
         Const.OpenErrorPage("操作失败,请联系管理员!", this.Page);
     }
     finally
     {
         if (this.dbo != null)
         {
             this.dbo.Close();
         }
     }
 }