예제 #1
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);
        }
예제 #2
0
        public Dictionary <List <STGridColumnsInfo>, DataSet> ShowModuleByJournal(String strSourceLeger, String strDocumentNo, ADInboxItemsInfo objInbox, STFieldsInfo objOldField)
        {
            STModulesController      ModuleCtrl      = new STModulesController();
            STModuleTablesController ModuleTableCtrl = new STModuleTablesController();

            int    iMainObjectID  = -1;
            String strTable       = String.Empty;
            String strTablePrefix = String.Empty;
            String strPrimaryKey  = String.Empty;
            Object MainObj        = null;

            int            iModuleID = 0;
            List <DataRow> dr        = GetLocalDataSet("STModuleID,STModuleName", "STModules", string.Format("STModuleName = '{0}'", strSourceLeger));

            if (dr.Count > 0)
            {
                iModuleID = Convert.ToInt32(dr.First()["STModuleID"]);
            }

            dr = GetLocalDataSet("STModuleTableID,STModuleTableName,STModuleID,STModuleTableLevelIndex", "STModuleTables", string.Format("STModuleID = {0} AND STModuleTableLevelIndex = 0", iModuleID));
            if (dr.Count > 0)
            {
                strTable = dr.First()["STModuleTableName"].ToString();
            }

            if (String.IsNullOrEmpty(strTable) == false)
            {
                strTablePrefix = strTable.Substring(0, strTable.Length - 1);
                strPrimaryKey  = strTablePrefix + "ID";
            }

            BaseBusinessController Ctrl = BusinessControllerFactory.GetBusinessController(strTable + "Controller");

            if (Ctrl != null)
            {
                MainObj = Ctrl.GetObjectByNo(strDocumentNo);
            }

            if (MainObj != null)
            {
                iMainObjectID = Convert.ToInt32(GMCDbUtil.GetPropertyValue(MainObj, strPrimaryKey));
                if (GMCDbUtil.GetPropertyValue(MainObj, "FK_HREmployeeID") != null)
                {
                    int iEmployeeID = Convert.ToInt32(GMCDbUtil.GetPropertyValue(MainObj, "FK_HREmployeeID"));
                    objInbox.FK_HRFromEmployeeID = iEmployeeID;
                }
                if (GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc") != null)
                {
                    //TextEdit txtRemark = (TextEdit)GetControlByName("fld_medADInboxItemRemark1");
                    //if (txtRemark != null)
                    //{
                    //    txtRemark.EditValue = GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc");
                    //}
                    objInbox.ADInboxItemMessage = Convert.ToString(GMCDbUtil.GetPropertyValue(MainObj, strTable.TrimEnd('s') + "Desc"));
                }
            }
            //ShowModuleByJournal(strSourceLeger, iMainObjectID, false);
            //Thang - edit 26/4/2016 hiển thị chi tiêt chứng từ

            ADUserGroupsInfo objUserGroup = AuthConfig.CurrenUserGroupInfo;

            dr = GetLocalDataSet("STScreenID,STScreenNumber,STModuleID,STUserGroupID,STScreenSortOrder", "STScreens", string.Format(@"STModuleID = {0} AND STUserGroupID = {1} 
                AND STScreenNumber like 'DM%' AND STScreenSortOrder > 0 AND STScreenSortOrder <= 1", iModuleID, objUserGroup.ADUserGroupID));
            int iScreenID = 0;

            if (dr.Count > 0)
            {
                iScreenID = Convert.ToInt32(dr.First()["STScreenID"]);
            }
            //Thang edit - 8/2/2017 Chỉnh sửa nếu 1 user group không có giao diện riêng thì sẽ lấy mặc định giao diện admin
            if (iScreenID == 0)
            {
                int iUserGroupDefaultID = new ADUserGroupsController().GetObjectIDByName("ADMIN");
                dr = GetLocalDataSet("STScreenID,STScreenNumber,STModuleID,STUserGroupID,STScreenSortOrder", "STScreens", string.Format(@"STModuleID = {0} AND STUserGroupID = {1} 
                AND STScreenNumber like 'DM%' AND STScreenSortOrder > 0 AND STScreenSortOrder <= 1", iModuleID, iUserGroupDefaultID));
                if (dr.Count > 0)
                {
                    iScreenID = Convert.ToInt32(dr.First()["STScreenID"]);
                }
            }

            dr = GetLocalDataSet("*", "STFields", string.Format(@"STScreenID = {0} AND STFieldType = 'GMCGridControl' 
                                        AND(STFieldDataSource like '%Items' OR STFieldDataSource like '%Details')
                                        AND STFieldGroup <> ''", iScreenID));
            if (dr.Count == 0)
            {
                return(null);
            }
            STFieldsInfo objField = (STFieldsInfo) new STFieldsController().GetObjectFromDataRow(dr[0]);

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

            BaseBusinessController itemCtrl = BusinessControllerFactory.GetBusinessController(objField.STFieldDataSource + "Controller");
            DataSet ds = new DataSet();

            if (itemCtrl != null)
            {
                ds = itemCtrl.GetAllDataByForeignColumn("FK_" + strPrimaryKey, iMainObjectID);
            }

            List <STGridColumnsInfo> lstGridColumns = new List <STGridColumnsInfo>();

            if (objOldField == null || !objOldField.STFieldID.Equals(objField.STFieldID))
            {
                objOldField = objField;
                dr          = GetLocalDataSet("*", "STGridColumns", string.Format("FK_STFieldID = {0}", objField.STFieldID));
                STGridColumnsController GridColCtrl = new STGridColumnsController();
                dr.Distinct().ToList().ForEach(x =>
                {
                    STGridColumnsInfo colInfo = (STGridColumnsInfo)GridColCtrl.GetObjectFromDataRow(x);
                    lstGridColumns.Add(colInfo);
                });
            }
            return(new Dictionary <List <STGridColumnsInfo>, DataSet>()
            {
                { lstGridColumns, ds }
            });
        }