コード例 #1
0
        /// <summary>
        /// 设置状态选中
        /// </summary>
        /// <param name="key"></param>
        public void SetChecked(object key, bool isFocus = true)
        {
            setCheckeding = true;
            string keyStr = key as string;

            if (allowCheckBox)
            {
                isFocus = false;
            }

            {
                if (keyStr == null)
                {
                    DSCommon.SetTreeListNodeChecked <T>(treeList1, key, isFocus);
                }
                else
                {
                    string[] keys = keyStr.Split(',');
                    for (int i = 0; i < keys.Length; i++)
                    {
                        DSCommon.SetTreeListNodeChecked <T>(treeList1, keys[i], isFocus);
                    }
                }
            }
            //else
            {
            }
            popupcEdit_Closed(null, null);
            setCheckeding = false;
        }
コード例 #2
0
ファイル: UCModifyDataBase.cs プロジェクト: bininc/WinCommon
        /// <summary>
        /// 遍历检索控件中值
        /// </summary>
        /// <returns></returns>
        protected Dictionary <string, object> GetControlData()
        {
            if (string.IsNullOrWhiteSpace(tableName))
            {
                return(null);
            }

            DataTable dt = null;// Tmo_FakeEntityClient.Instance.GetTableStruct(tableName);

            if (dt == null)
            {
                return(null);
            }

            Dictionary <string, object> dic = new Dictionary <string, object>();
            List <Control> listControl      = DSCommon.FindControl(panelControlMain);

            foreach (Control ctrl in listControl)
            {
                string fieldName = ctrl.Name;
                if (!dt.Columns.Contains(fieldName))
                {
                    continue;                                   //跳过不在表中的控件
                }
                object fieldValue = null;
                if (ctrl is Label)
                {
                    fieldValue = ((Label)ctrl).Text;
                }
                else if (ctrl is TextBox)
                {
                    fieldValue = ((TextBox)ctrl).Text;
                }
                else if (ctrl is ComboBox)
                {
                    fieldValue = ((ComboBox)ctrl).SelectedItem;
                }
                else if (ctrl is DevExpress.XtraEditors.DateEdit)
                {
                    fieldValue = ((DevExpress.XtraEditors.DateEdit)ctrl).DateTime;
                }
                else if (ctrl is DevExpress.XtraEditors.LabelControl)
                {
                    fieldValue = ((DevExpress.XtraEditors.LabelControl)ctrl).Text;
                }
                else if (ctrl is DevExpress.XtraEditors.BaseEdit)
                {
                    fieldValue = ((DevExpress.XtraEditors.BaseEdit)ctrl).EditValue;
                }

                if (fieldName != null && fieldValue != null)
                {
                    if (!dic.ContainsKey(fieldName))
                    {
                        dic.Add(fieldName, fieldValue);
                    }
                }
            }
            return(dic);
        }
コード例 #3
0
        public void InitData(PopupContainerEdit popupcEdit, IEnumerable <T> dataSource, string keyFieldName, string parentFieldName, string previewFieldName, bool showCheckBox = false)
        {
            PopupcEdit    = popupcEdit;
            allowCheckBox = showCheckBox;
            DSCommon.SetTreeList(treeList1, showCheckBox);
            if (showCheckBox)
            {
                treeList1.AfterCheckNode += treeList1_AfterCheckNode;
            }
            else
            {
                treeList1.FocusedNodeChanged += treeList1_FocusedNodeChanged;
                //treeList1.AfterFocusNode += treeList1_AfterFocusNode;
            }

            treeList1.KeyFieldName     = keyFieldName;
            treeList1.ParentFieldName  = parentFieldName;
            treeList1.PreviewFieldName = previewFieldName;
            if (!string.IsNullOrWhiteSpace(previewFieldName))
            {
                TreeListColumn tc = new TreeListColumn {
                    Name = previewFieldName, FieldName = previewFieldName, VisibleIndex = 0
                };
                tc.OptionsColumn.AllowEdit = false;
                treeList1.Columns.Add(tc);
            }
            treeList1.DataSource = dataSource;
            treeList1.ExpandAll();
        }
コード例 #4
0
 void treeList1_AfterCheckNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
 {
     if (setCheckeding)
     {
         return;
     }
     DSCommon.SetTreeListCheckedChildNodes(e.Node, e.Node.CheckState);
     DSCommon.SetTreeListCheckedParentNodes(e.Node, e.Node.CheckState, _specialMode);
 }
コード例 #5
0
 public UCYearMonthRangeSelector()
 {
     InitializeComponent();
     if (!DesignMode)
     {
         List <Year> listYears = GetYearRange();
         DSCommon.BindImageComboBox(cmbBeginYear, listYears, x => true, "description", "year");
         DSCommon.BindImageComboBox(cmbEndYear, listYears, y => true, "description", "year");
         List <Month> listMonths = GetMonthRange();
         DSCommon.BindImageComboBox(cmbBeginMonth, listMonths, m => true, "description", "month");
         DSCommon.BindImageComboBox(cmbEndMonth, listMonths, m => true, "description", "month");
         BeginDate = DateTimeHelper.DefaultDateTime;
         EndDate   = DateTime.Now;
     }
 }
コード例 #6
0
ファイル: UCSelectDataBase.cs プロジェクト: bininc/WinCommon
        private void ConfigGridView()
        {
            if (!DesignMode)
            {
                if (_gridControl == null)
                {
                    return;
                }
                DSCommon.SetGridControl(_gridControl);
                DSCommon.SetGridControlColumnsBind(_gridControl, _columnBind);

                #region 添加编辑删除按钮
                GridView mainView = (GridView)_gridControl.MainView;
                if (!BrowseMode && !ChooseMode)
                {
                    if (HasEdit)
                    {
                        RepositoryItemHyperLinkEdit linkEdit = new RepositoryItemHyperLinkEdit();
                        GridColumn gc_edit = new GridColumn();
                        gc_edit.Caption    = "编辑";
                        gc_edit.Name       = "gc_edit";
                        gc_edit.FieldName  = "edit";
                        gc_edit.ColumnEdit = linkEdit;
                        gc_edit.Width      = 32;
                        gc_edit.OptionsColumn.FixedWidth = true;
                        gc_edit.Visible = true;
                        mainView.Columns.Add(gc_edit);
                    }
                    if (HasDel)
                    {
                        RepositoryItemHyperLinkEdit linkDel = new RepositoryItemHyperLinkEdit();
                        GridColumn gc_del = new GridColumn();
                        gc_del.Caption    = "删除";
                        gc_del.Name       = "gc_del";
                        gc_del.FieldName  = "del";
                        gc_del.ColumnEdit = linkDel;
                        gc_del.Width      = 32;
                        gc_del.OptionsColumn.FixedWidth = true;
                        gc_del.Visible = true;
                        mainView.Columns.Add(gc_del);
                    }
                }
                #endregion

                //单元格点击事件
                mainView.RowCellClick += (object sender, RowCellClickEventArgs e) => OnRowCellClick(e);
            }
        }
コード例 #7
0
        protected override void OnFirstLoad()
        {
            base.OnFirstLoad();
            if (!DesignMode)
            {
                List <Year> listYears = UCYearMonthRangeSelector.GetYearRange(ShowMoreDate ? DateTime.Now.Year + 50 : 0);
                DSCommon.BindImageComboBox(cmbBeginYear, listYears, x => true, "description", "year");

                List <Month> listMonths = UCYearMonthRangeSelector.GetMonthRange();
                DSCommon.BindImageComboBox(cmbBeginMonth, listMonths, m => true, "description", "month");

                if (DefaultTime != default(DateTime))
                {
                    DateTime = DefaultTime;
                }
                else
                {
                    DateTime = DateTime.Now;
                }
            }
        }
コード例 #8
0
        public string GetText()
        {
            if (allowCheckBox)
            {
                if (dicValues == null)
                {
                    dicValues = DSCommon.GetTreeListCheckedKeyValue <T>(treeList1);
                }
                StringBuilder sb = new StringBuilder();
                int           i  = 1;
                foreach (object item in dicValues.Values)
                {
                    if (item != null)
                    {
                        sb.AppendFormat("{0}", item);
                    }
                    if (i < dicValues.Count)
                    {
                        sb.Append(",");
                    }
                    i++;
                }
                return(sb.ToString());
            }
            else
            {
                T data = treeList1.GetDataRecordByNode(treeList1.FocusedNode) as T;
                if (data != null)
                {
                    PropertyInfo propertyInfo = data.GetType().GetProperty(treeList1.PreviewFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
                    object       name         = propertyInfo.GetValue(data, null);
                    return(name?.ToString());
                }
            }

            return(null);
        }
コード例 #9
0
ファイル: UCModifyDataBase.cs プロジェクト: bininc/WinCommon
        /// <summary>
        /// 为控件赋值
        /// </summary>
        /// <param name="dr"></param>
        /// <returns></returns>
        protected bool SetControlData(DataRow dr)
        {
            try
            {
                List <Control> listControl = DSCommon.FindControl(panelControlMain);
                foreach (Control ctrl in listControl)
                {
                    string fieldName = ctrl.Name;

                    if (!dr.Table.Columns.Contains(fieldName))
                    {
                        continue;                                         //跳过不在表中的控件
                    }
                    object fieldValue = dr[fieldName];
                    if (ctrl is Label)
                    {
                        ((Label)ctrl).Text = fieldValue == null ? null : fieldValue.ToString();
                    }
                    else if (ctrl is TextBox)
                    {
                        TextBox tb = (TextBox)ctrl;
                        tb.Text = fieldValue == null ? null : fieldValue.ToString();
                        if (dbOperaType == DbOperateType.View)
                        {
                            tb.ReadOnly = true;
                        }
                    }
                    else if (ctrl is ComboBox)
                    {
                        ComboBox cb = (ComboBox)ctrl;
                        cb.SelectedItem = fieldValue;
                    }
                    else if (ctrl is DevExpress.XtraEditors.DateEdit)
                    {
                        DevExpress.XtraEditors.DateEdit de = (DevExpress.XtraEditors.DateEdit)ctrl;
                        de.EditValue = fieldValue;
                        if (dbOperaType == DbOperateType.View)
                        {
                            de.ReadOnly = true;
                        }
                    }
                    else if (ctrl is DevExpress.XtraEditors.LabelControl)
                    {
                        ((DevExpress.XtraEditors.LabelControl)ctrl).Text = fieldValue.ToString();
                    }
                    else if (ctrl is DevExpress.XtraEditors.BaseEdit)
                    {
                        DevExpress.XtraEditors.BaseEdit be = (DevExpress.XtraEditors.BaseEdit)ctrl;
                        be.EditValue = fieldValue;
                        if (dbOperaType == DbOperateType.View)
                        {
                            be.ReadOnly = true;
                        }
                    }
                    else
                    {
                    }
                }
                string[] other = { "province_id", "city_id", "eare_id" };
                foreach (string item in other)
                {
                    Control ctrl = listControl.Find((Control x) => x.Name == item);
                    if (ctrl != null)
                    {
                        if (ctrl is DevExpress.XtraEditors.BaseEdit)
                        {
                            ((DevExpress.XtraEditors.BaseEdit)ctrl).EditValue = dr[item].ToString();
                        }
                    }
                }

                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
コード例 #10
0
        private void FillYear()
        {
            List <Year> listYears = UCYearMonthRangeSelector.GetYearRange(_maxYear, _minYear);

            DSCommon.BindImageComboBox(cmbYear, listYears, x => true, "description", "year");
        }