Exemplo n.º 1
0
 public static bool createMenu(t_Menu menu)
 {
     using (DataClassesEduDataContext dc = new DataClassesEduDataContext())
     {
         dc.t_Menu.InsertOnSubmit(menu);
         dc.SubmitChanges();
         return true;
     }
 }
Exemplo n.º 2
0
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if((string)ViewState["mode"] == "add")
            {
                try
                {
                    t_Menu menu = new t_Menu();
                    menu.Id = Convert.ToInt32( tbMenuId.Text);
                    menu.name = tbName.Text;
                    menu.url = tbUrl.Text;
                    menu.status = CheckBoxStatus.Checked;

                    if (!String.IsNullOrEmpty(DropDownListParentNode.SelectedValue))
                        menu.parentId = Convert.ToInt32(DropDownListParentNode.SelectedValue);
                    else
                        menu.parentId = 0;
                    if (!String.IsNullOrEmpty(DropDownSys.SelectedValue))
                        menu.sysId = Convert.ToInt32(DropDownSys.SelectedValue);
                    else
                        menu.sysId = null;
                    BLL.admin.menu.MenuManagement.createMenu(menu);
                    Response.Write("<script language=javascript>");
                    Response.Write("window.parent.lframe.location='menu_left.aspx';<");
                    Response.Write("/script>");
                    BLL.pub.PubClass.showAlertMessage(Page, ClientScript, "添加成功!");
                    lbMode.Text = "修改模式";
                    ViewState["mode"] = "update";
                    tbMenuId.Enabled = false;
                }catch(Exception ex)
                {
                    lbMessage.Text = "添加错误:" + ex.Message;
                }

            }else
            if ((string)ViewState["mode"] == "update")
            {
                try
                {
                    t_Menu menu = new t_Menu();
                    menu.Id = Convert.ToInt32(tbMenuId.Text);
                    menu.name = tbName.Text;
                    menu.url = tbUrl.Text;
                    menu.status = CheckBoxStatus.Checked;
                    if (!String.IsNullOrEmpty(DropDownListParentNode.SelectedValue))
                        menu.parentId = Convert.ToInt32(DropDownListParentNode.SelectedValue);
                    else
                        menu.parentId = 0;
                    if (!String.IsNullOrEmpty(DropDownSys.SelectedValue))
                        menu.sysId = Convert.ToInt32(DropDownSys.SelectedValue);
                    else
                        menu.sysId = null;
                    BLL.admin.menu.MenuManagement.updateMenu(menu);

                    Response.Write("<script language=javascript>");
                    Response.Write("window.parent.lframe.location='menu_left.aspx';<");
                    Response.Write("/script>");
                    BLL.pub.PubClass.showAlertMessage(Page, ClientScript, "修改成功!");
                    lbMode.Text = "修改模式";
                    ViewState["mode"] = "update";
                    tbMenuId.Enabled = false;
                }
                catch (Exception ex)
                {
                    lbMessage.Text = "修改错误:" + ex.Message;
                }
            }
        }
Exemplo n.º 3
0
        public static bool updateMenu(t_Menu menu)
        {
            using (DataClassesEduDataContext dc = new DataClassesEduDataContext())
            {
                t_Menu m = dc.t_Menu.Where(me=>me.Id == menu.Id).Single();
                m.name = menu.name;
                m.parentId = menu.parentId;
                m.url = menu.url;
                m.status = menu.status;
                m.sysId = menu.sysId;
                dc.SubmitChanges();

                return true;
            }
        }