Exemple #1
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);
                        }
                    }
                }
            }
        }
Exemple #2
0
        protected override DevExpress.XtraEditors.Controls.ConvertEditValueEventArgs DoFormatEditValue(object val)
        {
            object objValue = val;

            if (objValue != null && objValue != DBNull.Value)
            {
                if (this.OwnerEdit != null)
                {
                    ABCTextEdit textEdit = (this.OwnerEdit as ABCTextEdit);

                    String strDataMember = textEdit.DataMember;
                    if (DataStructureProvider.IsForeignKey(textEdit.TableName, textEdit.DataMember))
                    {
                        strDataMember = textEdit.DataMember + ":" + DataStructureProvider.GetDisplayColumn(textEdit.TableName);
                    }

                    if (textEdit.BindingManager.Position >= 0 && textEdit.BindingManager.Current != null && textEdit.BindingManager.Current is ABCBusinessEntities.BusinessObject)
                    {
                        if (strDataMember.Contains(":") && objValue is Guid && ABCHelper.DataConverter.ConvertToGuid(objValue) != Guid.Empty)
                        {
                            ABCBusinessEntities.BusinessObject objBinds = textEdit.BindingManager.Current as ABCBusinessEntities.BusinessObject;
                            objValue = DataCachingProvider.GetCachingObjectAccrossTable(objBinds, ABCHelper.DataConverter.ConvertToGuid(objValue), strDataMember);
                        }
                    }
                }
            }
            return(base.DoFormatEditValue(objValue));
        }
        public static bool SetAutoValue(BusinessObject obj)
        {
            bool isModified = false;

            #region Edit Count
            if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colEditCount))
            {
                int    iCount   = -1;
                object objCount = ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colEditCount);
                if (objCount != null && objCount != DBNull.Value)
                {
                    iCount = Convert.ToInt32(objCount);
                }
                iCount++;

                object objOldValue = ABCDynamicInvoker.GetValue(obj, ABCCommon.ABCConstString.colEditCount);
                ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colEditCount, iCount);
                if (Convert.ToInt32(objOldValue) != iCount)
                {
                    isModified = true;
                }
            }
            #endregion

            isModified = isModified || CurrencyProvider.GenerateCurrencyValue(obj);
            return(isModified);
        }
        public static Type GetBusinessObjectType(String strTableName)
        {
            String strBusName = strTableName + "Info";

            Type type = null;

            if (CachingBusinessObjectType.TryGetValue(strBusName, out type) == false)
            {
                try
                {
                    if (DataStructureProvider.IsSystemTable(strTableName))
                    {
                        Assembly assEntities = Assembly.LoadFrom(Application.StartupPath + "\\BaseObjects.dll");
                        type = assEntities.GetType("ABCBusinessEntities." + strBusName);
                    }
                    else
                    {
                        Assembly assEntities = Assembly.LoadFrom(Application.StartupPath + "\\BusinessObjects.dll");
                        type = assEntities.GetType("ABCBusinessEntities." + strBusName);
                    }
                    if (type != null)
                    {
                        CachingBusinessObjectType.Add(strBusName, type);
                    }
                }
                catch (Exception)
                {
                }
            }
            return(type);
        }
Exemple #5
0
        public static void InitDefaultRepositoryLookupEdit(String strTableName, ABCRepositoryLookUpEdit repo)
        {
            DataConfigProvider.TableConfig config = DataConfigProvider.TableConfigList[strTableName];

            #region Columns
            foreach (String strField in config.FieldConfigList.Keys)
            {
                if (config.FieldConfigList[strField].InUse && config.FieldConfigList[strField].IsDefault)
                {
                    DevExpress.XtraEditors.Controls.LookUpColumnInfo col = new DevExpress.XtraEditors.Controls.LookUpColumnInfo();
                    col.FieldName = strField;
                    col.Caption   = DataConfigProvider.GetFieldCaption(strTableName, strField);
                    col.Visible   = true;
                    repo.Columns.Add(col);
                }
            }
            #endregion

            repo.ValueMember = DataStructureProvider.DataTablesList[strTableName].PrimaryColumn;

            repo.DisplayMember = DataStructureProvider.GetDisplayColumn(strTableName);
            if (String.IsNullOrWhiteSpace(repo.DisplayMember) && repo.Columns.Count > 0)
            {
                repo.DisplayMember = repo.Columns[0].FieldName;
            }

            repo.BestFit();
        }
Exemple #6
0
        public void UpdateObject(BusinessObject obj)
        {
            if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colSelected))
            {
                ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colSelected, false);
            }

            if (String.IsNullOrWhiteSpace(ABCBaseUserProvider.CurrentUserName) == false &&
                DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colUpdateUser))
            {
                ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colUpdateUser, ABCBaseUserProvider.CurrentUserName);
            }

            if (DataStructureProvider.IsTableColumn(obj.AATableName, ABCCommon.ABCConstString.colUpdateTime))
            {
                ABCDynamicInvoker.SetValue(obj, ABCCommon.ABCConstString.colUpdateTime, ABCApp.ABCDataGlobal.WorkingDate);
            }

            BusinessObjectHelper.GenerateNoColumn(obj, false);

            if (DatabaseHelper.IsSQLConnection())
            {
                (DatabaseHelper as SqlDatabaseHelper).RunStoredProcedure(StoredProcedureGenerator.GetSPName(StoredProcedureGenerator.SPType.Update, TableName), obj);
            }
            else
            {
                DatabaseHelper.RunScript(QueryTemplateGenerator.GenUpdate(TableName), obj);
            }
        }
Exemple #7
0
        public static void InitDefaultRepositoryGridLookUpEdit(String strTableName, ABCRepositoryGridLookupEdit repo, Boolean isCreateNewView)
        {
            ABCGridView view;

            if (isCreateNewView)
            {
                view = new ABCGridView(strTableName);
                InitDefaultColumns(strTableName, view);
            }
            else
            {
                view = GetDefaultGridView(strTableName);
            }

            repo.View        = view;
            repo.ValueMember = DataStructureProvider.GetPrimaryKeyColumn(strTableName);

            String strDisplayCol = DataStructureProvider.GetDisplayColumn(strTableName);

            if (String.IsNullOrWhiteSpace(strDisplayCol))
            {
                strDisplayCol = repo.ValueMember;
            }
            repo.DisplayMember = strDisplayCol;

            if (view.Columns.Count <= 7)
            {
                repo.BestFitMode = DevExpress.XtraEditors.Controls.BestFitMode.BestFitResizePopup;
            }
            else
            {
                repo.BestFitMode   = DevExpress.XtraEditors.Controls.BestFitMode.BestFit;
                repo.PopupFormSize = new System.Drawing.Size(700, 400);
            }
        }
Exemple #8
0
        public static void InitCachingPresentControls( )
        {
            CachingGridViews.Clear();
            ReposityGridLookupEdits.Clear();
            ReposityLookupEdits.Clear();

            foreach (String strTableName in DataConfigProvider.TableConfigList.Keys)
            {
                DataConfigProvider.TableConfig config = DataConfigProvider.TableConfigList[strTableName];
                if (config.IsCaching && DataStructureProvider.IsSystemTable(strTableName) == false)
                {
                    //RepositoryLookUpEdit
                    GetDefaultRepositoryLookUpEdit(strTableName, false);
                }
            }

            foreach (String strTableName in DataConfigProvider.TableConfigList.Keys)
            {
                DataConfigProvider.TableConfig config = DataConfigProvider.TableConfigList[strTableName];
                if (config.IsCaching)
                {
                    //GridView
                    GridView view = GetDefaultGridView(strTableName);

                    //RepositoryGridLookupEdit
                    RepositoryItemGridLookUpEdit repoLookupEdit = GetDefaultRepositoryGridLookupEdit(strTableName, false);
                    repoLookupEdit.View = view;
                }
            }
        }
Exemple #9
0
        public void UpdateFieldName(ABCCommonTreeListNode obj)
        {
            if (obj == null || obj.InnerData == null)
            {
                return;
            }

            if (obj.ParentNode != null)
            {
                ABCCommonTreeListNode objparent = obj.ParentNode;

                ABCBindingConfig currentBind = (ABCBindingConfig)obj.InnerData;
                ABCBindingConfig parentBind  = (ABCBindingConfig)objparent.InnerData;

                if (currentBind != null && parentBind != null)
                {
                    if (currentBind.ParentName != parentBind.TableName || (currentBind.ParentName == parentBind.TableName && (String.IsNullOrWhiteSpace(currentBind.ParentField) || String.IsNullOrWhiteSpace(currentBind.ChildField))))
                    {
                        if (DataStructureProvider.IsExistedTable(parentBind.TableName))
                        {
                            currentBind.ParentField = DataStructureProvider.GetPrimaryKeyColumn(parentBind.TableName);
                        }
                        if (DataStructureProvider.IsExistedTable(currentBind.TableName))
                        {
                            currentBind.ChildField = DataStructureProvider.GetTable(currentBind.TableName).GetForeignKeyOfTableName(parentBind.TableName);
                        }
                    }
                    currentBind.ParentName = parentBind.Name;
                }
            }
            //foreach ( TreeListNode nodeChild in node.Nodes )
            //    UpdateFieldName( nodeChild );
        }
        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);
            }
        }
        private void InitField(ABCCommonTreeListNode parentNode, String strTableName, String strFieldName)
        {
            ABCScreen.ABCBindingConfig bindInfo = ((FieldNodeInfo)parentNode.InnerData).Config;
            String strDiplay = DataConfigProvider.GetFieldCaption(strTableName, strFieldName);

            if (strDiplay == strFieldName)
            {
                return;
            }

            FieldNodeInfo fieldInfo = new FieldNodeInfo();

            fieldInfo.Display = strDiplay;
            fieldInfo.Type    = FiledNodeType.Field;
            fieldInfo.Config  = bindInfo;
            if (String.IsNullOrWhiteSpace(((FieldNodeInfo)parentNode.InnerData).FieldName) == false)
            {
                fieldInfo.FieldName = ((FieldNodeInfo)parentNode.InnerData).FieldName + ":";
            }

            fieldInfo.FieldName += strFieldName;
            fieldInfo.TableName  = strTableName;

            ABCCommonTreeListNode node = new ABCCommonTreeListNode(parentNode, fieldInfo);

            InitControls(node);

            if (DataStructureProvider.IsForeignKey(strTableName, strFieldName))
            {
                fieldInfo.Type = FiledNodeType.Foreign;
            }
        }
        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);
        }
Exemple #13
0
        public void AddComment(String strTableName, Guid iID, String strComment)
        {
            if (String.IsNullOrWhiteSpace(strComment))
            {
                return;
            }
            if (DataStructureProvider.IsExistedTable(strTableName) == false)
            {
                return;
            }
            if (BusinessControllerFactory.GetBusinessController(strTableName).GetObjectByID(iID) == null)
            {
                return;
            }

            RefreshTagsString();

            String strCreateUser     = ABCUserProvider.CurrentUserName.Replace("'", "''");
            String strCreateEmployee = ABCUserProvider.CurrentEmployeeName.Replace("'", "''");

            String strQuery = String.Format(@"INSERT INTO GEComments ( GECommentID,CreateTime , CreateUser , Employee , TableName , ID ,Comment,TagString,TagStringDisplay ) 
                                                              VALUES ('{0}',GetDate() ,N'{1}' ,N'{2}' ,'{3}','{4}',N'{5}',N'{6}',N'{7}')", Guid.NewGuid(), strCreateUser.Replace("'", "''"), strCreateEmployee.Replace("'", "''"), strTableName, iID, strComment.Replace("'", "''"), Tags.Replace("'", "''"), TagsDisplay.Replace("'", "''"));

            BusinessObjectController.RunQuery(strQuery);
            NotifyProvider.CreateNewNotifyFromComment(strTableName, iID);
            LoadComments();
            this.gridView.MoveLast();

            this.richEditControl1.Text = "";

            this.tabPanel.ClearTags();
        }
        void Menu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if (e.Item.Tag != null && e.Item.Tag.ToString() == "New")
            {
                TableChooserForm form         = new TableChooserForm();
                String           strTableName = form.ShowChooseOne();
                if (form.DialogResult == DialogResult.Cancel)
                {
                    return;
                }
                if (DataStructureProvider.IsExistedTable(strTableName) == false)
                {
                    return;
                }

                TreeConfigData configData = new TreeConfigData();
                configData.Name             = "objNew" + this.Manager.ConfigList.Count;
                configData.DefaultLoad      = true;
                configData.TableName        = strTableName;
                configData.ColumnFieldNames = new Dictionary <string, string>();

                TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode);
                if (obj == null)
                {
                    new TreeConfigNode(Manager.RootConfig, configData);
                }
                else
                {
                    configData.ParentTableName = obj.InnerData.TableName;
                    configData.ParentField     = DataStructureProvider.GetPrimaryKeyColumn(obj.InnerData.TableName);
                    configData.ChildField      = DataStructureProvider.GetForeignKeyOfTableName(configData.TableName, obj.InnerData.TableName);
                    new TreeConfigNode(obj, configData);
                }

                UpdateDataConfigs();
                RefreshDataConfigTree();
            }

            if (e.Item.Tag != null && e.Item.Tag.ToString() == "Delete")
            {
                TreeConfigNode obj = (TreeConfigNode)DataConfigTreeCtrl.GetDataRecordByNode(DataConfigTreeCtrl.FocusedNode);
                if (obj == null || (TreeConfigData)obj.InnerData == null)
                {
                    return;
                }

                DialogResult result = ABCHelper.ABCMessageBox.Show("Do you want to delete selected Object ? ", "Delete Object", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    obj.ParentNode.ChildrenNodes.Remove(obj.InnerData.Name);
                    obj.ParentNode = null;

                    UpdateDataConfigs();
                    RefreshDataConfigTree();
                }
            }
        }
Exemple #15
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);
        }
        public void InvalidateControl( )
        {
            if (EditControl == null)
            {
                #region init
                String strType = DataStructureProvider.GetCodingType(this.TableName, this.DataMember.Split(':')[0]);
                if (strType == "String" || strType == "Nullable<String>")
                {
                    EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCTextSearch));
                }
                else if (strType == "bool" || strType == "Nullable<bool>")
                {
                    EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCBoolSearch));
                }
                else if (strType == "DateTime" || strType == "Nullable<DateTime>")
                {
                    EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCDateTimeSearch));
                }
                else if (strType == "int" || strType == "Nullable<int>" || strType == "Guid" || strType == "Nullable<Guid>" || strType == "double" || strType == "Nullable<double>" || strType == "decimal" || strType == "Nullable<decimal>")
                {
                    if (DataStructureProvider.IsForeignKey(this.TableName, this.DataMember.Split(':')[0]) ||
                        DataStructureProvider.IsPrimaryKey(this.TableName, this.DataMember.Split(':')[0]))
                    {
                        EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCGridLookUpEditSearch));
                    }
                    else
                    {
                        EditControl = (ISearchControl)ABCBusinessEntities.ABCDynamicInvoker.CreateInstanceObject(typeof(ABCNumbSearch));
                    }
                }

                if (EditControl != null)
                {
                    EditControl.GetType().GetProperty("DataMember").SetValue(EditControl, this.DataMember, null);
                    EditControl.GetType().GetProperty("TableName").SetValue(EditControl, this.TableName, null);
                    if (EditControl is ABCGridLookUpEdit)
                    {
                        ((ABCGridLookUpEdit)EditControl).Initialize(OwnerView);
                    }
                }

                #endregion
            }

            if (EditControl != null)
            {
                EditControl.GetType().GetProperty("DataMember").SetValue(EditControl, this.DataMember, null);
                EditControl.GetType().GetProperty("TableName").SetValue(EditControl, this.TableName, null);
                EditControl.SetFormatInfo();
                this.layoutControl1.Controls.Add((this.EditControl as Control));
                this.LayoutItem.Control = (this.EditControl as Control);
            }

            UpdateLabelText();
        }
        public void RefreshDisplayTree( )
        {
            DisplayTreeListCtrl.TableName = this.TableName;
            DisplayTreeListCtrl.InnerTreeList.Columns.Clear();
            DisplayTreeListCtrl.ColumnConfigs      = this.ColumnList;
            DisplayTreeListCtrl.Manager.ConfigList = this.Manager.ConfigList;//new
            DisplayTreeListCtrl.InitColumns();

            #region Script
            if (String.IsNullOrWhiteSpace(this.TableName))
            {
                if (String.IsNullOrWhiteSpace(Script) == false)
                {
                    DataSet ds = DataQueryProvider.RunQuery(Script);
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        Manager.Invalidate(ds);
                        DisplayTreeListCtrl.InnerTreeList.ColumnsCustomization();
                    }
                }
                return;
            }
            #endregion

            if (DataCachingProvider.LookupTables.ContainsKey(this.TableName))
            {
                Manager.Invalidate(DataCachingProvider.LookupTables[this.TableName]);
            }
            else
            {
                ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder();
                strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0} ", this.TableName));
                if (DataStructureProvider.IsExistABCStatus(this.TableName))
                {
                    strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus));
                }

                strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName)));

                try
                {
                    DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString());
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        this.DisplayTreeListCtrl.InnerTreeList.DataSource = ds.Tables[0];
                    }
                }
                catch (Exception ex)
                {
                }
            }

            this.DisplayTreeListCtrl.InnerTreeList.RefreshDataSource();
            DisplayTreeListCtrl.InnerTreeList.ColumnsCustomization();
        }
        public static Guid GetIDValue(BusinessObject obj)
        {
            if (obj == null)
            {
                return(Guid.Empty);
            }

            string strPrimaryKeyColumn = DataStructureProvider.GetPrimaryKeyColumn(obj.AATableName);

            return(ABCHelper.DataConverter.ConvertToGuid(ABCDynamicInvoker.GetValue(obj, strPrimaryKeyColumn)));
        }
Exemple #19
0
        public List <BusinessObject> GetListByColumn(String strFieldName, object objValue)
        {
            if (DataStructureProvider.IsTableColumn(TableName, strFieldName) == false)
            {
                return(new List <BusinessObject>());
            }

            String strQuery = QueryGenerator.GenSelectByColumn(TableName, strFieldName, objValue, false);

            return(GetList(strQuery));
        }
Exemple #20
0
 public static DataSet RunQuery(String strQuery, String strTableName)
 {
     if (DataStructureProvider.IsSystemTable(strTableName))
     {
         return(DataQueryProvider.SystemDatabaseHelper.RunQuery(strQuery));
     }
     else
     {
         return(DataQueryProvider.CompanyDatabaseHelper.RunQuery(strQuery));
     }
 }
        public void RunLink(String strTableName, ViewMode mode, bool isShowDialog, Guid iMainID, ABCScreenAction action)
        {
            STViewsInfo       viewResult = null;
            STViewsController viewCtrl   = new STViewsController();

            String strViewNo = VoucherProvider.GetViewNo(strTableName, iMainID);

            if (!String.IsNullOrWhiteSpace(strViewNo))
            {
                viewResult = viewCtrl.GetObjectByNo(strViewNo) as STViewsInfo;
            }
            if (viewResult == null)
            {
                #region Without Voucher
                BusinessObjectController controller = BusinessControllerFactory.GetBusinessController(strTableName);
                if (controller == null)
                {
                    return;
                }

                BusinessObject obj = controller.GetObjectByID(iMainID);
                if (obj == null)
                {
                    return;
                }


                List <BusinessObject> lstViews = viewCtrl.GetListFromDataset(viewCtrl.GetDataSet(String.Format("SELECT * FROM STViews WHERE [MainTableName] = '{0}' ", strTableName)));
                foreach (STViewsInfo viewIfo in lstViews)
                {
                    if (String.IsNullOrWhiteSpace(viewIfo.MainFieldName) == false && DataStructureProvider.IsTableColumn(strTableName, viewIfo.MainFieldName))
                    {
                        object objValue = ABCBusinessEntities.ABCDynamicInvoker.GetValue(obj, viewIfo.MainFieldName);
                        if (objValue != null && objValue.ToString().ToUpper().Trim() == viewIfo.MainValue.ToUpper())
                        {
                            viewResult = viewIfo;
                            break;
                        }
                    }
                }

                if (viewResult == null && lstViews.Count > 0)
                {
                    viewResult = lstViews[0] as STViewsInfo;
                }

                #endregion
            }

            if (viewResult != null)
            {
                ABCScreenManager.Instance.RunLink(viewResult, mode, isShowDialog, iMainID, action);
            }
        }
Exemple #22
0
        public void PopulateControls(ABCView view, String BusName, String strTableName)
        {
            ViewOwner  = view;
            DataSource = BusName;
            TableName  = strTableName;
            int iCount            = 0;
            ABCSearchControl ctrl = null;

            foreach (DataConfigProvider.FieldConfig fieldConfig in DataConfigProvider.TableConfigList[strTableName].FieldConfigList.Values)
            {
                if (fieldConfig.InUse == false)
                {
                    continue;
                }

                if (DataStructureProvider.IsPrimaryKey(strTableName, fieldConfig.FieldName) ||
                    DataStructureProvider.IsForeignKey(strTableName, fieldConfig.FieldName))
                {
                    continue;
                }

                if (fieldConfig.IsDefault)
                {
                    if (view != null && view.Mode == ViewMode.Design)
                    {
                        ctrl = (ABCSearchControl)view.Surface.DesignerHost.CreateComponent(typeof(ABCSearchControl));
                    }
                    else
                    {
                        ctrl = (ABCSearchControl)ABCDynamicInvoker.CreateInstanceObject(typeof(ABCSearchControl));
                    }

                    ABCSearchInfo searchInfo = new ABCSearchInfo();
                    searchInfo.DataSource = BusName;
                    searchInfo.TableName  = TableName;
                    searchInfo.DataMember = fieldConfig.FieldName;

                    ctrl.Initialize(view, searchInfo);
                    ctrl.Parent = this.DropZone;
                    iCount++;
                }
            }

            if (iCount % 2 != 0)
            {
                iCount++;
            }
            iCount = iCount / 2;
            if (ctrl != null)
            {
                this.Size = new Size(ctrl.Width * 2 + 4 * 3, 20 * iCount + (iCount + 1) * 5 + 25);
            }
        }
 void ConfigGridView_CustomRowCellEdit(object sender, DevExpress.XtraGrid.Views.Grid.CustomRowCellEditEventArgs e)
 {
     if (e.Column.FieldName == "FilterString")
     {
         ABCGridColumn.ColumnConfig config = this.ConfigGridView.GetRow(this.ConfigGridView.FocusedRowHandle) as ABCGridColumn.ColumnConfig;
         if (config == null || DataStructureProvider.IsForeignKey(config.TableName, config.FieldName) == false)
         {
             e.RepositoryItem = null;
             return;
         }
     }
 }
Exemple #24
0
        void ABCGridLookUpEdit_QueryPopUp(object sender, CancelEventArgs e)
        {
            if (String.IsNullOrWhiteSpace(this.ParentCtrlName) == false && String.IsNullOrWhiteSpace(this.ChildField) == false)
            {
                if (ParentControl == null)
                {
                    Form      frm         = this.FindForm();
                    Control[] parentCtrls = frm.Controls.Find(this.ParentCtrlName, true);
                    if (parentCtrls != null && parentCtrls.Length > 0)
                    {
                        if (parentCtrls[0] is IABCBindableControl && parentCtrls[0] is ABCBindingBaseEdit == false)
                        {
                            ParentControl = parentCtrls[0] as IABCBindableControl;
                        }
                        else if (parentCtrls[0] is ABCBindingBaseEdit && (parentCtrls[0] as ABCBindingBaseEdit).EditControl is IABCBindableControl)
                        {
                            ParentControl = (parentCtrls[0] as ABCBindingBaseEdit).EditControl as IABCBindableControl;
                        }
                    }
                }

                if (ParentControl != null && ParentControl is IABCBindableControl && DataStructureProvider.IsTableColumn(LookupTableName, ChildField))
                {
                    object objValue = ParentControl.GetType().GetProperty((ParentControl as IABCBindableControl).BindingProperty).GetValue(ParentControl, null);
                    if (objValue != null)
                    {
                        DataView newView = DataCachingProvider.TryToGetDataView(this.LookupTableName, true);
                        newView.RowFilter = DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(DevExpress.Data.Filtering.CriteriaOperator.Parse(DefaultFilterString));

                        String strFilter = String.Empty;
                        if (objValue.GetType() == typeof(int) || objValue.GetType() == typeof(double) ||
                            objValue.GetType() == typeof(Nullable <int>) || objValue.GetType() == typeof(Nullable <double>) ||
                            objValue.GetType() == typeof(Boolean) || objValue.GetType() == typeof(Nullable <Boolean>))
                        {
                            strFilter = String.Format(@" {0} = {1} ", ChildField, objValue);
                        }
                        if (objValue.GetType() == typeof(String))
                        {
                            strFilter = String.Format(@" {0} = '{1}' ", ChildField, objValue.ToString());
                        }
                        if (String.IsNullOrWhiteSpace(newView.RowFilter) == false)
                        {
                            strFilter = " AND " + strFilter;
                        }
                        newView.RowFilter += strFilter;

                        this.Properties.DataSource = newView;
                    }
                }
            }
        }
Exemple #25
0
        private void DrawLinkButton(DevExpress.XtraVerticalGrid.Events.CustomDrawRowValueCellEventArgs e)
        {
            if (this.ABCGrid == null ||
                (this.ABCGrid.OwnerView != null && this.ABCGrid.OwnerView.Mode != ViewMode.Design))
            {
                if (e.Row != null && e.Row.Tag is ABCGridColumn.ColumnConfig && String.IsNullOrWhiteSpace(this.ABCGrid.TableName) == false && e.CellValue != null && e.CellValue.GetType() == typeof(int))
                {
                    Boolean isDraw = false;

                    EditorRow gridRow      = e.Row as EditorRow;
                    String    strTableName = this.ABCGrid.TableName;
                    if (gridRow.Properties.FieldName.Contains(":") == false)
                    {
                        if (ForeignColumnList.TryGetValue(gridRow.Properties.FieldName, out isDraw) == false)
                        {
                            if (DataStructureProvider.IsForeignKey(strTableName, gridRow.Properties.FieldName))
                            {
                                ForeignColumnList.Add(gridRow.Properties.FieldName, true);
                            }
                            else
                            {
                                ForeignColumnList.Add(gridRow.Properties.FieldName, false);
                            }
                        }
                    }
                    else
                    {
                        DataCachingProvider.AccrossStructInfo acrrosInfo = DataCachingProvider.GetAccrossStructInfo(strTableName, ABCHelper.DataConverter.ConvertToGuid(e.CellValue), e.Row.Properties.FieldName);
                        if (acrrosInfo != null && (acrrosInfo.FieldName == DataStructureProvider.GetNOColumn(acrrosInfo.TableName) ||
                                                   acrrosInfo.FieldName == DataStructureProvider.GetNAMEColumn(acrrosInfo.TableName)))
                        {
                            isDraw = true;
                        }
                    }

                    if (isDraw)
                    {
                        e.Graphics.DrawImage(ABCControls.ABCImageList.GetImage16x16("DocLink"), e.Bounds.Location);

                        Rectangle r = e.Bounds;
                        r.Width -= 18;
                        r.X     += 18;
                        e.Appearance.DrawString(e.Cache, e.CellText, r);

                        e.Handled = true;
                    }
                }
            }
        }
Exemple #26
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);
                        }
                    }
                }
            }
        }
        public void RefreshDisplayGrid( )
        {
            DisplayGridCtrl.TableName = this.TableName;
            DisplayGridCtrl.Grid.Fields.Clear();
            DisplayGridCtrl.FieldConfigs = this.FieldsList;
            DisplayGridCtrl.InitFields();
            DisplayGridCtrl.Grid.OptionsView.RowTreeWidth = RowTreeWidth;
            DisplayGridCtrl.UseChartControl = UseChartControl;
            DisplayGridCtrl.Script          = Script;

            if (String.IsNullOrWhiteSpace(this.TableName))
            {
                DisplayGridCtrl.LoadDataSourceFromScript();
                return;
            }
            if (DataCachingProvider.LookupTables.ContainsKey(this.TableName))
            {
                this.DisplayGridCtrl.GridDataSource = DataCachingProvider.LookupTables[this.TableName];
            }
            else
            {
                ABCHelper.ConditionBuilder strBuilder = new ABCHelper.ConditionBuilder();
                strBuilder.Append(String.Format(@"SELECT TOP 5 * FROM {0}", this.TableName));


                if (DataStructureProvider.IsExistABCStatus(this.TableName))
                {
                    strBuilder.AddCondition(QueryGenerator.GenerateCondition(this.TableName, ABCCommon.ABCColumnType.ABCStatus));
                }

                strBuilder.Append(String.Format(@" ORDER BY {0} DESC", DataStructureProvider.GetPrimaryKeyColumn(this.TableName)));

                try
                {
                    DataSet ds = DataQueryProvider.RunQuery(strBuilder.ToString());
                    if (ds != null && ds.Tables.Count > 0)
                    {
                        this.DisplayGridCtrl.GridDataSource = ds.Tables[0];
                    }
                }
                catch (Exception ex)
                {
                }
            }

            this.DisplayGridCtrl.RefreshDataSource();
            DisplayGridCtrl.Grid.FieldsCustomization(splitContainerControl2.Panel2);
        }
        public void RefreshData(Boolean includeParent, Boolean includeChildren, Boolean defaultOnly)
        {
            #region Current Node
            if (InnerData != null)
            {
                BusinessObjectController ctrller = BusinessControllerFactory.GetBusinessController(InnerData.AATableName);
                String strPK = DataStructureProvider.GetPrimaryKeyColumn(InnerData.AATableName);
                Guid   iID   = ABCHelper.DataConverter.ConvertToGuid(ABCBusinessEntities.ABCDynamicInvoker.GetValue(InnerData, strPK));
                InnerData = ctrller.GetObjectByID(iID);
                if (InnerData == null)
                {
                    if (this.ParentNode != null)
                    {
                        this.ParentNode.ChildrenNodes.Remove(iID);
                        this.ParentNode = null;
                    }
                    Dictionary <Guid, ABCTreeListNode> innerList = null;
                    if (this.Manager.DataList.TryGetValue(this.ObjectName, out innerList))
                    {
                        if (innerList.ContainsKey(iID))
                        {
                            innerList.Remove(iID);
                        }
                    }
                }
            }
            #endregion

            List <ABCTreeListNode> lstTemps = new List <ABCTreeListNode>();
            foreach (ABCTreeListNode childNode in this.ChildrenNodes.Values)
            {
                lstTemps.Add(childNode);
            }

            if (includeChildren)
            {
                foreach (ABCTreeListNode childNode in lstTemps)
                {
                    childNode.RefreshData(false, includeChildren, defaultOnly);
                }
            }
            if (includeParent && this.ParentNode != null)
            {
                this.ParentNode.RefreshData(true, false, defaultOnly);
            }

            ExpandData(includeChildren, defaultOnly);
        }
 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;
             }
         }
     }
 }
Exemple #30
0
        public DataSet GetDataSetByColumn(String strFieldName, object objValue)
        {
            if (DataStructureProvider.IsTableColumn(TableName, strFieldName) == false)
            {
                return(null);
            }

            String strTypeName = DataStructureProvider.GetCodingType(TableName, strFieldName);

            if (strTypeName == "String" || strTypeName == "DateTime" || strTypeName == "Guid" || strTypeName == "Nullable<Guid>")
            {
                return(GetDataSet(String.Format("SELECT * FROM {0} WHERE {1} = '{2}' ", TableName, strFieldName, objValue)));
            }

            return(GetDataSet(String.Format("SELECT * FROM {0} WHERE {1} = {2} ", TableName, strFieldName, objValue)));
        }