예제 #1
0
        public DataTable Codes(string codeName, object vWhere, bool noCache)
        {
            string      sListname = codeName + this.AppMan.Language;
            DataTable   olist     = new DataTable(codeName);
            WhereClause wc        = new WhereClause();

            if (!noCache)
            {
                if (this.MyColCodes.ContainsKey(sListname))
                {
                    return((DataTable)this.MyColCodes[sListname]);
                }
            }

            switch (codeName.ToUpper())
            {
            case "VOUTCOME":
            case "OUTCOME":
                if (vWhere == null)
                {
                    int decID = 1;

                    if (GetSSTMng().DB.SSTCase.Count > 0 && !GetSSTMng().DB.SSTCase[0].IsDecisionTypeNull())
                    {
                        decID = GetSSTMng().DB.SSTCase[0].DecisionType;
                    }

                    if (GetSSTMng().DB.SSTDecision.Count > 0)
                    {
                        SST.SSTDecisionRow[] sdrs = (SST.SSTDecisionRow[])GetSSTMng().GetSSTDecision().GetCurrentRow();
                        if (sdrs.Length == 1)
                        {
                            decID = sdrs[0].DecisionType;
                        }
                    }
                    wc.Add("DecisionType", "=", decID);
                    wc.Add("Obsolete", "=", 0);
                    olist   = this.AtMng.GetGeneralRec("select * from vOutcomeList " + wc.Clause() + " order by sortkey");
                    noCache = true;
                }
                else
                {
                    wc = (WhereClause)vWhere;
                    wc.Add("Obsolete", "=", 0);
                    olist = this.AtMng.GetGeneralRec("select * from vOutcomeList " + wc.Clause() + " order by sortkey");
                }
                break;

            case "SSTPARTYTYPE":
                int prgId = 0;
                if (GetSSTMng().DB.SSTCase.Rows.Count > 0)
                {
                    prgId = GetSSTMng().GetSSTCase().EffectiveProgram(GetSSTMng().DB.SSTCase[0]);
                }

                wc.Add("ProgramId", "=", prgId);
                wc.Add("Obsolete", "=", 0);
                olist   = this.AtMng.GetGeneralRec("vSSTContactTypeList", wc);
                noCache = true;
                break;

            case "CHILDFILETYPE":
                appDB.EFileSearchRow pfr = this.EFile.GetEfileParentRow(this.CurrentFile);
                if (pfr != null)
                {
                    string ft = pfr.FileType;
                    wc.Add("ParentFileType", "=", ft);
                    sListname += ft;
                }
                else
                {
                    string ft = this.CurrentFile.FileType;
                    wc.Add("ParentFileType", "=", ft);
                    sListname += ft;
                }
                if (this.MyColCodes.ContainsKey(sListname))
                {
                    return((DataTable)this.MyColCodes[sListname]);
                }

                olist = this.AtMng.GetGeneralRec("vFileTypeList", wc);
                break;

            case "CHILDMETATYPE":
                appDB.EFileSearchRow pfr1 = this.EFile.GetEfileParentRow(this.CurrentFile);
                if (pfr1 != null)
                {
                    string mt = pfr1.MetaType;
                    wc.Add("ParentMetaType", "=", mt);
                    sListname += mt;
                }
                else
                {
                    string mt = this.CurrentFile.MetaType;
                    wc.Add("ParentMetaType", "=", mt);
                    sListname += mt;
                }

                if (this.MyColCodes.ContainsKey(sListname))
                {
                    return((DataTable)this.MyColCodes[sListname]);
                }

                olist = this.AtMng.GetGeneralRec("vMetaTypeList", wc);

                break;

            case "PROVINCE":
                if (vWhere != null)
                {
                    wc = (WhereClause)vWhere;
                }
                wc.Add("Obsolete", "=", 0);
                olist = this.AtMng.GetGeneralRec(codeName, wc);
                if (1 == 1)
                {
                    DataColumn[] keys = new DataColumn[1];
                    keys[0]          = olist.Columns["ProvinceCode"];
                    olist.PrimaryKey = keys;
                }
                break;

            case "VOFFICECLIENTLIST":
                olist            = this.AtMng.GetGeneralRec("vOfficeClientList", wc);
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficeID"] };
                break;

            case "VOFFICELIST":
            case "OFFICELIST":
            case "AGENTLIST":
                olist            = this.AtMng.GetGeneralRec("vOfficeList", wc);
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficeID"] };
                break;

            case "AGENTLISTSPECIAL":
                olist = this.AtMng.GetGeneralRec("Select * from Office as a inner join address as ad on a.addressid=ad.addressid");
                break;

            case "VOFFICERLIST":
            case "OFFICERLIST":
                if (vWhere == null)
                {
                    olist = this.AtMng.GetGeneralRec("vOfficerList", wc);
                }
                else if (vWhere.GetType() == typeof(WhereClause))
                {
                    olist = this.AtMng.GetGeneralRec("vOfficerList", (WhereClause)vWhere);
                }
                else if ((bool)vWhere == true)
                {
                    wc.Add("CurrentEmployee", "=", 1);
                    olist = this.AtMng.GetGeneralRec("vOfficerList", wc);
                }
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficerID"] };
                break;

            case "LAWYERLIST":
                wc.Add("CurrentEmployee", "=", 1);
                olist = AtMng.GetGeneralRec("vLawyerList", wc);

                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficerID"] };
                break;

            case "OWNERLIST":
                olist = this.OfficerByOffice(this.CurrentFile.OwnerOfficeId, true, true);
                break;

            case "AGENTLOGGEDONOFFLIST":
                olist = this.OfficerByOffice(this.AtMng.OfficeLoggedOn.OfficeId, true, true);
                break;

            case "OFFICERACCESSLIST":
                wc.Add("FileId", "=", this.CurrentFile.FileId);
                wc.Add("CurrentEmployee", "=", 1);
                olist            = this.AtMng.GetGeneralRec("vOfficerAccessList", wc);
                olist.PrimaryKey = new DataColumn[] { olist.Columns["OfficerID"] };
                break;

            case "LEADLIST":
            case "AGENTOFFLIST":
                olist = this.OfficerByOffice(this.CurrentFile.LeadOfficeId, true, true);
                break;

            default:
                if (vWhere == null)
                {
                    return(AtMng.GetddLookup().Codes(codeName, this));
                }
                else
                {
                    olist = this.AtMng.GetGeneralRec(codeName, (WhereClause)vWhere);
                }
                break;
            }
            switch (codeName.ToUpper())
            {
            case "SELJUDGMENT":
                break;

            case "SELWRIT":
                break;

            default:
                if (!noCache)
                {
                    this.MyColCodes.Add(sListname, olist);
                }
                break;
            }

            if (olist.PrimaryKey.Length == 0)
            {
                olist.PrimaryKey = new DataColumn[] { olist.Columns[0] };
            }
            return(olist);
        }