コード例 #1
0
        public static String GetLabelCaption(String strTableName, String strDataMember)
        {
            if (string.IsNullOrWhiteSpace(strDataMember) || String.IsNullOrWhiteSpace(strTableName))
            {
                return(String.Empty);
            }

            if (strDataMember.Contains(":") == false)
            {
                return(DataConfigProvider.GetFieldCaption(strTableName, strDataMember));
            }

            String strCurrentTableName = strTableName;

            String[] strArray = strDataMember.Split(':');
            foreach (String strCurrentField in strArray)
            {
                if (DataStructureProvider.IsForeignKey(strCurrentTableName, strCurrentField))
                {
                    strCurrentTableName = DataStructureProvider.GetTableNameOfForeignKey(strCurrentTableName, strCurrentField);
                }
                else
                {
                    return(DataConfigProvider.GetFieldCaption(strCurrentTableName, strCurrentField));
                }
            }

            return(String.Empty);
        }
コード例 #2
0
        public void ExpandForeignNode(ABCCommonTreeListNode node)
        {
            FieldNodeInfo fieldInfo = (FieldNodeInfo)node.InnerData;

            if (fieldInfo == null)
            {
                return;
            }
            String[] strArr = fieldInfo.FieldName.Split(':');
            if (strArr.Length <= 0)
            {
                return;
            }

            String strFK = strArr[strArr.Length - 1];

            String strTableName = DataStructureProvider.GetTableNameOfForeignKey(fieldInfo.TableName, strFK);

            if (DataStructureProvider.DataTablesList.ContainsKey(strTableName) == false)
            {
                return;
            }

            foreach (String strFieldName in DataStructureProvider.DataTablesList[strTableName].ColumnsList.Keys)
            {
                InitField(node, strTableName, strFieldName);
            }
        }
コード例 #3
0
        void repFilter_ButtonPressed(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            DataRow dr = ViewFieldConfig.GetDataRow(ViewFieldConfig.FocusedRowHandle);

            if (dr != null)
            {
                STFieldConfigsInfo configInfo = (STFieldConfigsInfo) new STFieldConfigsController().GetObjectFromDataRow(dr);
                if (configInfo != null)
                {
                    if (DataStructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                    {
                        String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(configInfo.TableName, configInfo.FieldName);

                        ABCCommonForms.FilterBuilderForm filterBuilder = new ABCCommonForms.FilterBuilderForm(strPKTableName);
                        String strOldValue = ViewFieldConfig.GetRowCellValue(ViewFieldConfig.FocusedRowHandle, "FilterString").ToString();
                        filterBuilder.SetFilterString(strOldValue);

                        if (filterBuilder.ShowDialog() == DialogResult.OK)
                        {
                            ViewFieldConfig.SetRowCellValue(ViewFieldConfig.FocusedRowHandle, "FilterString", filterBuilder.FilterString);
                        }
                    }
                }
            }
        }
コード例 #4
0
        public override object EditValue(ITypeDescriptorContext context, System.IServiceProvider provider, object value)
        {
            IWindowsFormsEditorService svc = null;

            if (provider != null)
            {
                svc = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            }

            if (svc != null)
            {
                String strTableName = String.Empty;

                if ((context as DevExpress.XtraVerticalGrid.Data.DescriptorContext).FieldName == "FilterCondition" && context.Instance.GetType().FullName == typeof(ABCScreen.ABCBindingConfig).FullName)
                {
                    //if ( Convert.ToBoolean( context.Instance.GetType().GetProperty( "IsList" ).GetValue( context.Instance , null ) )==false )
                    //{
                    //    ABCHelper.ABCMessageBox.Show( "Please set IsList = true before use this function." );
                    //    return value;
                    //}
                    strTableName = context.Instance.GetType().GetProperty("TableName").GetValue(context.Instance, null).ToString();
                }
                if ((context as DevExpress.XtraVerticalGrid.Data.DescriptorContext).FieldName.EndsWith("Editor.FilterStringEx") && context.Instance.GetType().FullName.EndsWith("LookUpEdit"))
                {
                    strTableName = context.Instance.GetType().GetProperty("TableName").GetValue(context.Instance, null).ToString();
                    String strFieldName = context.Instance.GetType().GetProperty("DataMember").GetValue(context.Instance, null).ToString();
                    if (DataStructureProvider.IsForeignKey(strTableName, strFieldName) == false)
                    {
                        return(value);
                    }

                    strTableName = DataStructureProvider.GetTableNameOfForeignKey(strTableName, strFieldName);
                }

                if (String.IsNullOrWhiteSpace(strTableName) == false)
                {
                    using (ABCCommonForms.FilterBuilderForm form = new ABCCommonForms.FilterBuilderForm(strTableName))
                    {
                        String strOld = String.Empty;
                        if (value != null)
                        {
                            strOld = value.ToString();
                        }

                        form.SetFilterString(strOld);
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            value = form.FilterString;
                        }
                    }
                }
            }


            return(value);
        }
コード例 #5
0
        public void RunFocusedLink( )
        {
            if (String.IsNullOrWhiteSpace(this.ABCGrid.TableName) == false)
            {
                if (this.ABCGrid == null || (this.ABCGrid.OwnerView != null && this.ABCGrid.OwnerView.Mode != ViewMode.Design))
                {
                    String strTableName = this.ABCGrid.TableName;
                    String strFieldName = VGrid.FocusedRow.Properties.FieldName;

                    String strLinkTableName = String.Empty;
                    Guid   iLinkID          = Guid.Empty;


                    EditorRow gridRow      = this.VGrid.FocusedRow as EditorRow;
                    object    objCellValue = this.VGrid.GetCellValue(gridRow, VGrid.FocusedRecord);
                    if (objCellValue == null || objCellValue.GetType() != typeof(Guid))
                    {
                        return;
                    }
                    if (gridRow.Properties.FieldName.Contains(":"))
                    {
                        DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(strTableName, ABCHelper.DataConverter.ConvertToGuid(objCellValue), gridRow.Properties.FieldName);
                        if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                                   acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                        {
                            strLinkTableName = acrrosInfo.TableName;
                            iLinkID          = acrrosInfo.TableID;
                        }
                    }
                    else if (DataStructureProvider.IsForeignKey(strTableName, strFieldName))
                    {
                        strLinkTableName = DataStructureProvider.GetTableNameOfForeignKey(strTableName, strFieldName);
                        iLinkID          = ABCHelper.DataConverter.ConvertToGuid(objCellValue);
                    }

                    if (iLinkID != Guid.Empty)
                    {
                        if (this.ABCGrid.OwnerView != null)
                        {
                            ABCScreen.ABCScreenHelper.Instance.RunLink(strLinkTableName, this.ABCGrid.OwnerView.Mode, false, iLinkID, ABCScreenAction.None);
                        }
                        else
                        {
                            ABCScreen.ABCScreenHelper.Instance.RunLink(strLinkTableName, ViewMode.Runtime, false, iLinkID, ABCScreenAction.None);
                        }
                    }
                }
            }
        }
コード例 #6
0
 void repoFilterStringEditor_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
 {
     ABCGridColumn.ColumnConfig config = this.ConfigGridView.GetRow(this.ConfigGridView.FocusedRowHandle) as ABCGridColumn.ColumnConfig;
     if (config != null && DataStructureProvider.IsForeignKey(config.TableName, config.FieldName))
     {
         String strTableName = DataStructureProvider.GetTableNameOfForeignKey(config.TableName, config.FieldName);
         using (ABCCommonForms.FilterBuilderForm form = new ABCCommonForms.FilterBuilderForm(strTableName))
         {
             form.SetFilterString(config.FilterString);
             if (form.ShowDialog() == DialogResult.OK)
             {
                 config.FilterString = form.FilterString;
             }
         }
     }
 }
コード例 #7
0
ファイル: UICaching.cs プロジェクト: thachgiasoft/abc-erp
        public static void InitDefaultRepository(ABCGridColumn gridCol)
        {
            try
            {
                #region RepositoryLookupEdit
                if (DataStructureProvider.IsForeignKey(gridCol.TableName, gridCol.FieldName))
                {
                    String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(gridCol.TableName, gridCol.FieldName);
                    gridCol.ColumnEdit = GetDefaultRepositoryLookUpEdit(strPKTableName, false);
                    (gridCol.ColumnEdit as ABCRepositoryLookUpEdit).DataSource = DataCachingProvider.TryToGetDataView(strPKTableName, false);
                }
                #endregion

                #region Enum
                else if (DataStructureProvider.IsTableColumn(gridCol.TableName, gridCol.FieldName) &&
                         String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[gridCol.TableName].FieldConfigList[gridCol.FieldName].AssignedEnum) == false)
                {
                    String strEnum = DataConfigProvider.TableConfigList[gridCol.TableName].FieldConfigList[gridCol.FieldName].AssignedEnum;
                    if (EnumProvider.EnumList.ContainsKey(strEnum))
                    {
                        ABCRepositoryLookUpEdit repo = new ABCRepositoryLookUpEdit();

                        repo.Properties.ValueMember = "ItemName";
                        if (ABCApp.ABCDataGlobal.Language == "VN")
                        {
                            repo.Properties.DisplayMember = "CaptionVN";
                        }
                        else
                        {
                            repo.Properties.DisplayMember = "CaptionEN";
                        }

                        DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                        col.FieldName = repo.Properties.DisplayMember;
                        col.Caption   = DataConfigProvider.GetFieldCaption(gridCol.TableName, gridCol.FieldName);
                        col.Visible   = true;
                        repo.Properties.Columns.Add(col);
                        repo.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                        gridCol.ColumnEdit         = repo;
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
            }
        }
コード例 #8
0
        public void InitGridView( )
        {
            String strFieldName = this.DataMember.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName) || DataStructureProvider.IsPrimaryKey(this.TableName, strFieldName))
            {
                if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName))
                {
                    this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName);
                }
                else
                {
                    this.LookupTableName = this.TableName;
                }
                ABCControls.UICaching.InitDefaultRepositoryGridLookUpEdit(this.LookupTableName, this.Properties, true);


                if (String.IsNullOrWhiteSpace(this.DisplayMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.DisplayMember))
                {
                    this.Properties.DisplayMember = this.DisplayMember;
                }

                if (String.IsNullOrWhiteSpace(this.ValueMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.ValueMember))
                {
                    this.Properties.ValueMember = this.ValueMember;
                }

                #region DataSource
                if (String.IsNullOrWhiteSpace(DefaultFilterString))
                {
                    this.Properties.DataSource = DataCachingProvider.TryToGetDataView(this.LookupTableName, false);
                }
                else
                {
                    DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                    newView.RowFilter          = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));
                    this.Properties.DataSource = newView;
                }

                #endregion

                if (this.Enabled)
                {
                    this.Enabled = ABCScreen.ABCScreenHelper.Instance.CheckTablePermission(this.LookupTableName, TablePermission.AllowView);
                }
            }
        }
コード例 #9
0
        public void InitColumnsFromTable( )
        {
            foreach (String strField in DataStructureProvider.DataTablesList[TableName].ColumnsList.Keys)
            {
                if (!DataConfigProvider.TableConfigList[TableName].FieldConfigList.ContainsKey(strField))
                {
                    continue;
                }

                DataConfigProvider.FieldConfig config = DataConfigProvider.TableConfigList[TableName].FieldConfigList[strField];
                String strCaption = DataConfigProvider.GetFieldCaption(TableName, strField);

                if (config.TypeName == "DateTime" || config.TypeName == "Nullable<DateTime>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(DateTime), new RepositoryItemDateEdit(), FilterColumnClauseClass.DateTime));
                }
                if (config.TypeName == "int" || config.TypeName == "Nullable<int>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(int), new RepositoryItemSpinEdit(), FilterColumnClauseClass.Generic));
                }
                if (config.TypeName == "Guid" || config.TypeName == "Nullable<Guid>")
                {
                    if (DataStructureProvider.IsForeignKey(TableName, strField))
                    {
                        String strPKTableName             = DataStructureProvider.GetTableNameOfForeignKey(TableName, strField);
                        RepositoryItemLookUpEditBase repo = ABCControls.UICaching.GetDefaultRepository(strPKTableName, false);
                        repo.DataSource = DataCachingProvider.TryToGetDataView(strPKTableName, false);

                        this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(Guid), repo, FilterColumnClauseClass.Lookup));
                    }
                }
                if (config.TypeName == "String")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(String), new RepositoryItemTextEdit(), FilterColumnClauseClass.String));
                }
                if (config.TypeName == "double")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(double), new RepositoryItemTextEdit(), FilterColumnClauseClass.Generic));
                }
                if (config.TypeName == "bool" || config.TypeName == "Nullable<bool>")
                {
                    this.filterEditorControl1.FilterColumns.Add(new UnboundFilterColumn(strCaption, strField, typeof(bool), new RepositoryItemCheckEdit(), FilterColumnClauseClass.Generic));
                }
            }
        }
コード例 #10
0
        public void Initialize(ABCView view)
        {
            OwnerView = view;

            InitControl();

            String strFieldName = this.DataMember.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName))
            {
                this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName);

                this.ValueMember = DataStructureProvider.GetPrimaryKeyColumn(this.LookupTableName);

                this.DisplayMember = DataStructureProvider.GetDisplayColumn(this.LookupTableName);
            }

            this.DummyText = "...";
        }
コード例 #11
0
        public void ExploreFKNode(ABCCommonTreeListNode obj)
        {
            DataStructInfo data = (DataStructInfo)obj.InnerData;

            if (DataStructureProvider.IsForeignKey(data.TableName, data.FieldName))
            {
                String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(data.TableName, data.FieldName);
                if (DataStructureProvider.DataTablesList.ContainsKey(strPKTableName) == false)
                {
                    return;
                }

                foreach (String strFieldName in DataStructureProvider.DataTablesList[strPKTableName].ColumnsList.Keys)
                {
                    DataStructInfo dataInfo = new DataStructInfo(strPKTableName, strFieldName);
                    dataInfo.TotalFieldName = data.TotalFieldName + ":" + strFieldName;
                    lstData.Add(dataInfo);
                    new ABCCommonTreeListNode(obj, dataInfo);
                }
            }
        }
コード例 #12
0
        public ABCBindingConfig(String strTableName)
        {
            IsList       = false;
            IsMainObject = false;
            DisplayOnly  = false;
            AutoSave     = false;
            DefaultField = String.Empty;
            DefaultValue = String.Empty;
            TopCount     = 0;
            TableName    = strTableName;
            Name         = "obj" + strTableName;

            if (DataStructureProvider.DataTablesList.ContainsKey(strTableName))
            {
                foreach (String strFKcol in DataStructureProvider.DataTablesList[strTableName].ForeignColumnsList.Keys)
                {
                    FieldFilterConfig config = new FieldFilterConfig();
                    config.TableName = DataStructureProvider.GetTableNameOfForeignKey(strTableName, strFKcol);
                    config.Field     = strFKcol;
                    FieldFilterConditions.Add(config);
                }
            }
        }
コード例 #13
0
        void LayoutItem_MouseUp(object sender, MouseEventArgs e)
        {
            //if ( OwnerView!=null&&OwnerView.Mode!=ViewMode.Design)
            //{
            if (e.Button == System.Windows.Forms.MouseButtons.Left && this.DisplayImage && EditControl != null &&
                this.LayoutItem.TextSize.Width - 18 < e.X && e.X < this.LayoutItem.TextSize.Width)
            {
                BindingSource  binding = (this.EditControl as Control).DataBindings[0].DataSource as BindingSource;
                BusinessObject busObj  = binding.DataSource as BusinessObject;

                #region Link by ID

                object obj = EditControl.GetType().GetProperty("EditValue").GetValue(EditControl, null);
                Guid   iID = ABCHelper.DataConverter.ConvertToGuid(obj);

                String strLinkTableName = String.Empty;
                Guid   iLinkID          = Guid.Empty;
                if (this.DataMember.Contains(":"))
                {
                    DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(busObj, iID, this.DataMember);
                    if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                               acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                    {
                        strLinkTableName = acrrosInfo.TableName;
                        iLinkID          = acrrosInfo.TableID;
                    }
                }
                else if (DataStructureProvider.IsForeignKey(TableName, this.DataMember))
                {
                    strLinkTableName = DataStructureProvider.GetTableNameOfForeignKey(TableName, this.DataMember);
                    iLinkID          = iID;
                }
                else
                {
                    strLinkTableName = TableName;
                    iLinkID          = BusinessObjectHelper.GetIDValue(busObj);
                }


                if (iLinkID != Guid.Empty && String.IsNullOrWhiteSpace(strLinkTableName) == false)
                {
                    ABCScreen.ABCScreenHelper.Instance.RunLink(strLinkTableName, this.OwnerView.Mode, false, iLinkID, ABCScreenAction.None);
                    return;
                }
                #endregion

                if (String.IsNullOrWhiteSpace(this.LinkScreen) == false)
                {
                    String[] strArrays = this.ParamFields.Split(';');
                    object[] lstParams = new object[strArrays.Length];
                    for (int i = 0; i < strArrays.Length; i++)
                    {
                        object objParam = strArrays[i];
                        if (DataStructureProvider.IsTableColumn(busObj.AATableName, strArrays[i]))
                        {
                            objParam = ABCBusinessEntities.ABCDynamicInvoker.GetValue(busObj, strArrays[i]);
                        }
                        lstParams[i] = objParam;
                    }

                    ABCScreen.ABCScreenHelper.Instance.RunLink(this.LinkScreen, this.OwnerView.Mode, false, ABCScreenAction.None, lstParams);
                }
            }
            //}
        }
コード例 #14
0
        public ABCBindingConfig DeSerialization(XmlNode currentNode)
        {
            ABCBindingConfig currentInfo = new ABCBindingConfig();

            try
            {
                #region Current Node
                if (currentInfo != null)
                {
                    currentInfo.Children.Clear();
                }

                currentInfo.Name        = currentNode.Attributes["name"].Value.ToString();
                currentInfo.TableName   = currentNode.Attributes["table"].Value.ToString();
                currentInfo.OwnerConfig = this;

                if (currentNode.Attributes["IsList"] != null)
                {
                    currentInfo.IsList = Convert.ToBoolean(currentNode.Attributes["IsList"].Value.ToString());
                }

                if (currentNode.Attributes["IsMainObject"] != null)
                {
                    currentInfo.IsMainObject = Convert.ToBoolean(currentNode.Attributes["IsMainObject"].Value.ToString());
                }

                if (currentNode.Attributes["DisplayOnly"] != null)
                {
                    currentInfo.DisplayOnly = Convert.ToBoolean(currentNode.Attributes["DisplayOnly"].Value.ToString());
                }

                if (currentNode.Attributes["AutoSave"] != null)
                {
                    currentInfo.AutoSave = Convert.ToBoolean(currentNode.Attributes["AutoSave"].Value.ToString());
                }

                if (currentNode.Attributes["ConfirmSaveChildren"] != null)
                {
                    currentInfo.ConfirmSaveChildren = Convert.ToBoolean(currentNode.Attributes["ConfirmSaveChildren"].Value.ToString());
                }

                if (currentNode.Attributes["DefaultField"] != null)
                {
                    currentInfo.DefaultField = currentNode.Attributes["DefaultField"].Value.ToString();
                }

                if (currentNode.Attributes["DefaultValue"] != null)
                {
                    currentInfo.DefaultValue = currentNode.Attributes["DefaultValue"].Value.ToString();
                }

                if (currentNode.Attributes["TopCount"] != null)
                {
                    currentInfo.TopCount = Convert.ToInt32(currentNode.Attributes["TopCount"].Value.ToString());
                }

                if (currentNode.Attributes["CurrentUserOnly"] != null)
                {
                    currentInfo.CurrentUserOnly = Convert.ToBoolean(currentNode.Attributes["CurrentUserOnly"].Value.ToString());
                }

                if (currentNode.Attributes["CurrentUserGroupOnly"] != null)
                {
                    currentInfo.CurrentUserGroupOnly = Convert.ToBoolean(currentNode.Attributes["CurrentUserGroupOnly"].Value.ToString());
                }

                if (currentNode.Attributes["CurrentEmployeeOnly"] != null)
                {
                    currentInfo.CurrentEmployeeOnly = Convert.ToBoolean(currentNode.Attributes["CurrentEmployeeOnly"].Value.ToString());
                }

                if (currentNode.Attributes["CurrentCompanyUnitOnly"] != null)
                {
                    currentInfo.CurrentCompanyUnitOnly = Convert.ToBoolean(currentNode.Attributes["CurrentCompanyUnitOnly"].Value.ToString());
                }

                if (currentNode.Attributes["parentField"] != null)
                {
                    currentInfo.ParentField = currentNode.Attributes["parentField"].Value.ToString();
                }

                if (currentNode.Attributes["childField"] != null)
                {
                    currentInfo.ChildField = currentNode.Attributes["childField"].Value.ToString();
                }

                if (currentNode.Attributes["parentField1"] != null)
                {
                    currentInfo.ParentField1 = currentNode.Attributes["parentField1"].Value.ToString();
                }

                if (currentNode.Attributes["childField1"] != null)
                {
                    currentInfo.ChildField1 = currentNode.Attributes["childField1"].Value.ToString();
                }

                if (currentNode.Attributes["parentField2"] != null)
                {
                    currentInfo.ParentField2 = currentNode.Attributes["parentField2"].Value.ToString();
                }

                if (currentNode.Attributes["childField2"] != null)
                {
                    currentInfo.ChildField2 = currentNode.Attributes["childField2"].Value.ToString();
                }

                if (currentNode.Attributes["parentField3"] != null)
                {
                    currentInfo.ParentField3 = currentNode.Attributes["parentField3"].Value.ToString();
                }

                if (currentNode.Attributes["childField3"] != null)
                {
                    currentInfo.ChildField3 = currentNode.Attributes["childField3"].Value.ToString();
                }

                if (currentNode.Attributes["SQLExtension"] != null)
                {
                    currentInfo.SQLExtension = currentNode.Attributes["SQLExtension"].Value.ToString();
                }

                if (currentNode.Attributes["SQLQuery"] != null)
                {
                    currentInfo.SQLQuery = currentNode.Attributes["SQLQuery"].Value.ToString();
                }

                if (currentNode.Attributes["filterString"] != null)
                {
                    currentInfo.FilterCondition = currentNode.Attributes["filterString"].Value.ToString();
                }

                if (currentNode.Attributes["SQLFilterString"] != null)
                {
                    currentInfo.SQLFilterCondition = currentNode.Attributes["SQLFilterString"].Value.ToString();
                }

                foreach (XmlNode nodeFilter in currentNode.SelectNodes("Filter"))
                {
                    String strField        = nodeFilter.Attributes["Field"].Value.ToString();
                    String strFilterString = nodeFilter.InnerText;

                    ABCBindingConfig.FieldFilterConfig config = new ABCBindingConfig.FieldFilterConfig();
                    config.Field        = strField;
                    config.FilterString = strFilterString;
                    config.TableName    = DataStructureProvider.GetTableNameOfForeignKey(currentInfo.TableName, strField);
                    currentInfo.FieldFilterConditions.Add(config);
                }
                #endregion

                foreach (XmlNode node in currentNode.SelectNodes("B"))
                {
                    ABCBindingConfig bindInfo = DeSerialization(node);
                    currentInfo.Children.Add(bindInfo.Name, bindInfo);
                    bindInfo.Parent     = currentInfo;
                    bindInfo.ParentName = currentInfo.Name;
                }

                DeSerialedList.Add(currentInfo.Name);
            }
            catch (Exception ex)
            {
                ABCHelper.ABCMessageBox.Show(String.Format("Can not Deserialize ABCBindingConfig : {0}", currentInfo.Name));
            }
            return(currentInfo);
        }
コード例 #15
0
        private void SetDefaultFieldCaptionFromDictionary(String strTableName)
        {
            STFieldConfigsController fieldConfigCtrl = new STFieldConfigsController();
            STTableConfigsController tableConfigCtrl = new STTableConfigsController();
            STDictionarysController  dictionaryCtrl  = new STDictionarysController();
            DataSet ds = DataQueryProvider.SystemDatabaseHelper.RunQuery(String.Format("SELECT * FROM  STFieldConfigs WHERE TableName='{0}'", strTableName));

            if (ds != null && ds.Tables.Count > 0)
            {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    STFieldConfigsInfo configInfo = (STFieldConfigsInfo)fieldConfigCtrl.GetObjectFromDataRow(dr);
                    if (configInfo != null)
                    {
                        String strCaptionVN = configInfo.FieldName;
                        String strCaptionEN = configInfo.FieldName;

                        #region Dictionarys
                        DataSet ds2 = DataQueryProvider.SystemDatabaseHelper.RunQuery(String.Format("SELECT * FROM  STDictionarys WHERE ('{0}' LIKE '%'+ KeyString+'%'  AND IsContain='TRUE') OR ('{0}' LIKE KeyString+'%' AND IsStartWith='TRUE') OR ('{0}' LIKE '%' +KeyString AND IsEndWith='TRUE') OR (KeyString='{0}' AND (IsContain='FALSE' OR IsContain IS NULL) AND (IsStartWith='FALSE' OR IsStartWith IS NULL) AND (IsEndWith='FALSE' OR IsEndWith IS NULL) )", configInfo.FieldName));
                        if (ds2 != null && ds2.Tables.Count > 0 && ds2.Tables[0].Rows.Count > 0)
                        {
                            STDictionarysInfo dictInfo = (STDictionarysInfo)dictionaryCtrl.GetObjectFromDataRow(ds2.Tables[0].Rows[0]);
                            if (dictInfo != null)
                            {
                                if (String.IsNullOrWhiteSpace(dictInfo.TranslateVN) == false)
                                {
                                    strCaptionVN = dictInfo.TranslateVN;
                                }
                                if (String.IsNullOrWhiteSpace(dictInfo.TranslateEN) == false)
                                {
                                    strCaptionEN = dictInfo.TranslateEN;
                                }
                            }
                        }
                        #endregion



                        if (DataStructureProvider.IsForeignKey(configInfo.TableName, configInfo.FieldName))
                        {
                            String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(configInfo.TableName, configInfo.FieldName);

                            STTableConfigsInfo tableConfigInfo = (STTableConfigsInfo)tableConfigCtrl.GetObject(String.Format("SELECT * FROM  STTableConfigs WHERE TableName='{0}' ", strPKTableName));
                            if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionVN) == false)
                            {
                                strCaptionVN = tableConfigInfo.CaptionVN;
                            }
                            if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionEN) == false)
                            {
                                strCaptionEN = tableConfigInfo.CaptionEN;
                            }
                            else
                            {
                                strCaptionEN = strPKTableName.Substring(2, strPKTableName.Length - 3);
                            }
                        }
                        else if (configInfo.FieldName.StartsWith("FK_"))
                        {
                            String strPKTableName = DataStructureProvider.GetTableNameOfPrimaryKey(configInfo.FieldName.Substring(3, configInfo.FieldName.Length - 3));
                            if (String.IsNullOrWhiteSpace(strPKTableName) == false)
                            {
                                STTableConfigsInfo tableConfigInfo = (STTableConfigsInfo)tableConfigCtrl.GetObject(String.Format("SELECT * FROM  STTableConfigs WHERE TableName='{0}' ", strPKTableName));
                                if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionVN) == false)
                                {
                                    strCaptionVN = tableConfigInfo.CaptionVN;
                                }
                                if (tableConfigInfo != null && String.IsNullOrWhiteSpace(tableConfigInfo.CaptionEN) == false)
                                {
                                    strCaptionEN = tableConfigInfo.CaptionEN;
                                }
                                else
                                {
                                    strCaptionEN = strPKTableName.Substring(2, strPKTableName.Length - 3);
                                }
                            }
                        }


                        //if ( String.IsNullOrWhiteSpace( strCaptionVN )==false||String.IsNullOrWhiteSpace( strCaptionEN )==false )
                        //{
                        if (strCaptionVN != configInfo.FieldName)
                        {
                            configInfo.CaptionVN = strCaptionVN;
                        }
                        else
                        {
                            configInfo.CaptionVN = String.Empty;
                        }
                        configInfo.CaptionEN = strCaptionEN;
                        fieldConfigCtrl.UpdateObject(configInfo);
                        //}
                    }
                }
            }
        }
コード例 #16
0
        public void InvalidateControl( )
        {
            if (EditControl == null && String.IsNullOrWhiteSpace(UIControlType) == false)
            {
                #region Design - FirstTIme
                EditControl            = (IABCBindableControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(Type.GetType(UIControlType));
                EditControl.DataSource = this.DataSource;
                EditControl.DataMember = this.DataMember;
                EditControl.TableName  = this.TableName;

                if (this.DataMember.Contains(":"))
                {
                    SetToReadOnly();
                }
                #endregion
            }

            if (EditControl != null)
            {
                EditControl.DataSource = this.DataSource;
                EditControl.DataMember = this.DataMember;
                EditControl.TableName  = this.TableName;

                this.layoutControl1.Controls.Add((this.EditControl as Control));
                this.LayoutItem.Control = (this.EditControl as Control);

                #region DisplayImage
                if (this.DataMember.Contains(":"))
                {
                    DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(TableName, this.DataMember);
                    if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                               acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                    {
                        STViewsInfo viewIfo = (STViewsInfo) new STViewsController().GetObject(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", acrrosInfo.TableName));
                        if (viewIfo != null)
                        {
                            this.DisplayImage = true;
                        }
                    }
                }
                else if (DataStructureProvider.IsForeignKey(TableName, this.DataMember))
                {
                    String      strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(TableName, this.DataMember);
                    STViewsInfo viewIfo        = (STViewsInfo) new STViewsController().GetObject(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", strPKTableName));
                    if (viewIfo != null)
                    {
                        this.DisplayImage = true;
                    }
                }
                #endregion

                if (DataStructureProvider.IsNOColumn(this.TableName, this.DataMember))
                {
                    ReadOnly = true;
                }

                #region Permission

                DataCachingProvider.AccrossStructInfo accross = DataCachingProvider.GetAccrossStructInfo(this.TableName, this.DataMember);
                if (ABCScreen.ABCScreenHelper.Instance.CheckFieldPermission(accross.TableName, accross.FieldName, FieldPermission.AllowView) == false)
                {
                    isAllowView = false;
                    ReadOnly    = true;
                }

                if (ReadOnly == false)
                {
                    ReadOnly = !ABCScreen.ABCScreenHelper.Instance.CheckFieldPermission(accross.TableName, accross.FieldName, FieldPermission.AllowEdit);
                }
                #endregion

                if (isAllowView)
                {
                    (this.EditControl as DevExpress.XtraEditors.BaseEdit).CustomDisplayText += new DevExpress.XtraEditors.Controls.CustomDisplayTextEventHandler(ABCBindingBaseEdit_CustomDisplayText);
                }

                if (ReadOnly)
                {
                    SetToReadOnly();
                }
                else
                {
                    if (this.EditControl is DevExpress.XtraEditors.BaseEdit && (this.EditControl as DevExpress.XtraEditors.BaseEdit).Properties != null)
                    {
                        (this.EditControl as DevExpress.XtraEditors.BaseEdit).Properties.AppearanceFocused.BackColor = Color.Bisque;
                    }
                }
            }

            UpdateLabelText();
        }
コード例 #17
0
ファイル: ABCLookupEdit.cs プロジェクト: thachgiasoft/abc-erp
        private void InitRepositoryLookupEdit( )
        {
            String strFieldName = this.DataMember.Split(':')[0];

            if (DataStructureProvider.IsForeignKey(this.TableName, strFieldName))
            {
                this.LookupTableName = DataStructureProvider.GetTableNameOfForeignKey(this.TableName, strFieldName);
                ABCControls.UICaching.InitDefaultRepositoryLookupEdit(this.LookupTableName, this.Properties);

                if (String.IsNullOrWhiteSpace(this.DisplayMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.DisplayMember))
                {
                    this.Properties.DisplayMember = this.DisplayMember;
                }

                if (String.IsNullOrWhiteSpace(this.ValueMember) == false && DataStructureProvider.IsTableColumn(this.LookupTableName, this.ValueMember))
                {
                    this.Properties.ValueMember = this.ValueMember;
                }


                #region DataSource
                if (String.IsNullOrWhiteSpace(DefaultFilterString))
                {
                    this.Properties.DataSource = DataCachingProvider.TryToGetDataView(this.LookupTableName, false);
                }
                else
                {
                    DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                    newView.RowFilter          = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));
                    this.Properties.DataSource = newView;
                }
                #endregion

                if (this.Enabled)
                {
                    this.Enabled = ABCScreen.ABCScreenHelper.Instance.CheckTablePermission(this.LookupTableName, TablePermission.AllowView);
                }
            }
            else if (DataStructureProvider.IsTableColumn(this.TableName, strFieldName) &&
                     String.IsNullOrWhiteSpace(DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strFieldName].AssignedEnum) == false)
            {
                String strEnum = DataConfigProvider.TableConfigList[this.TableName].FieldConfigList[strFieldName].AssignedEnum;
                if (EnumProvider.EnumList.ContainsKey(strEnum))
                {
                    this.Properties.ValueMember = "ItemName";
                    if (ABCApp.ABCDataGlobal.Language == "VN")
                    {
                        this.Properties.DisplayMember = "CaptionVN";
                    }
                    else
                    {
                        this.Properties.DisplayMember = "CaptionEN";
                    }

                    DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                    col.FieldName = this.Properties.DisplayMember;
                    col.Caption   = DataConfigProvider.GetFieldCaption(this.TableName, strFieldName);
                    col.Visible   = true;
                    this.Properties.Columns.Add(col);

                    this.Properties.DataSource = EnumProvider.EnumList[strEnum].Items.Values.ToArray();
                }
            }
            this.Properties.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFit;
            this.Properties.BestFit();
        }
コード例 #18
0
        public static List <Type> GetControlTypes(String strTableName, String strFieldName)
        {
            List <Type> lstTypes = new List <Type>();

            String[] strArr = strFieldName.Split(':');
            if (strArr.Length <= 0)
            {
                return(lstTypes);
            }


            if (strArr.Length == 1)
            {
                #region Level 1

                String strFieldNameTemp = strArr[0];
                String strTableNameTemp = strTableName;
                if (DataStructureProvider.IsForeignKey(strTableNameTemp, strFieldNameTemp))
                {
                    #region Foreign Key

                    lstTypes.Add(typeof(ABCLookUpEdit));
                    lstTypes.Add(typeof(ABCTextEdit));
                    lstTypes.Add(typeof(ABCGridLookUpEdit));
                    lstTypes.Add(typeof(ABCRadioGroup));
                    lstTypes.Add(typeof(ABCCheckedListBox));
                    if (DataStructureProvider.GetTableNameOfForeignKey(strTableNameTemp, strFieldNameTemp) == "GEPeriods")
                    {
                        lstTypes.Add(typeof(ABCPeriodEdit));
                    }
                    #endregion
                }
                else
                {
                    String strEnumName = DataConfigProvider.TableConfigList[strTableNameTemp].FieldConfigList[strFieldNameTemp].AssignedEnum;
                    if (String.IsNullOrWhiteSpace(strEnumName) == false && EnumProvider.EnumList.ContainsKey(strEnumName))
                    {
                        #region Enum

                        lstTypes.Add(typeof(ABCLookUpEdit));
                        lstTypes.Add(typeof(ABCRadioGroup));
                        lstTypes.Add(typeof(ABCCheckedListBox));
                        #endregion
                    }
                    else
                    {
                        #region Common
                        String strType = DataStructureProvider.GetCodingType(strTableNameTemp, strFieldNameTemp);
                        if (strType == "DateTime" || strType == "Nullable<DateTime>")
                        {
                            lstTypes.Add(typeof(ABCDateEdit));
                            lstTypes.Add(typeof(ABCTimeEdit));
                            lstTypes.Add(typeof(ABCMonthYearEdit));
                        }
                        if (strType == "int" || strType == "Nullable<int>")
                        {
                            lstTypes.Add(typeof(ABCTextEdit));
                            lstTypes.Add(typeof(ABCSpinEdit));
                            DataFormatProvider.ABCFormatInfo formatInfo = DataFormatProvider.GetFormatInfo(strTableNameTemp, strFieldNameTemp);
                            if (formatInfo != null)
                            {
                                if (formatInfo.ABCFormat == DataFormatProvider.FieldFormat.Year)
                                {
                                    lstTypes.Add(typeof(ABCYearEdit));
                                }
                                if (formatInfo.ABCFormat == DataFormatProvider.FieldFormat.Month ||
                                    formatInfo.ABCFormat == DataFormatProvider.FieldFormat.MonthAndYear)
                                {
                                    lstTypes.Add(typeof(ABCMonthEdit));
                                }
                            }
                        }
                        if (strType == "String" || strType == "Nullable<String>")
                        {
                            lstTypes.Add(typeof(ABCTextEdit));
                            lstTypes.Add(typeof(ABCLabel));
                            lstTypes.Add(typeof(ABCMemoEdit));
                            lstTypes.Add(typeof(ABCMemoExEdit));
                            lstTypes.Add(typeof(ABCRichEditControl));
                        }
                        if (strType == "double" || strType == "decimal" || strType == "Nullable<double>" || strType == "Nullable<decimal>")
                        {
                            lstTypes.Add(typeof(ABCTextEdit));
                            lstTypes.Add(typeof(ABCSpinEdit));
                            lstTypes.Add(typeof(ABCCalcEdit));
                        }
                        if (strType == "bool" || strType == "Nullable<bool>")
                        {
                            lstTypes.Add(typeof(ABCCheckEdit));
                            lstTypes.Add(typeof(ABCCheckPanel));
                            lstTypes.Add(typeof(ABCRadioGroup));
                            //     lstTypes.Add( typeof( ABCCheckedListBox ) );
                        }
                        #endregion
                    }
                }
                lstTypes.Add(typeof(ABCSearchControl));

                #endregion
            }
            else
            {
                #region Level n
                String strFieldNameTemp = String.Empty;
                String strTableNameTemp = strTableName;
                for (int i = 0; i < strArr.Length; i++)
                {
                    strFieldNameTemp = strArr[i];
                    if (DataStructureProvider.IsForeignKey(strTableNameTemp, strFieldNameTemp) == false)
                    {
                        break;
                    }

                    strTableNameTemp = DataStructureProvider.GetTableNameOfForeignKey(strTableNameTemp, strFieldNameTemp);
                }
                String strType = DataStructureProvider.GetCodingType(strTableNameTemp, strFieldNameTemp);
                if (strType == "DateTime" || strType == "Nullable<DateTime>")
                {
                    lstTypes.Add(typeof(ABCDateEdit));
                    lstTypes.Add(typeof(ABCTimeEdit));
                }
                if (strType == "int" || strType == "double" || strType == "decimal" || strType == "Nullable<int>" || strType == "Nullable<double>" || strType == "Nullable<decimal>")
                {
                    lstTypes.Add(typeof(ABCTextEdit));
                    lstTypes.Add(typeof(ABCLabel));
                }
                if (strType == "String" || strType == "Nullable<String>")
                {
                    lstTypes.Add(typeof(ABCTextEdit));
                    lstTypes.Add(typeof(ABCLabel));
                    lstTypes.Add(typeof(ABCMemoEdit));
                    lstTypes.Add(typeof(ABCRichEditControl));
                }
                if (strType == "bool" || strType == "Nullable<bool>")
                {
                    lstTypes.Add(typeof(ABCCheckEdit));
                    lstTypes.Add(typeof(ABCCheckPanel));
                }
                #endregion
            }

            return(lstTypes);
        }