private void CreateUC()
        {
            UC_ConditionTextbox uc1 = new UC_ConditionTextbox();

            uc1.mParent = this;
            uc1.Name    = "uc" + m_maxrow;
            uc1.cmblog.SelectionChanged += cmblog_SelectionChanged;
            m_maxrow++;
            SPAllParameters.Children.Add(uc1);
        }
 private void cmblog_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         UC_ConditionTextbox cmblog = ((sender as ComboBox).Parent as Grid).Parent as UC_ConditionTextbox;
         string str_id = cmblog.Name.Substring(2, cmblog.Name.Length - 2);
         if (str_id == (m_maxrow - 1).ToString())
         {
             CreateUC();
         }
     }
     catch (Exception ex)
     {
         App.ShowExceptionMessage(ex.Message);
     }
 }
        /// <summary>
        ///  修改筛选策略
        /// </summary>
        private void UpdateFilterStrategy()
        {
            AllFilterData item = LvStrategy.SelectedItem as AllFilterData;

            if (item != null)
            {
                string           messageBoxText = App.GetLanguageInfo("2101T00030", "Confirm Update?");
                MessageBoxButton button         = MessageBoxButton.OKCancel;
                MessageBoxImage  icon           = MessageBoxImage.Warning;
                MessageBoxResult result         = MessageBox.Show(messageBoxText, App.AppName, button, icon);
                switch (result)
                {
                case MessageBoxResult.Cancel:
                    return;
                }
                try
                {
                    mlstcfoperator.Clear();
                    #region 条件
                    if (cmbsttype.SelectedItem == null || string.IsNullOrWhiteSpace(txtstname.Text) || !IsValidDate(DateStart.Text) || !IsValidDate(DateEnd.Text))
                    {
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00024", "Illegal Parameter"));
                        return;
                    }
                    foreach (var c in SPAllParameters.Children)
                    {
                        if (c is UC_ConditionTextbox)
                        {
                            UC_ConditionTextbox tb = (UC_ConditionTextbox)c;
                            if (tb.Name.Contains("uc"))
                            {
                                try
                                {
                                    ComboBox cmbcondition = tb.cmbcondition as ComboBox;
                                    ComboBox cmbope       = tb.cmbope as ComboBox;
                                    TextBox  txtval       = tb.txtval as TextBox;
                                    ComboBox cmblog       = tb.cmblog as ComboBox;
                                    if (!string.IsNullOrWhiteSpace(cmbcondition.Text) &&
                                        !string.IsNullOrWhiteSpace(cmbope.Text) &&
                                        !string.IsNullOrWhiteSpace(txtval.Text))
                                    {
                                        StrategyInfo selStrategy = (cmbcondition.SelectionBoxItem as StrategyInfo);
                                        if (selStrategy.ConditionName.ToUpper() == "C004" || selStrategy.ConditionName.ToUpper() == "C005")
                                        {
                                            //时间格式判断
                                            if (!IsDateTimeValue(txtval.Text))
                                            {
                                                App.ShowInfoMessage(App.GetLanguageInfo("2101T00028", "Invalid Format."));//+ "\t" + "2015-01-01 01:01:01"
                                                return;
                                            }
                                        }
                                        int id = int.Parse(tb.Name.Substring(2, tb.Name.Length - 2));
                                        CFilterCondition tempfc = new CFilterCondition();
                                        tempfc.FilterTarget  = 1;
                                        tempfc.ID            = id;
                                        tempfc.ConditionName = (cmbcondition.SelectionBoxItem as StrategyInfo).ConditionName;
                                        tempfc.Operator      = cmbope.Text;
                                        tempfc.isEnum        = txtval.Text.Length > 1024 ? "1" : "0";
                                        tempfc.Value         = txtval.Text;
                                        tempfc.Logical       = cmblog.Text;
                                        mlstcfoperator.Add(tempfc);
                                    }
                                }
                                catch
                                { }
                            }
                        }
                    }
                    if (mlstcfoperator.Count < 1)
                    {
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00024", "Illegal Parameter"));
                        return;
                    }
                    #endregion
                    AllFilterData allfd = new AllFilterData();
                    allfd.FilterType   = 1;
                    allfd.StrategyCode = item.StrategyCode;
                    allfd.StrategyType = cmbsttype.SelectedValue.ToString();
                    allfd.StrategyName = txtstname.Text;
                    allfd.IsValid      = rdbValid.IsChecked == true ? "1" : "0";
                    allfd.IsDelete     = "0";
                    allfd.Creator      = App.Session.UserID;
                    allfd.CreateTime   = DateTime.Now.ToUniversalTime().ToString("yyyyMMddHHmmss");
                    //allfd.FilterNumber = 0;
                    allfd.DateStart           = Convert.ToDateTime(DateStart.Text).ToUniversalTime().ToString("yyyyMMddHHmmss");
                    allfd.DateEnd             = Convert.ToDateTime(DateEnd.Text).ToUniversalTime().ToString("yyyyMMddHHmmss");
                    allfd.Remarks             = txtdes.Text;
                    allfd.listFilterCondition = mlstcfoperator;

                    WebRequest webRequest = new WebRequest();
                    webRequest.Session = App.Session;
                    webRequest.Code    = (int)S2101Codes.SubmitStrategies;
                    OperationReturn optReturn = XMLHelper.SeriallizeObject(allfd);
                    if (!optReturn.Result)
                    {
                        App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), optReturn.Message));
                        return;
                    }
                    webRequest.Data = optReturn.Data.ToString();
                    webRequest.ListData.Add("1");//1 修改策略
                    //Service21011Client client = new Service21011Client();
                    Service21011Client client = new Service21011Client(WebHelper.CreateBasicHttpBinding(App.Session), WebHelper.CreateEndpointAddress(App.Session.AppServerInfo, "Service21011"));
                    //WebHelper.SetServiceClient(client);
                    WebReturn webReturn = client.DoOperation(webRequest);
                    client.Close();
                    if (!webReturn.Result)
                    {
                        if (webReturn.Code == Defines.RET_ALREADY_EXIST)
                        {
                            App.ShowExceptionMessage(App.GetLanguageInfo("2101T00025", "Filter Strategy exists."));
                        }
                        else
                        {
                            App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), webReturn.Message));
                        }
                        return;
                    }
                    else
                    {
                        string strLog = string.Format("{0}{1}{2}", App.Session.UserInfo.UserName, Utils.FormatOptLogString(string.Format("FO2101002")), item.StrategyName + "->" + allfd.StrategyName);
                        App.WriteOperationLog("2101", ConstValue.OPT_RESULT_SUCCESS, strLog);
                        //操作成功 刷新数据
                        InitFilters();
                        App.ShowInfoMessage(App.GetLanguageInfo("2101T00026", "Operation Succeed."));
                    }
                }
                catch (Exception ex)
                { App.ShowExceptionMessage(string.Format("{0}\t{1}", App.GetLanguageInfo("2101T00027", "Operation Field."), ex.Message)); }
            }
            else
            {
                App.ShowInfoMessage(App.GetLanguageInfo("2101T00029", "Please select at least one Strategy."));
            }
        }