Exemplo n.º 1
0
        /**********************  新增/查詢/拷貝/存檔/刪除 相關 Function **********************/
        #region WfIniMaster() 設定表單主要的資料來源
        protected virtual Boolean WfIniMaster()
        {
            try
            {
                // 以 FormID 由 Pu_pgm 中取得表單設定
                #region 初始化 PU_BUSOBJ
                if (GlobalVar.PU_BUSOBJ != null)
                {
                    this.BoSecurity = (YR.ERP.BLL.MSSQL.AdmBLL)GlobalVar.PU_BUSOBJ;
                }
                else
                {
                    if (GlobalVar.Adm_DAO != null)
                    {
                        this.BoSecurity = new AdmBLL((YR.ERP.DAL.ERP_MSSQLDAL)GlobalVar.Adm_DAO);
                    }
                    else
                    {
                        //this.BoSecurity = new AdmBLL();
                    }
                }
                #endregion

                if (BoSecurity == null)
                {
                    return(false);
                }
                this.AdoModel = BoSecurity.OfGetAdoModel(StrFormID);
                if (AdoModel == null)
                {
                    return(false);
                }
                this.TabMaster.TargetTable  = AdoModel.ado05;
                this.TabMaster.TargetColumn = "*";
                this.TabMaster.ViewTable    = AdoModel.ado06;
                if (TabMaster.ViewTable == "")
                {
                    TabMaster.ViewTable = TabMaster.TargetTable;
                }

                if (BoSecurity == null)
                {
                    throw new Exception("物件BoSecurity,尚未初始化!");
                    //return false;
                }
                this.TabMaster.AzaTbList  = BoSecurity.OfGetAzaModels(TabMaster.ViewTable);
                this.TabMaster.AddTbModel = BoSecurity.OfGetAddModel(LoginInfo.UserRole, StrFormID);

                // 建立 Form Master 的 Business Object : boBasic
                this.WfCreateBoBasic();
                //取得baa_tb共用參數代碼
                if (BaaModel == null)
                {
                    using (var boBas = new BasBLL(BoMaster.OfGetConntion()))
                    {
                        if (BoMaster.TRAN != null)
                        {
                            boBas.TRAN = BoMaster.TRAN;
                        }
                        BaaModel = boBas.OfGetBaaModel();
                    }
                }

                #region 取得日期格式
                var baa01KvpList = new BasBLL().OfGetBaa01KVPList();//取得日期格式
                this.DateFormat = baa01KvpList.Where(x => x.Key == BaaModel.baa01)
                                  .Select(x => x.Value)
                                  .FirstOrDefault()
                ;

                if (GlobalFn.varIsNull(DateFormat))
                {
                    DateFormat = "yyyy/MM/dd";
                }
                else //取得格式會含有 . ex:1.yyyy/MM/dd 要剔除
                {
                    if (DateFormat.IndexOf('.') >= 0)
                    {
                        var dotPosition = DateFormat.IndexOf('.');
                        DateFormat = DateFormat.Substring(dotPosition + 1, DateFormat.Length - dotPosition - 1);
                    }
                }
                #endregion

                // 先取得空的資料表
                if (this.TabMaster.ViewTable != "")
                {
                    this.TabMaster.DtSource = this.TabMaster.BoBasic.OfSelect(" WHERE 1=2 ");
                    TabMaster.DtSource.Rows.Add(TabMaster.DtSource.NewRow());

                    this.WfSetMasterDatasource(this.TabMaster.DtSource);
                    this.BindingMaster.MoveFirst();
                    DrMaster = TabMaster.DtSource.Rows[0];
                    WfSetMasterRowDefault(DrMaster);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(true);
        }