protected void btnSave_Click(object sender, ImageClickEventArgs e)
    {
        if (this.ddlParents.SelectedIndex == 0)
        {
            MessageBox.Show(this, "请选择父节点!");
            return;
        }
        if (Request.QueryString["menuID"] != null)
        {
            if (this.chkIsLeaf.Checked)
            {
                if (DbHelperSQL.Exists("Select Count(0) from Sys_Menu where ParentsID='" + Request.QueryString["menuID"].ToString() + "'"))
                {
                    MessageBox.Show(this, "您修改的节点下面还有子节点,不能修改成叶子节点!");
                    return;
                }
            }
        }
        BuildModel();

        if (string.IsNullOrEmpty(Request.QueryString["menuID"]))
        {
            string strparentsID = "0";
            if (this.ddlParents.SelectedIndex != 0)
            {
                strparentsID = this.ddlParents.SelectedValue;
            }
            DataTable dtExist = menuBll.GetList(" menuName='" + this.txtMenuName.Text.Trim().Replace("'", "''") + "' and parentsID='" + strparentsID + "'").Tables[0];
            if (dtExist.Rows.Count > 0)
            {
                MessageBox.Show(this, "同父级别下的菜单名称不能重复,请重新输入!");
                return;
            }
            if (menuBll.Add(menuModel) == 1)
            {
                #region 数据同步
                if (ConfigurationManager.AppSettings["IsSync"] == "1")
                {
                    try
                    {
                        //添加成功,数据同步到各个磅房
                        IndustryPlatform.DBUtility.MsmqManage msm = MsmqManage.GetMsmq();
                        string strSQL = "INSERT INTO Sys_Menu ( " +
                                        "[MenuID] ," +
                                        "[MenuName] ," +
                                        "[MenuUrl] ," +
                                        "[FunctionID] ," +
                                        "[IsLeaf] ," +
                                        "[MenuLevel] ," +
                                        "[RootID] ," +
                                        "[ParentsID] ," +
                                        "[DisplayOrder] ," +
                                        "[IcValue] ," +
                                        "[IsPop] ," +
                                        "[MenuSeq] ) VALUES ('" + menuModel.MenuID + "','" + CommonMethod.RepChar(menuModel.MenuName) +
                                        "','" + CommonMethod.RepChar(menuModel.MenuUrl) + "','" + menuModel.FunctionID +
                                        "','" + menuModel.IsLeaf + "','" + menuModel.MenuLevel +
                                        "','" + menuModel.RootID + "','" + menuModel.ParentsID +
                                        "'," + menuModel.DisplayOrder + ",'" + menuModel.IcValue +
                                        "','" + menuModel.IsPop + "','" + menuModel.MenuSeq + "')";
                        strSQL = msm.AllStation + msm.Prefix + "Sys_Menu" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL;
                        msm.AddMsmq(strSQL);
                        //List<string> iplist = ControlBindHelper.GetAllRoomIP();
                        //for (int i = 0; i < iplist.Count; i++)
                        //{
                        //    if (iplist[i] != "")
                        //    {
                        //        EndpointAddress ep = new EndpointAddress("net.msmq://" + iplist[i] + "/private/STOCMessagingQueue");
                        //        NetMsmqBinding et = new NetMsmqBinding();
                        //        et.ExactlyOnce = false;
                        //        et.Security.Mode = System.ServiceModel.NetMsmqSecurityMode.None;
                        //        IDataPublish proxy = ChannelFactory<IDataPublish>.CreateChannel(et, ep);
                        //        proxy.IndustryPlatform_Menu_Add(menuModel);
                        //    }
                        //}
                    }
                    catch
                    { }
                }
                #endregion

                MessageBox.Show(this, "添加成功!");
                SetText();
                menuBll.BindDdl(ddlParents, PositionCodes);
            }
            else
            {
                MessageBox.Show(this, "添加失败!");
            }
        }
        else//更新操作
        {
            menuModel.MenuID = Request.QueryString["MenuID"];
            string strparentsID = "0";
            if (this.ddlParents.SelectedIndex != 0)
            {
                strparentsID = this.ddlParents.SelectedValue;
            }
            DataTable dtExist = menuBll.GetList(" menuName='" + this.txtMenuName.Text.Trim().Replace("'", "''") + "' and MenuID<>'" + menuModel.MenuID + "' and ParentsID='" + strparentsID + "'").Tables[0];
            if (dtExist.Rows.Count > 0)
            {
                MessageBox.Show(this, "同父级别下的菜单名称不能重复,请重新输入!");
                return;
            }

            if (menuBll.IsChildren(menuModel.MenuID, ddlParents.SelectedValue))
            {
                MessageBox.Show(this, "不要选择该菜单项下的子菜单项作为父菜单!");
                //菜单项实体
                IndustryPlatform.Model.SYS_MenuEntity menu = menuBll.GetModel(menuModel.MenuID);

                ddlParents.SelectedValue = menu.ParentsID;
            }
            else
            {
                if (menuBll.Update(menuModel) == 1)
                {
                    #region 数据同步
                    if (ConfigurationManager.AppSettings["IsSync"] == "1")
                    {
                        try
                        {
                            //添加成功,数据同步到各个磅房
                            if (menuModel.DisplayOrder == null)
                            {
                                menuModel.DisplayOrder = 0;
                            }
                            //添加成功,数据同步到各个磅房
                            IndustryPlatform.DBUtility.MsmqManage msm = MsmqManage.GetMsmq();
                            string strSQL = "Delete From Sys_Menu Where MenuID='" + menuModel.MenuID + "'; ";

                            strSQL += "INSERT INTO Sys_Menu ( " +
                                      "[MenuID] ," +
                                      "[MenuName] ," +
                                      "[MenuUrl] ," +
                                      "[FunctionID] ," +
                                      "[IsLeaf] ," +
                                      "[MenuLevel] ," +
                                      "[RootID] ," +
                                      "[ParentsID] ," +
                                      "[DisplayOrder] ," +
                                      "[IcValue] ," +
                                      "[IsPop] ," +
                                      "[MenuSeq] ) VALUES ('" + menuModel.MenuID + "','" + CommonMethod.RepChar(menuModel.MenuName) +
                                      "','" + CommonMethod.RepChar(menuModel.MenuUrl) + "','" + menuModel.FunctionID +
                                      "','" + menuModel.IsLeaf + "','" + menuModel.MenuLevel +
                                      "','" + menuModel.RootID + "','" + menuModel.ParentsID +
                                      "'," + menuModel.DisplayOrder + ",'" + menuModel.IcValue +
                                      "','" + menuModel.IsPop + "','" + menuModel.MenuSeq + "')";
                            strSQL = msm.AllStation + msm.Prefix + "Sys_Menu" + msm.Prefix + msm.AddFlg + msm.Prefix + DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + msm.Prefix + strSQL;
                            msm.AddMsmq(strSQL);
                        }
                        catch
                        { }
                    }
                    #endregion

                    ClientScript.RegisterStartupScript(Page.GetType(), "", "this.top.currForm.close();", true);
                }
                else
                {
                    MessageBox.Show(this, "修改失败!");
                }
            }
        }
    }