private void btnmenuadd_Click(object sender, EventArgs e)
        {
            if (txtmenuname.Text.Trim() == "")
            {
                MessageBoxEx.Show("不能为空!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }

            if (plugin.menu.FindIndex(x => x.menuname == txtmenuname.Text.Trim()) == -1)
            {
                menuClass menu = new menuClass();
                menu.menuname       = txtmenuname.Text;
                menu.pluginname     = txtmenupn.Text;
                menu.controllername = txtmenucn.Text;
                menu.viewname       = txtmenuvn.Text;
                menu.menupath       = txtmenump.Text;
                menu.memo           = txtmenumemo.Text;
                plugin.menu.Add(menu);
            }
            else
            {
                menuClass menu = plugin.menu.Find(x => x.menuname == txtmenuname.Text.Trim());
                menu.menuname       = txtmenuname.Text;
                menu.pluginname     = txtmenupn.Text;
                menu.controllername = txtmenucn.Text;
                menu.viewname       = txtmenuvn.Text;
                menu.menupath       = txtmenump.Text;
                menu.memo           = txtmenumemo.Text;
            }
            gridmenu.DataSource = null;
            gridmenu.DataSource = plugin.menu;
        }
Exemplo n.º 2
0
    //connected model
    // Retrieves values from database table and passes values into properties. Stores values in a list and returns
    public List <menuClass> getMenu()
    {
        List <menuClass> allMenu = new List <menuClass>();
        SqlConnection    conn    = new SqlConnection(_connString);
        SqlCommand       cmd     = new SqlCommand("SELECT * FROM menu", conn);

        try
        {
            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            // dr.read reads each row until there are none left
            while (dr.Read())
            {
                menuClass objMenu = new menuClass();
                objMenu.MenuID          = Convert.ToInt32(dr["id"].ToString());
                objMenu.MenuFood        = (string)dr["Food"];
                objMenu.MenuDescription = (string)dr["Description"];
                objMenu.MenuPrice       = Convert.ToDecimal(dr["Price"].ToString());
                allMenu.Add(objMenu);
            }
            return(allMenu);
        }
        catch (Exception err)
        {
            allMenu.Clear();
            menuClass objMenu = new menuClass();
            objMenu.MenuFood = "Server Error (DB): " + err.Message.ToString();
            allMenu.Add(objMenu);
            return(allMenu);
        }
        finally
        {
            conn.Close();
        }
    }
Exemplo n.º 3
0
    public List <menuClass> getMenuByID(int id)
    {
        List <menuClass> allProducts = new List <menuClass>();
        SqlConnection    conn        = new SqlConnection(_connString);
        SqlCommand       cmd         = new SqlCommand("SELECT * FROM menu WHERE id=" + id, conn);

        try
        {
            conn.Open();
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                menuClass objMenu = new menuClass();
                objMenu.MenuID          = Convert.ToInt32(dr["id"].ToString());
                objMenu.MenuFood        = (string)dr["Food"];
                objMenu.MenuDescription = (string)dr["Description"];
                objMenu.MenuPrice       = Convert.ToDecimal(dr["Price"].ToString());
                allProducts.Add(objMenu);
            }
            return(allProducts);
        }
        catch (Exception err)
        {
            allProducts.Clear();
            menuClass objMenu = new menuClass();
            objMenu.MenuFood = "Server Error (DB): " + err.Message.ToString();
            allProducts.Add(objMenu);
            return(allProducts);
        }
        finally
        {
            conn.Close();
        }
    }
    protected void subUpdate(object sender, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Update":
            TextBox     txtFood  = (TextBox)e.Item.FindControl("txt_foodU");
            TextBox     txtDesc  = (TextBox)e.Item.FindControl("txt_descU");
            TextBox     txtPrice = (TextBox)e.Item.FindControl("txt_priceU");
            HiddenField hdfID    = (HiddenField)e.Item.FindControl("hdf_id");

            menuClass objMenu = new menuClass();

            objMenu.MenuID          = Int32.Parse(hdfID.Value.ToString());
            objMenu.MenuFood        = txtFood.Text.ToString();
            objMenu.MenuDescription = txtDesc.Text.ToString();
            objMenu.MenuPrice       = Convert.ToDecimal(txtPrice.Text.ToString());

            lbl_msg.Text = objMenu.updateMenu();
            _subRebind();
            break;

        case "Cancel":
            _subRebind();
            break;
        }
    }
    protected void subAdmin(object sender, CommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Insert":
            menuClass objMenu = new menuClass();
            objMenu.MenuFood        = txt_foodI.Text.ToString();
            objMenu.MenuDescription = txt_descI.Text.ToString();
            objMenu.MenuPrice       = Convert.ToDecimal(txt_priceI.Text.ToString());
            lbl_msg.Text            = objMenu.insertMenu();
            _subRebind();
            break;

        case "Update":
            _showUpdate(e.CommandArgument.ToString());
            break;

        case "Delete":
            _showDelete(e.CommandArgument.ToString());
            break;

        case "Cancel":
            txt_foodI.Text  = string.Empty;
            txt_descI.Text  = string.Empty;
            txt_priceI.Text = string.Empty;
            break;
        }
    }
    private void _showDelete(string id)
    {
        _PanelControl(pnl_delete);
        menuClass objMenu = new menuClass();

        rpt_delete.DataSource = objMenu.getMenuByID(Int32.Parse(id));
        rpt_delete.DataBind();
    }
    private void _subRebind()
    {
        txt_foodI.Text  = string.Empty;
        txt_descI.Text  = string.Empty;
        txt_priceI.Text = string.Empty;
        menuClass objMenu = new menuClass();

        rpt_all.DataSource = objMenu.getMenu();
        rpt_all.DataBind();
        _PanelControl(pnl_all);
    }
Exemplo n.º 8
0
        //将菜单设置为启动项
        private void btnSetstartitem_Click(object sender, EventArgs e)
        {
            //FrmDevSetting setting = new FrmDevSetting();
            //setting.ShowDialog();

            if (gridpluginmenu.CurrentCell == null)
            {
                return;
            }
            if (treePlugin.SelectedNode == null || treePlugin.SelectedNode.Tag == null)
            {
                return;
            }
            PluginClass pc = (PluginClass)treePlugin.SelectedNode.Tag;

            List <menuClass> mlist = gridpluginmenu.DataSource as List <menuClass>;
            menuClass        menu  = mlist[gridpluginmenu.CurrentCell.RowIndex];

            if (pc.plugintype == "WebModulePlugin")
            {
                string      netwebserver     = CommonHelper.AppRootPath + "\\NetWebServer.exe.config";
                XmlDocument xmlDoc_webserver = new System.Xml.XmlDocument();
                xmlDoc_webserver.Load(netwebserver);
                XmlNode node = xmlDoc_webserver.DocumentElement.SelectSingleNode("appSettings/add[@key='defaultpage']");
                node.Attributes["value"].Value = menu.menupath;
                xmlDoc_webserver.Save(netwebserver);
            }
            else if (pc.plugintype == "WinformModulePlugin")
            {
                string      pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml";
                string      appconfig     = CommonHelper.WinformPlatformPath + "\\EFWWin.exe.config";
                XmlDocument xmlDoc_app    = new System.Xml.XmlDocument();
                xmlDoc_app.Load(appconfig);
                PluginSysManage.pluginsysFile = pluginsysFile;
                XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']");
                node.Attributes["value"].Value = "Winform";
                xmlDoc_app.Save(appconfig);
                PluginSysManage.SetWinformEntry(menu.pluginname, menu.viewname == "" ? menu.controllername : menu.controllername + "|" + menu.viewname);
            }
            else if (pc.plugintype == "WcfModulePlugin")
            {
                string      pluginsysFile = CommonHelper.WinformPlatformPath + "\\Config\\pluginsys.xml";
                string      appconfig     = CommonHelper.WinformPlatformPath + "\\EFWWin.exe.config";
                XmlDocument xmlDoc_app    = new System.Xml.XmlDocument();
                xmlDoc_app.Load(appconfig);
                PluginSysManage.pluginsysFile = pluginsysFile;
                XmlNode node = xmlDoc_app.DocumentElement.SelectSingleNode("appSettings/add[@key='ClientType']");
                node.Attributes["value"].Value = "WCFClient";
                xmlDoc_app.Save(appconfig);
                PluginSysManage.SetWcfClientEntry(menu.pluginname, menu.viewname == "" ? menu.controllername : menu.controllername + "|" + menu.viewname);
            }

            MessageBoxEx.Show("设置启动项成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        }
Exemplo n.º 9
0
        private void gridpluginmenu_Click(object sender, EventArgs e)
        {
            if (gridpluginmenu.CurrentCell != null)
            {
                List <menuClass> mlist = gridpluginmenu.DataSource as List <menuClass>;
                menuClass        menu  = mlist[gridpluginmenu.CurrentCell.RowIndex];

                txtMenuName.Text       = menu.menuname;
                txtMenuPath.Text       = menu.menupath;
                txtPluginName.Text     = menu.pluginname;
                txtControllerName.Text = menu.controllername;
                txtViewName.Text       = menu.viewname;
                txtMemo.Text           = menu.memo;
            }
        }
Exemplo n.º 10
0
    protected void subDelete(object sender, RepeaterCommandEventArgs e)
    {
        switch (e.CommandName)
        {
        case "Delete":
            HiddenField hdfID   = (HiddenField)e.Item.FindControl("hdf_id");
            menuClass   objMenu = new menuClass();
            objMenu.MenuID = Int32.Parse(hdfID.Value.ToString());
            lbl_msg.Text   = objMenu.deleteMenu();
            _subRebind();
            break;

        case "Cancel":
            _subRebind();
            break;
        }
    }