Пример #1
0
        public virtual void ActionInvalidate(int objectID)
        {
            VinaDbUtil dbUtil     = new VinaDbUtil();
            string     tableName  = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
            string     primaryKey = dbUtil.GetTablePrimaryColumn(tableName);

            if (Toolbar.ObjectCollection != null)
            {
                for (int i = 0; i < Toolbar.ObjectCollection.Tables[0].Rows.Count; i++)
                {
                    if (objectID == Convert.ToInt32(Toolbar.ObjectCollection.Tables[0].Rows[i][primaryKey]))
                    {
                        Toolbar.CurrentIndex = i;
                        //FocusRowOfGridSearchResultByToolbarCurrentIndex();
                        return;
                    }
                }
            }

            //If can't find the object in toolbar's collection
            BaseBusinessController controller = BusinessControllerFactory.GetBusinessController(tableName + "Controller");

            if (controller != null)
            {
                DataSet ds = controller.GetDataSetByID(objectID);
                Toolbar.SetToolbar(ds);
                //InvalidateAfterSearch(null, String.Empty);
            }
        }
Пример #2
0
        public static bool IsAuthenticated(string username, string password, out string strMessage)
        {
            strMessage = string.Empty;
            ADUsersController adUsersController = new ADUsersController();
            ADUsersInfo       objUsersInfo      = (ADUsersInfo)adUsersController.GetObjectByName(username);

            if (objUsersInfo == null)
            {
                return(false);
            }

            if (!objUsersInfo.ADUserActiveCheck)
            {
                strMessage = "Tài khoản của bạn đã bị khóa. Vui lòng thử lại sau!";
                return(false);
            }

            if (!objUsersInfo.ADPassword.Equals(VinaUtil.EncryptMD5Hash(password)))
            {
                strMessage = "Tài khoản hoặc mật khẩu không chính xác. Vui lòng thử lại!";
                return(false);
            }
            VinaApp.CurrentUserName = objUsersInfo.ADUserName;
            VinaApp.CurrentUserInfo = objUsersInfo;
            return(true);
        }
Пример #3
0
        public virtual int Save()
        {
            int  iObjectID  = 0;
            bool isContinue = true;

            VinaDbUtil dbUtil       = new VinaDbUtil();
            String     strMainTable = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);

            String strMainTablePrimaryColumn = strMainTable.Substring(0, strMainTable.Length - 1) + "ID";
            String strMainTableNoColumn      = strMainTablePrimaryColumn.Substring(0, strMainTablePrimaryColumn.Length - 2) + "No";
            String strObjectNo = dbUtil.GetPropertyStringValue(CurrentModuleEntity.MainObject, strMainTableNoColumn);

            isContinue = IsValidObjectNo(strObjectNo);
            if (isContinue)
            {
                iObjectID = CurrentModuleEntity.SaveMainObject();

                if (iObjectID > 0)
                {
                    CurrentModuleEntity.SaveModuleObjects();
                }
                return(iObjectID);
            }
            else
            {
                return(0);
            }
        }
Пример #4
0
        protected virtual bool IsValidObjectNo(string objectNo)
        {
            VinaDbUtil             dbUtil = new VinaDbUtil();
            BaseBusinessController objCurrentObjectController = BusinessControllerFactory.GetBusinessController(CurrentModuleEntity.MainObject.GetType().Name.Substring(0, CurrentModuleEntity.MainObject.GetType().Name.Length - 4) + "Controller");
            String mainTable = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
            String mainTablePrimaryColumn = dbUtil.GetTablePrimaryColumn(mainTable);
            bool   isValid = true;

            if (!String.IsNullOrEmpty(objectNo))
            {
                if (this.Toolbar.ModuleAction == BaseToolbar.ModuleNew)
                {
                    if (objCurrentObjectController.IsExist(objectNo))
                    {
                        MessageBox.Show("Mã đã tồn tại trong hệ thống vui lòng nhập mã khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        isValid = false;
                    }
                }
                else if (this.Toolbar.ModuleAction == BaseToolbar.ModuleEdit)
                {
                    BusinessObject objMainObject = (BusinessObject)objCurrentObjectController.GetObjectByNo(objectNo);
                    if (objMainObject != null)
                    {
                        int iMainObjectID = Convert.ToInt32(dbUtil.GetPropertyValue(objMainObject, mainTablePrimaryColumn));
                        if (iMainObjectID != Toolbar.CurrentObjectID)
                        {
                            MessageBox.Show("Mã đã tồn tại trong hệ thống vui lòng nhập mã khác!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            isValid = false;
                        }
                    }
                }
            }
            return(isValid);
        }
Пример #5
0
 public bool IsValidForeignKeyProperty(String strForeignKeyColumn)
 {
     try
     {
         VinaDbUtil dbUtil = new VinaDbUtil();
         //String strMainObjectTableName = MainObject.GetType().Name.Substring(0, MainObject.GetType().Name.Length - 4);
         String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
         String strPrimaryTable        = ((IBaseModuleERP)Module).GetTreePrimaryTableWhichForeignColumnReferenceTo(strMainObjectTableName, strForeignKeyColumn);
         String strPrimaryColumn       = ((IBaseModuleERP)Module).GetTreePrimaryTableWhichForeignColumnReferenceTo(strMainObjectTableName, strForeignKeyColumn);
         BaseBusinessController objPrimaryTableObjectController = BusinessControllerFactory.GetBusinessController(strPrimaryTable + "Controller");
         int iForeignKeyColumnValue = Convert.ToInt32(dbUtil.GetPropertyValue(MainObject, strForeignKeyColumn));
         if (iForeignKeyColumnValue > 0)
         {
             return(objPrimaryTableObjectController.IsExist(iForeignKeyColumnValue));
         }
         else
         {
             return(false);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #6
0
        protected virtual DataSet GetSearchData()
        {
            String mainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
            BaseBusinessController objCurrentObjectController = BusinessControllerFactory.GetBusinessController(mainObjectTableName + "Controller");

            return(objCurrentObjectController.GetAllObjects());
        }
Пример #7
0
 private void UpdateUser()
 {
     ADUsers.ADUserName        = Convert.ToString(fld_txtUsername.EditValue);
     ADUsers.ADPassword        = VinaUtil.EncryptMD5Hash(Convert.ToString(fld_txtPassword.EditValue));
     ADUsers.FK_HREmployeeID   = Convert.ToInt32(fld_lkeHREmployeeID.EditValue);
     ADUsers.FK_ADUserGroupID  = Convert.ToInt32(fld_lkeUserGroup.EditValue);
     ADUsers.ADUserActiveCheck = Convert.ToBoolean(fld_chkIsActive.EditValue);
 }
Пример #8
0
        public virtual int CreateMainObject()
        {
            VinaDbUtil dbUtil       = new VinaDbUtil();
            int        iObjectID    = 0;
            bool       editObjectNo = true;

            //Get Table which Business object Represent
            String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
            BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(strMainObjectTableName + "Controller");

            //Set Object No value
            String strPrimaryColumn = strMainObjectTableName.Substring(0, strMainObjectTableName.Length - 1) + "ID";
            String strColumnNo      = strMainObjectTableName.Substring(0, strMainObjectTableName.Length - 1) + "No";
            String strMainObjectNo  = dbUtil.GetPropertyStringValue(MainObject, strColumnNo);
            int    numberingStart   = 0;

            try
            {
                if (strMainObjectNo.Equals(NewObjectNoText))
                {
                    editObjectNo    = false;
                    strMainObjectNo = GetMainObjectNo(ref numberingStart);
                    dbUtil.SetPropertyValue(MainObject, strColumnNo, strMainObjectNo);
                }

                //Set Created User, Created Date
                dbUtil.SetPropertyValue(MainObject, AACreatedUser, VinaApp.CurrentUserName);
                dbUtil.SetPropertyValue(MainObject, AACreatedDate, DateTime.Now);


                iObjectID = dbUtil.GetPropertyIntValue(MainObject, strPrimaryColumn);
                if (iObjectID == 0)
                {
                    iObjectID = objMainObjectController.CreateObject(MainObject);
                }
                else
                {
                    objMainObjectController.CreateObject(MainObject, iObjectID);
                }
            }
            catch (Exception ex)
            {
                if (!editObjectNo)
                {
                    dbUtil.SetPropertyValue(MainObject, strColumnNo, NewObjectNoText);
                    dbUtil.SetPropertyValue(MainObject, strPrimaryColumn, 0);
                }

                iObjectID = 0;
                MessageBox.Show(ex.Message.ToString());
            }

            return(iObjectID);
        }
Пример #9
0
        private void fld_dteHRRewardFromDate_Validated(object sender, EventArgs e)
        {
            int      n1           = fld_dteHRTimeSheetDate.DateTime.Year;
            int      n2           = fld_dteHRTimeSheetDate.DateTime.Month;
            DateTime date         = new DateTime(n1, n2, 1);
            DateTime dateEndMonth = VinaUtil.GetMonthEndDate(date);

            fld_dteHRTimeSheetToDate.DateTime   = dateEndMonth;
            fld_dteHRTimeSheetFromDate.DateTime = date;
            ((TimeSheetModule)Module).ChangeTimeSheetTime();
        }
Пример #10
0
        public override void SetDefaultMainObject()
        {
            base.SetDefaultMainObject();
            HRTimeSheetsInfo objTimeSheetsInfo = (HRTimeSheetsInfo)MainObject;

            objTimeSheetsInfo.HRTimeSheetDate     = DateTime.Now;
            objTimeSheetsInfo.HRTimeSheetFromDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
            objTimeSheetsInfo.HRTimeSheetToDate   = VinaUtil.GetMonthEndDate(DateTime.Now);
            objTimeSheetsInfo.HRTimeSheetType     = TimeSheetType.Day.ToString();
            objTimeSheetsInfo.HRTimeSheetStatus   = TimeSheetStatus.New.ToString();
            objTimeSheetsInfo.FK_HREmployeeID     = VinaApp.CurrentUserInfo.FK_HREmployeeID;
        }
Пример #11
0
        public virtual void CreateMainObjectRule()
        {
            VinaDbUtil dbUtil = new VinaDbUtil();

            MainObject.BusinessRuleCollections = new List <BusinessRule>();
            String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);

            DataSet dsColumns = dbUtil.GetNotAllowNullTableColumns(strMainObjectTableName);

            if (dsColumns.Tables.Count > 0)
            {
                AAColumnAliasController  objColumnAlliasController = new AAColumnAliasController();
                List <AAColumnAliasInfo> LstColumnAlias            = objColumnAlliasController.GetColumnAliasByTableName(strMainObjectTableName);
                foreach (DataRow rowColumn in dsColumns.Tables[0].Rows)
                {
                    String strColumnName            = rowColumn["COLUMN_NAME"].ToString();
                    String strBrokenRuleDescription = String.Empty;
                    //Add rule if column is not primary key
                    if (!dbUtil.IsPrimaryKey(strMainObjectTableName, strColumnName))
                    {
                        //If column does not allow null
                        if (!dbUtil.ColumnIsAllowNull(strMainObjectTableName, strColumnName))
                        {
                            AAColumnAliasInfo objColumnAliasInfo = LstColumnAlias.Where(a => a.AATableName == strMainObjectTableName &&
                                                                                        a.AAColumnAliasName == strColumnName).FirstOrDefault();
                            if (objColumnAliasInfo != null)
                            {
                                strBrokenRuleDescription = String.Format(string.Format("{0} không thể để trống", objColumnAliasInfo.AAColumnAliasCaption));
                            }
                            else
                            {
                                strBrokenRuleDescription = String.Format(string.Format("{0} không thể để trống", strColumnName));
                            }

                            if (((IBaseModuleERP)Module).IsForeignKey(strMainObjectTableName, strColumnName))
                            {
                                BusinessRule foreignKeyRule = new BusinessRule(
                                    strColumnName,
                                    strBrokenRuleDescription,
                                    IsValidForeignKeyProperty);
                                MainObject.BusinessRuleCollections.Add(foreignKeyRule);
                            }
                            else
                            {
                                BusinessRule nonForeignKeyRule = new BusinessRule(strColumnName, strBrokenRuleDescription, IsValidNonForeignKeyPropety);
                                MainObject.BusinessRuleCollections.Add(nonForeignKeyRule);
                            }
                        }
                    }
                }
            }
            dsColumns.Dispose();
        }
Пример #12
0
        public virtual int UpdateMainObject()
        {
            int    iObjectID = 0;
            String strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
            BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(strMainObjectTableName + "Controller");

            VinaDbUtil dbUtil = new VinaDbUtil();

            dbUtil.SetPropertyValue(MainObject, AAUpdatedUser, VinaApp.CurrentUserName);
            dbUtil.SetPropertyValue(MainObject, AAUpdatedDate, DateTime.Now);

            iObjectID = objMainObjectController.UpdateObject(MainObject);
            return(iObjectID);
        }
Пример #13
0
        public virtual void ActionNew()
        {
            Cursor.Current = Cursors.WaitCursor;
            this.Toolbar.New();
            this.ParentScreen.InvalidateToolbarAfterActionNew();

            //this.SaveUserAudit("Create");
            //this.InvalidateFieldGroupControls("New");
            //if (this.ParentScreen.IsObjectListExpanded)
            //    this.ParentScreen.CollapseObjectList();
            VinaUtil.GetTableNameFromBusinessObject(this.CurrentModuleEntity.MainObject);
            SetDefaultEmployee();
            Cursor.Current = Cursors.Default;
        }
Пример #14
0
        public virtual void Invalidate(int iObjectID)
        {
            string strTableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
            BaseBusinessController objBaseBusinessController = BusinessControllerFactory.GetBusinessController(strTableName + "Controller");
            BusinessObject         mainObject = (BusinessObject)objBaseBusinessController.GetObjectByID(iObjectID);

            if (mainObject != null)
            {
                CurrentModuleEntity.Invalidate(iObjectID);

                CurrentModuleEntity.MainObject.OldObject = (BusinessObject)CurrentModuleEntity.MainObject.Clone();

                InvalidateToolbar();
            }
            InvalidateEmployee();
        }
Пример #15
0
        public virtual void InitializeModule()
        {
            STModulesController objModulesController = new STModulesController();

            CurrentModuleID = objModulesController.GetObjectIDByName(CurrentModuleName);

            CurrentModuleEntity.InitModuleEntity();

            InitModuleToolbarEvents();

            InitializeScreens();

            CurrentModuleEntity.InitGridControlInVinaList();

            MainTableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);

            MainTablePrefix = MainTableName.Substring(0, MainTableName.Length - 1);
        }
Пример #16
0
        protected virtual bool IsInvalidInput()
        {
            CurrentModuleEntity.CreateMainObjectRule();
            this.ErrorTable = this.InitErrorTable();
            this.CheckExtraInput();
            if (this.CurrentModuleEntity.MainObject != null)
            {
                VinaDbUtil bosDbUtil = new VinaDbUtil();
                this.ErrorTable.Rows.Clear();
                //TODO Check Error From Database
                string dataSource = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
                foreach (BusinessRule r in CurrentModuleEntity.MainObject.BusinessRuleCollections)
                {
                    bool isRuleBroken = !r.ValidateRule(CurrentModuleEntity.MainObject);
                    if (isRuleBroken)
                    {
                        AddErrorToErrorScreen(r.Description, dataSource, r.PropertyName);
                    }
                }
            }
            if (this.ErrorTable.Rows.Count == 0)
            {
                return(false);
            }

            if (this.ErrorMessageScreen == null)
            {
                this.ErrorMessageScreen        = new GuiErrorMessage(this.ErrorTable);
                this.ErrorMessageScreen.Module = (BaseModule)this;
            }
            else if (this.ErrorMessageScreen.IsDisposed)
            {
                this.ErrorMessageScreen        = new GuiErrorMessage(this.ErrorTable);
                this.ErrorMessageScreen.Module = (BaseModule)this;
            }
            //this.ErrorMessageScreen.Show();
            if (ErrorTable.Rows.Count > 0)
            {
                ErrorMessageScreen = new GuiErrorMessage(this.ErrorTable);
                ErrorMessageScreen.ShowDialog();
                return(true);
            }
            return(true);
        }
Пример #17
0
 public override void BindingDataControl(Control ctrl)
 {
     try
     {
         VinaDbUtil        dbUtil          = new VinaDbUtil();
         String            strDataSource   = dbUtil.GetPropertyStringValue(ctrl, cstDataSourcePropertyName);
         String            strDataMember   = dbUtil.GetPropertyStringValue(ctrl, cstDataMemberPropertyName);
         String            strPropertyName = dbUtil.GetPropertyStringValue(ctrl, "VinaPropertyName");
         ERPModuleEntities entity          = ((BaseModuleERP)Module).CurrentModuleEntity;
         if (ctrl.Tag != null)
         {
             if (ctrl.Tag.Equals(DataControl))
             {
                 String strMainModuleTable = VinaUtil.GetTableNameFromBusinessObject(entity.MainObject);
                 if (strDataSource.Equals(strMainModuleTable))
                 {
                     if (((BaseModuleERP)Module).CurrentModuleEntity.MainObject != null)
                     {
                         ctrl.DataBindings.Add(
                             new Binding(strPropertyName,
                                         entity.MainObjectBindingSource,
                                         strDataMember,
                                         true,
                                         DataSourceUpdateMode.OnPropertyChanged));
                     }
                 }
             }
             else if (ctrl.Tag.Equals(SearchControl))
             {
                 if (entity.SearchObjectBindingSource != null)
                 {
                     ctrl.DataBindings.Add(new Binding(strPropertyName,
                                                       entity.SearchObjectBindingSource,
                                                       strDataMember,
                                                       true,
                                                       DataSourceUpdateMode.OnPropertyChanged));
                 }
             }
         }
     }
     catch (Exception)
     {
     }
 }
Пример #18
0
        public virtual void SetProductPrice(BusinessObject item)
        {
            VinaDbUtil dbUtil          = new VinaDbUtil();
            String     itemTableName   = VinaUtil.GetTableNameFromBusinessObject(item);
            string     itemTablePrefix = itemTableName.Substring(0, itemTableName.Length - 1);

            //Get Item Qty
            String  columnName = itemTablePrefix + "ProductQty";
            decimal qty        = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            if (qty == 0)
            {
                qty = 1;
                dbUtil.SetPropertyValue(item, columnName, qty);
            }

            //Get Item Unit Price
            columnName = itemTablePrefix + "ProductUnitPrice";
            decimal unitPrice = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            //Get Item Discount Percent
            columnName = itemTablePrefix + "DiscountPercent";
            decimal discountPercent = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            //Set Item Discount Amount
            columnName = itemTablePrefix + "DiscountAmount";
            decimal discountAmount = qty * unitPrice * discountPercent / 100;

            dbUtil.SetPropertyValue(item, columnName, discountAmount);

            //Get Item Tax Percent
            columnName = itemTablePrefix + "TaxPercent";
            decimal taxPercent = Convert.ToDecimal(dbUtil.GetPropertyValue(item, columnName));

            //Set Item Tax Amount
            columnName = itemTablePrefix + "TaxAmount";
            decimal taxAmount = (qty * unitPrice - discountAmount) * taxPercent / 100;

            dbUtil.SetPropertyValue(item, columnName, taxAmount);

            //Set Item Total Amount
            columnName = itemTablePrefix + "TotalAmount";
            dbUtil.SetPropertyValue(item, columnName, qty * unitPrice - discountAmount + taxAmount);
        }
Пример #19
0
        public virtual String GetMainObjectNo(ref int numberingStart)
        {
            String strMainObjectNo = String.Empty;
            GENumberingsController objGENumberingController = new GENumberingsController();
            GENumberingsInfo       objGENumberingInfo       = (GENumberingsInfo)objGENumberingController.GetObjectByName(Module.CurrentModuleName);

            if (objGENumberingInfo != null)
            {
                String mainTableName = VinaUtil.GetTableNameFromBusinessObject(MainObject);
                BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(mainTableName + "Controller");
                if (objMainObjectController != null)
                {
                    VinaDbUtil    dbUtil              = new VinaDbUtil();
                    string        strPrefixHaveYear   = DateTime.Now.Year.ToString().Substring(2, 2);
                    List <string> subMainObjectNoList = new List <string>();
                    subMainObjectNoList.Add(objGENumberingInfo.GENumberingPrefix);
                    if (objGENumberingInfo.GENumberingPrefixHaveYear)
                    {
                        subMainObjectNoList.Add(strPrefixHaveYear);
                    }
                    subMainObjectNoList.Add(objGENumberingInfo.GENumberingNumber.ToString().PadLeft(objGENumberingInfo.GENumberingLength, '0'));

                    strMainObjectNo = string.Join(".", subMainObjectNoList.ToArray());

                    numberingStart = objGENumberingInfo.GENumberingNumber;
                    while (objMainObjectController.IsExist(strMainObjectNo))
                    {
                        objGENumberingInfo.GENumberingNumber++;

                        subMainObjectNoList.Clear();
                        subMainObjectNoList.Add(objGENumberingInfo.GENumberingPrefix);
                        if (objGENumberingInfo.GENumberingPrefixHaveYear)
                        {
                            subMainObjectNoList.Add(strPrefixHaveYear);
                        }
                        subMainObjectNoList.Add(objGENumberingInfo.GENumberingNumber.ToString().PadLeft(objGENumberingInfo.GENumberingLength, '0'));

                        strMainObjectNo = string.Join(".", subMainObjectNoList.ToArray());
                        numberingStart  = objGENumberingInfo.GENumberingNumber;
                    }
                }
            }
            return(strMainObjectNo);
        }
Пример #20
0
        public int GetParentObjectID()
        {
            VinaDbUtil dbUtil          = new VinaDbUtil();
            int        iParentObjectID = 0;

            if (!String.IsNullOrEmpty(ParentTableName))
            {
                String strMainTableName = String.Empty;
                if (Entity.MainObject != null)
                {
                    strMainTableName = VinaUtil.GetTableNameFromBusinessObject(Entity.MainObject);
                }
                string strParentTablePrimaryKey = dbUtil.GetTablePrimaryColumn(ParentTableName);
                if (ParentTableName == strMainTableName)
                {
                    iParentObjectID = dbUtil.GetPropertyIntValue(Entity.MainObject, strParentTablePrimaryKey);
                }
            }
            return(iParentObjectID);
        }
Пример #21
0
        public virtual void SetDefaultMainObject()
        {
            try
            {
                VinaDbUtil vinaDbUtil = new VinaDbUtil();

                string fromBusinessObject = VinaUtil.GetTableNameFromBusinessObject(this.MainObject);
                string str = fromBusinessObject.Substring(0, fromBusinessObject.Length - 1) + "ID";
                this.MainObject = (BusinessObject)BusinessObjectFactory.GetBusinessObject(fromBusinessObject + "Info");

                vinaDbUtil.SetPropertyValue(this.MainObject, str.Substring(0, str.Length - 2) + "No", (object)BusinessObject.DefaultObjectNo);
                vinaDbUtil.SetPropertyValue(this.MainObject, "AAStatus", (object)BusinessObject.DefaultAAStatus);

                this.UpdateMainObjectBindingSource();
            }
            catch (Exception ex)
            {
                int num = (int)MessageBox.Show(ex.ToString());
            }
        }
Пример #22
0
        public virtual void Search()
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                String strMainObjectControllerName = VinaUtil.GetBusinessControllerNameFromBusinessObject(CurrentModuleEntity.MainObject);
                String strMainObjectTableName      = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
                BaseBusinessController objCurrentObjectController = BusinessControllerFactory.GetBusinessController(strMainObjectControllerName);
                Cursor.Current = Cursors.WaitCursor;

                string  searchQuery = string.Empty;
                DataSet ds          = GetSearchData();
                Toolbar.SetToolbar(ds);
                InvalidateAfterSearch(null, String.Empty);
                Cursor.Current = Cursors.Default;
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
                return;
            }
        }
Пример #23
0
        public virtual void InvalidateSearchResultsControl(object sender, String strEventName)
        {
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                VinaDbUtil             dbUtil                  = new VinaDbUtil();
                String                 strMainTableName        = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
                string                 mainTablePrimaryColumn  = dbUtil.GetTablePrimaryColumn(strMainTableName);
                BaseBusinessController objMainObjectController = BusinessControllerFactory.GetBusinessController(strMainTableName + "Controller");

                //Invalidate toolbar collection
                PropertyInfo[] properties;
                DataRow        newRow;
                String         strMainObjectTableName = VinaUtil.GetTableNameFromBusinessObject(CurrentModuleEntity.MainObject);
                int            iObjectID = Convert.ToInt32(dbUtil.GetPropertyValue(CurrentModuleEntity.MainObject, SqlDatabaseHelper.GetPrimaryKeyColumn(strMainObjectTableName)));

                if (Toolbar.ObjectCollection == null)
                {
                    DataSet ds = objMainObjectController.GetDataSetByID(iObjectID);
                    Toolbar.SetToolbar(ds);
                }
                else
                {
                    //if Toolbar.ModusAction is new, add new object to object collection of toolbar
                    if (Toolbar.ModuleAction == BaseToolbar.ModuleNew)
                    {
                        newRow = Toolbar.ObjectCollection.Tables[0].NewRow();
                        newRow = objMainObjectController.GetDataRowFromBusinessObject(newRow, CurrentModuleEntity.MainObject);
                        Toolbar.ObjectCollection.Tables[0].Rows.Add(newRow);
                        Toolbar.CurrentIndex = Toolbar.ObjectCollection.Tables[0].Rows.Count - 1;
                    }
                    else
                    {
                        //Update object in object collection of toolbar
                        properties = CurrentModuleEntity.MainObject.GetType().GetProperties();
                        int iCurrIndex = Toolbar.CurrentIndex;
                        for (int i = 0; i < properties.Length; i++)
                        {
                            if (Toolbar.ObjectCollection.Tables[0].Columns[properties[i].Name] != null)
                            {
                                Toolbar.ObjectCollection.Tables[0].Rows[iCurrIndex][properties[i].Name] = properties[i].GetValue(CurrentModuleEntity.MainObject, null);
                            }
                        }
                    }
                }


                //Invalidate search result control
                Control searchResultControl = null;
                foreach (Control ctrl in Controls.Values)
                {
                    if (ctrl.Tag == VinaScreen.SearchResultControl)
                    {
                        searchResultControl = ctrl;
                        break;
                    }
                }

                if (searchResultControl != null)
                {
                    if (searchResultControl is GridControl)
                    {
                        VinaSearchResultsGridControl gridControl = searchResultControl as VinaSearchResultsGridControl;
                        GridView gridView = gridControl.Views[0] as GridView;
                        if (gridControl.DataSource == null)
                        {
                            VinaSearchResultsGridControl.BindingSearchResultGridControl(gridControl, Toolbar.ObjectCollection);
                        }
                        //gridControl.InvalidateLookupEditColumns();
                        gridView.RefreshData();
                        gridView.FocusedRowHandle = gridView.GetRowHandle(Toolbar.CurrentIndex);
                    }
                }
            }
            catch (Exception)
            {
            }
        }