/// <summary>
 /// 执行触发事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void XinlongyuButton_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrEmpty(_clickEvent))
     {
         EventAssitant.CallEventDerectly(_clickEvent, this);
     }
 }
        /// <summary>
        /// 设置数据源
        /// </summary>
        private void SetDataSource(string sql)
        {
            //var sql = obj.d0;
            sql = EventAssitant.FormatSql(sql, _currentIControl);
            var dicarray = _sqlController.ExcuteSqlWithReturn(sql).data;

            if (object.Equals(dicarray, null))
            {
                return;
            }
            //每次都清空然后添加到数据源中
            _currentDataSource = new List <Dictionary <string, string> >();
            _currentDataSource.AddRange(dicarray);
            //var dicarray = dicresult.Result.data;
            var listsource = DicArrayToListObject(dicarray);

            Binding binding = new Binding()
            {
                Source = listsource, IsAsync = true
            };

            binding.UpdateSourceTrigger = UpdateSourceTrigger.Explicit;
            mydatagridview.SetBinding(DataGrid.ItemsSourceProperty, binding);
            //mydatagridview.ItemsSource = listsource;
        }
Beispiel #3
0
 /// <summary>
 /// 执行失败进行调用
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="inControl"></param>
 /// <param name="eventText"></param>
 public static void SetP12 <T>(this T inControl, string eventText) where T : IControl
 {
     if (ExcuteClassMethodByname(inControl, "SetP12", eventText) == ReturnConst.CancleReturn)
     {
         EventAssitant.CallEventDerectly(eventText, inControl);
     }
 }
        /// <summary>
        /// 图片的点击事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var    selectedItem = MyFlipView.SelectedItem as FlipViewItem;
            string eventText    = string.Format("[\"0.a5({0})\"]", selectedItem.pageId);

            EventAssitant.CallEventDerectly(eventText, this);
        }
 /// <summary>
 /// 页面初始化事件
 /// </summary>
 /// <param name="value"></param>
 public void SetP7(object value)
 {
     if (!object.Equals(value, null) && !string.IsNullOrEmpty(value.ToString()))
     {
         EventAssitant.CallEventDerectly(value.ToString(), this);
     }
 }
Beispiel #6
0
        /// <summary>
        /// 设置控件的值
        /// 这个是父类的方法,如果是图片控件什么的,需要自己重新重写一下这个方法
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="inControl"></param>
        /// <param name="text"></param>
        public static void SetD0 <T>(this T inControl, object value) where T : IControl
        {
            //更新一下d0的值
            if (value is string)
            {
                ControlDetailForPage obj = (inControl as FrameworkElement).Tag as ControlDetailForPage;
                obj.d0 = value.ToString();
                (inControl as FrameworkElement).Tag = obj;
            }

            if (ExcuteClassMethodByname(inControl, "SetD0", value) == ReturnConst.CancleReturn)
            {
                //if (!object.Equals(value, null))
                //{
                //    //(inControl as FrameworkElement) = value.ToString();
                //}
            }

            //数据获取后执行的事件
            if (!object.Equals(value, null) && !string.IsNullOrEmpty(value.ToString()))
            {
                if (!string.IsNullOrEmpty(((inControl as FrameworkElement).Tag as ControlDetailForPage).p4))
                {
                    EventAssitant.CallEventDerectly(((inControl as FrameworkElement).Tag as ControlDetailForPage).p4, inControl);
                }
            }
        }
 /// <summary>
 /// 标签的点击事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TxtContent_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     //throw new System.NotImplementedException();
     if (!string.IsNullOrEmpty(_clickEvent))
     {
         EventAssitant.CallEventDerectly(_clickEvent, this);
     }
 }
 /// <summary>
 /// 主值改变事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void XinlongyuCombobox_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (this.SelectedIndex != -1)
     {
         string p9 = (this.Tag as ControlDetailForPage).p9;
         if (!string.IsNullOrEmpty(p9))
         {
             EventAssitant.CallEventDerectly(p9, this);
         }
     }
 }
        /// <summary>
        /// 获取行数
        /// </summary>
        /// <returns></returns>
        private int GetTotalRowCount()
        {
            string _rowCountSql = _CurrentCtObj.d14;

            _rowCountSql = EventAssitant.FormatSql(_rowCountSql, _currentIControl);
            if (!string.IsNullOrEmpty(_rowCountSql))
            {
                var result = _sqlController.ExcuteSqlWithReturn(_rowCountSql);
                if (!object.Equals(result.data, null) && result.data.Length > 0)
                {
                    int totalCount = CommonConverter.StringToInt(result.data[0].First().Value);
                    return(totalCount);
                }
            }
            return(0);
        }
        /// <summary>
        /// 设置主值
        /// </summary>
        /// <param name="value"></param>
        public void SetD0(object value)
        {
            listItems.Clear();
            if (object.Equals(value, null) || string.IsNullOrEmpty(value.ToString()))
            {
                return;
            }
            ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
            //获取页面ID数组,默认全都要设置所以这里不进行判断
            List <int> listPageId = JsonController.DeSerializeToClass <List <int> >(currentObj.d11);

            //判断是数组还是sql
            if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
            {
                List <string> listImage = JsonController.DeSerializeToClass <List <string> >(value.ToString());
                for (int i = 0; i < listPageId.Count; i++)
                {
                    listItems.Add(new FlipViewItem()
                    {
                        ImageUrl = listImage[i], pageId = listPageId[i]
                    });
                }
            }
            else
            {
                //sql处理
                SqlController cn = new SqlController();
                value = EventAssitant.FormatSql(value.ToString(), this);
                var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                var result    = returnDic.data;
                if (!object.Equals(result, null) && result.Length > 0)
                {
                    int index = 0;
                    foreach (Dictionary <string, string> dic in result)
                    {
                        listItems.Add(new FlipViewItem()
                        {
                            ImageUrl = dic[currentObj.d19], pageId = listPageId[index]
                        });
                        index++;
                    }
                }
            }
            MyFlipView.ItemsSource = null;
            MyFlipView.ItemsSource = listItems;
        }
        /// <summary>
        /// 缓存到本地
        /// </summary>
        /// <param name="value"></param>
        public void SetA2(object value)
        {
            //缓存的本地里面
            string valueStr = value.ToString().Trim();

            string[] valueArray = valueStr.Split('&');
            Dictionary <string, string> dicTemp = new Dictionary <string, string>();

            foreach (string str in valueArray)
            {
                dicTemp.Add(str.Split('=')[0], str.Split('=')[1]);
            }
            foreach (string key in dicTemp.Keys)
            {
                LocalCacher.AddCache(key, EventAssitant.FormatSql(dicTemp[key], this));
            }
        }
        /// <summary>
        /// 打开新的窗体
        /// </summary>
        /// <param name="inText"></param>
        /// <param name="isDialog"></param>
        private async void OpenPage(string inText, bool isDialog = false)
        {
            int pageId = CommonConverter.StringToInt(inText);

            if (pageId != -1)
            {
                OpenPageById(pageId, isDialog);
            }
            //接下来是有传值的方法,格式应该是类似(1236, text={1.d0}&type=animal)
            else
            {
                if (Regex.IsMatch(inText, @"\d+, *\w+=.*"))
                {
                    pageId = CommonConverter.StringToInt(inText.Split(',')[0].Trim());
                    string   parameters     = inText.Split(',')[1].Trim();
                    string[] parameterArray = parameters.Split('&');
                    Dictionary <string, string> dicParameter       = new Dictionary <string, string>();
                    Dictionary <string, string> dicParameterResult = new Dictionary <string, string>();
                    foreach (string str in parameterArray)
                    {
                        dicParameter.Add(str.Split('=')[0], str.Split('=')[1]);
                    }
                    foreach (string key in dicParameter.Keys)
                    {
                        dicParameterResult.Add(key, EventAssitant.FormatSql(dicParameter[key], this));
                    }
                    OpenPageById(pageId, isDialog, dicParameterResult);
                }
                else
                {
                    string pageid = EventAssitant.FormatSql(inText, this);
                    pageId = CommonConverter.StringToInt(pageid);
                    if (pageId != -1)
                    {
                        OpenPageById(pageId, isDialog);
                    }
                }
            }
        }
 public void SetA1(string text)
 {
     try
     {
         DecoderOfControl dct = new DecoderOfControl();
         //dct.CtrlId = int.Parse(this.Name);
         dct.RightDirectValue = (this.Tag as ControlDetailForPage).d0;
         //执行d0sql的数据获取
         if (EventAssitant.dealWithSqlRequest(dct, this))
         {
             //触发后触发的事件
             EventAssitant.CallEventDerectly((this.Tag as ControlDetailForPage).p9, this);
         }
         else
         {
             //触发后触发的事件
             EventAssitant.CallEventDerectly((this.Tag as ControlDetailForPage).p12, this);
         }
     }
     catch (Exception ex)
     {
         Logging.Error("数据控件出错:" + ex.Message);
     }
 }
        /// <summary>
        /// 设置显示
        /// </summary>
        /// <param name="value"></param>
        public void SetD0(object value)
        {
            this.Items.Clear();
            _listValue.Clear();

            if (!object.Equals(value, null))
            {
                if (value is string)
                {
                    if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
                        //数组处理

                        if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                        {
                            string[] array = new string[1];
                            try
                            {
                                array = JsonController.DeSerializeToClass <string[]>(value.ToString().Replace("\r\n", string.Empty));
                            }
                            catch
                            {
                                array = JsonController.DeSerializeToClass <string[]>(value.ToString());
                            }
                            this.ItemsSource = array;
                            if (System.Text.RegularExpressions.Regex.IsMatch(currentObj.d5.Trim().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                            {
                                _listValue.AddRange(JsonController.DeSerializeToClass <string[]>(currentObj.d5.Trim()));
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(currentObj.d19) || string.IsNullOrEmpty(currentObj.d20))
                            {
                                return;
                            }
                            //sql处理
                            SqlController cn = new SqlController();
                            value = EventAssitant.FormatSql(value.ToString(), this);
                            var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                            var result    = returnDic.data;
                            if (!object.Equals(result, null) && result.Length > 0)
                            {
                                foreach (Dictionary <string, string> dic in result)
                                {
                                    this.Items.Add(dic[currentObj.d20]);
                                    _listValue.Add(dic[currentObj.d19]);
                                }
                            }
                        }
                        if (this.Items.Count > 0)
                        {
                            this.SelectedIndex = 0;
                        }
                    }
                }
                else
                {
                    //这里应该是用于.语法调用处理的时候进行处理,就是传进来的
                }
            }
        }
        /// <summary>
        /// 相等的逻辑判断
        /// </summary>
        /// <param name="text"></param>
        private void CustomEquals(string text, string specialChar)
        {
            text = text.Trim();
            string rightValue = text.Substring(text.IndexOf(specialChar) + specialChar.Length).Trim();
            string leftValue  = text.Substring(0, text.IndexOf(specialChar)).Trim();

            string leftPart  = leftValue;
            string rightPart = rightValue;

            if (Regex.IsMatch(leftValue, @"[{].*[}]"))
            {
                leftPart = EventAssitant.FormatSql(leftPart, this);
            }
            if (Regex.IsMatch(rightValue, @"[{].*[}]"))
            {
                rightPart = EventAssitant.FormatSql(rightPart, this);
            }

            bool isSuccess = false;

            if ("''".Equals(rightPart))
            {
                rightPart = string.Empty;
            }
            switch (specialChar)
            {
            case _equalStr:
                isSuccess = dealWithEqual(leftPart, rightPart);
                break;

            case _inequalStr:
                isSuccess = dealWithInEqual(leftPart, rightPart);
                break;

            case _upperOrEqual:
                isSuccess = dealWithUpperAndEqual(leftPart, rightPart);
                break;

            case _lowerOrEqual:
                isSuccess = dealWithLowerAndEqual(leftPart, rightPart);
                break;

            case _upper:
                isSuccess = dealWithUpper(leftPart, rightPart);
                break;

            case _lower:
                isSuccess = dealWithLower(leftPart, rightPart);
                break;

            default:
                break;
            }
            if (isSuccess)
            {
                this.SetP9((this.Tag as ControlDetailForPage).p9);
            }
            else
            {
                this.SetP12((this.Tag as ControlDetailForPage).p12);
            }
        }
Beispiel #16
0
        /// <summary>
        /// 主值
        /// </summary>
        /// <param name="text"></param>
        public void SetD0(object value)
        {
            checkListItems.Clear();
            MyListBox.ItemsSource = null;

            if (!object.Equals(value, null))
            {
                if (value is string)
                {
                    if (!string.IsNullOrEmpty(value.ToString()))
                    {
                        ControlDetailForPage currentObj = this.Tag as ControlDetailForPage;
                        //数组处理

                        if (System.Text.RegularExpressions.Regex.IsMatch(value.ToString().Replace("\r\n", string.Empty), @".*\[.*\].*"))
                        {
                            List <string> listArray = JsonController.DeSerializeToClass <List <string> >(value.ToString().Replace("\r\n", string.Empty));
                            //判断是否需要显示与值分开
                            if (!string.IsNullOrEmpty(currentObj.d11))
                            {
                                List <string> listValue = JsonController.DeSerializeToClass <List <string> >(currentObj.d11);
                                for (int i = 0; i < listArray.Count; i++)
                                {
                                    checkListItems.Add(new CheckBoxListItem()
                                    {
                                        DisPlayValue = listArray[i], ActualValue = listValue [i]
                                    });
                                }
                            }
                            else
                            {
                                listArray.AsParallel().ForAll(p => checkListItems.Add(new CheckBoxListItem()
                                {
                                    ActualValue = p, DisPlayValue = p
                                }));
                            }
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(currentObj.d19) || string.IsNullOrEmpty(currentObj.d20))
                            {
                                return;
                            }
                            //sql处理
                            SqlController cn = new SqlController();
                            value = EventAssitant.FormatSql(value.ToString(), this);
                            var returnDic = cn.ExcuteSqlWithReturn(value.ToString().Trim());
                            var result    = returnDic.data;
                            if (!object.Equals(result, null) && result.Length > 0)
                            {
                                foreach (Dictionary <string, string> dic in result)
                                {
                                    checkListItems.Add(new CheckBoxListItem()
                                    {
                                        ActualValue = dic[currentObj.d19], DisPlayValue = dic[currentObj.d20]
                                    });
                                }
                            }
                        }
                    }
                    if (!object.Equals(checkListItems, null))
                    {
                        MyListBox.ItemsSource = checkListItems;
                    }
                }
            }
        }