Пример #1
0
        public static void Init_from_DB()
        {
            if ((DateTime.Now - DTC_model_master.lastUpdateTime).TotalHours < Utility.RefreshInterval)
            {
                return;
            }

            DTC_model_master.Reset();
            DB_select selt = new DB_select(DTCPositionModelNumber_Mapping.Get_cmdTP());

            DB_reader reader = new DB_reader(selt, Utility.Get_DRWIN_hDB());

            while (reader.Read())
            {
                DTCPositionModelNumber_Mapping dm = new DTCPositionModelNumber_Mapping();
                dm.Init_from_reader(reader);

                DTC_model_master.mapping_dic[dm.ModelNumber.Value] = dm;

                if (!DTC_model_master.country_dic.ContainsKey(dm.Country.Value))
                {
                    List <DTCPositionModelNumber_Mapping> list = new List <DTCPositionModelNumber_Mapping>();
                    DTC_model_master.country_dic[dm.Country.Value] = list;
                }
                DTC_model_master.country_dic[dm.Country.Value].Add(dm);
            }
            reader.Close();

            DTC_model_master.lastUpdateTime = DateTime.Now;
        }
        internal HssUtility.SQLserver.DB_update Get_DBupdate()
        {
            if (!this.CheckValueChanges())
            {
                return(null);
            }

            HssUtility.SQLserver.DB_update upd = new HssUtility.SQLserver.DB_update(DTCPositionModelNumber_Mapping.Get_cmdTP());
            if (this.Country.ValueChanged)
            {
                upd.AddValue("Country", this.Country);
            }
            if (this.Issue.ValueChanged)
            {
                upd.AddValue("Issue", this.Issue);
            }
            if (this.RecordYear.ValueChanged)
            {
                upd.AddValue("RecordYear", this.RecordYear);
            }
            if (this.IncomeEvent.ValueChanged)
            {
                upd.AddValue("IncomeEvent", this.IncomeEvent);
            }
            if (this.ModelNumber.ValueChanged)
            {
                upd.AddValue("ModelNumber", this.ModelNumber);
            }
            if (this.ADRRecordDate.ValueChanged)
            {
                upd.AddValue("ADRRecordDate", this.ADRRecordDate);
            }
            if (this.ORDPayDate.ValueChanged)
            {
                upd.AddValue("ORDPayDate", this.ORDPayDate);
            }
            if (this.SecurityTypeID.ValueChanged)
            {
                upd.AddValue("SecurityTypeID", this.SecurityTypeID);
            }
            if (this.ADRRecordDate_End.ValueChanged)
            {
                upd.AddValue("ADRRecordDate_End", this.ADRRecordDate_End);
            }
            if (this.AtSourceSumFromDetails.ValueChanged)
            {
                upd.AddValue("AtSourceSumFromDetails", this.AtSourceSumFromDetails);
            }

            HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("DTCModelMappingID", HssUtility.General.RelationalOperator.Equals, this.pk_ID);
            upd.SetCondition(rela);

            return(upd);
        }
Пример #3
0
        public static DTCPositionModelNumber_Mapping GetMapping_country(string countryName, string secName, DateTime curr_dt, int secTypeID)
        {
            DTC_model_master.Init_from_DB();
            if (string.IsNullOrEmpty(countryName))
            {
                return(null);
            }
            if (!DTC_model_master.country_dic.ContainsKey(countryName))
            {
                return(null);
            }

            List <DTCPositionModelNumber_Mapping> list = DTC_model_master.country_dic[countryName];
            int i = 0, j = list.Count - 1;

            while (i < j)//put the mapping with issue in front, quick sort
            {
                while (i < j && !string.IsNullOrEmpty(list[i].Issue.Value))
                {
                    ++i;
                }
                while (i < j && string.IsNullOrEmpty(list[j].Issue.Value))
                {
                    --j;
                }

                DTCPositionModelNumber_Mapping temp = list[i];
                list[i] = list[j];
                list[j] = temp;
            }

            foreach (DTCPositionModelNumber_Mapping dm in list)
            {
                if (curr_dt < dm.ADRRecordDate.Value)
                {
                    continue;
                }
                if (curr_dt > dm.ADRRecordDate_End.Value)
                {
                    continue;
                }
                if (dm.SecurityTypeID.Value != secTypeID)
                {
                    continue;
                }

                if (dm.CheckIssueMatch(secName))
                {
                    return(dm);
                }
            }

            return(null);
        }
        public DTCPositionModelNumber_Mapping GetCopy()
        {
            DTCPositionModelNumber_Mapping newEntity = new DTCPositionModelNumber_Mapping();

            if (!this.Country.IsNull_flag)
            {
                newEntity.Country.Value = this.Country.Value;
            }
            if (!this.Issue.IsNull_flag)
            {
                newEntity.Issue.Value = this.Issue.Value;
            }
            if (!this.RecordYear.IsNull_flag)
            {
                newEntity.RecordYear.Value = this.RecordYear.Value;
            }
            if (!this.IncomeEvent.IsNull_flag)
            {
                newEntity.IncomeEvent.Value = this.IncomeEvent.Value;
            }
            if (!this.ModelNumber.IsNull_flag)
            {
                newEntity.ModelNumber.Value = this.ModelNumber.Value;
            }
            if (!this.ADRRecordDate.IsNull_flag)
            {
                newEntity.ADRRecordDate.Value = this.ADRRecordDate.Value;
            }
            if (!this.ORDPayDate.IsNull_flag)
            {
                newEntity.ORDPayDate.Value = this.ORDPayDate.Value;
            }
            if (!this.SecurityTypeID.IsNull_flag)
            {
                newEntity.SecurityTypeID.Value = this.SecurityTypeID.Value;
            }
            if (!this.ADRRecordDate_End.IsNull_flag)
            {
                newEntity.ADRRecordDate_End.Value = this.ADRRecordDate_End.Value;
            }
            if (!this.AtSourceSumFromDetails.IsNull_flag)
            {
                newEntity.AtSourceSumFromDetails.Value = this.AtSourceSumFromDetails.Value;
            }
            return(newEntity);
        }
        /// <summary>
        /// Initialize object from DB
        /// </summary>
        public bool Init_from_DB()
        {
            if (this.DTCModelMappingID < 0)
            {
                return(false);
            }

            HssUtility.SQLserver.DB_select db_sel = new HssUtility.SQLserver.DB_select(DTCPositionModelNumber_Mapping.Get_cmdTP());
            db_sel.tableName = "DTCPositionModelNumber_Mapping";
            HssUtility.SQLserver.SQL_relation rela = new HssUtility.SQLserver.SQL_relation("DTCModelMappingID", HssUtility.General.RelationalOperator.Equals, this.DTCModelMappingID);
            db_sel.SetCondition(rela);

            bool res_flag = false;

            HssUtility.SQLserver.DB_reader reader = new HssUtility.SQLserver.DB_reader(db_sel, Utility.Get_DRWIN_hDB());
            if (reader.Read())
            {
                this.Init_from_reader(reader);
                res_flag = true;
            }
            reader.Close();
            return(res_flag);
        }
        internal HssUtility.SQLserver.DB_insert Get_DBinsert()
        {
            HssUtility.SQLserver.DB_insert dbIns = new HssUtility.SQLserver.DB_insert(DTCPositionModelNumber_Mapping.Get_cmdTP());

            dbIns.AddValue("Country", this.Country);                               /*Optional 2*/
            dbIns.AddValue("Issue", this.Issue);                                   /*Optional 3*/
            dbIns.AddValue("RecordYear", this.RecordYear);                         /*Optional 4*/
            dbIns.AddValue("IncomeEvent", this.IncomeEvent);                       /*Optional 5*/
            dbIns.AddValue("ModelNumber", this.ModelNumber.Value);
            dbIns.AddValue("ADRRecordDate", this.ADRRecordDate);                   /*Optional 7*/
            dbIns.AddValue("ORDPayDate", this.ORDPayDate);                         /*Optional 8*/
            dbIns.AddValue("SecurityTypeID", this.SecurityTypeID);                 /*Optional 9*/
            dbIns.AddValue("ADRRecordDate_End", this.ADRRecordDate_End);           /*Optional 10*/
            dbIns.AddValue("AtSourceSumFromDetails", this.AtSourceSumFromDetails); /*Optional 11*/

            return(dbIns);
        }