Ejemplo n.º 1
0
        public IEnumerable<IStockStructure> GetAll()
        {
            List<StockStructure> result = new List<StockStructure>();
            string sql = string.Format("SELECT * FROM {0}", tableName);

            using (SqlCeConnection conn = new SqlCeConnection(ConnectionString))
            {
                conn.Open();

                using (SqlCeCommand cmd = new SqlCeCommand(sql, conn))
                {
                    SqlCeDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        StockStructure dbo = new StockStructure
                        {
                            DateOfChange = DateTime.Parse(reader[colDateOfChange].ToString().Trim()),
                            DateOfDeclaration = DateTime.Parse(reader[colDateOfDeclaration].ToString().Trim()),
                            DomesticLegalPersonShares = Double.Parse(reader[colDomesticLegalPersonShares].ToString().Trim()),
                            DomesticSponsorsShares = Double.Parse(reader[colDomesticSponsorsShares].ToString().Trim()),
                            ExecutiveShares = Double.Parse(reader[colExecutiveShares].ToString().Trim()),
                            FundsShares = Double.Parse(reader[colFundsShares].ToString().Trim()),
                            GeneralLegalPersonShares = Double.Parse(reader[colGeneralLegalPersonShares].ToString().Trim()),
                            InternalStaffShares = Double.Parse(reader[colInternalStaffShares].ToString().Trim()),
                            PreferredStock = Double.Parse(reader[colPreferredStock].ToString().Trim()),
                            RaiseLegalPersonShares = Double.Parse(reader[colRaiseLegalPersonShares].ToString().Trim()),
                            Reason = reader[colReason].ToString().Trim(),
                            RestrictedSharesA = Double.Parse(reader[colRestrictedSharesA].ToString().Trim()),
                            RestrictedSharesB = Double.Parse(reader[colRestrictedSharesB].ToString().Trim()),
                            SharesA = Double.Parse(reader[colSharesA].ToString().Trim()),
                            SharesB = Double.Parse(reader[colSharesB].ToString().Trim()),
                            SharesH = Double.Parse(reader[colSharesH].ToString().Trim()),
                            StateOwnedLegalPersonShares = Double.Parse(reader[colStateOwnedLegalPersonShares].ToString().Trim()),
                            StateShares = Double.Parse(reader[colStateShares].ToString().Trim()),
                            StrategicInvestorsShares = Double.Parse(reader[colStrategicInvestorsShares].ToString().Trim()),
                            TotalShares = Double.Parse(reader[colTotalShares].ToString().Trim()),
                            TransferredAllottedShares = Double.Parse(reader[colTransferredAllottedShares].ToString().Trim()),
                        };
                        result.Add(dbo);
                    }
                    reader.Close();
                }

                conn.Close();
            }
            return result;
        }
Ejemplo n.º 2
0
        public void TestStockStructureReadAndWrite()
        {
            StockStructure insertData = new StockStructure()
            {
                /// <summary>
                /// 变动日期
                /// </summary>
                DateOfChange = new DateTime(2016, 1, 15),
                /// <summary>
                /// 公告日期
                /// </summary>
                DateOfDeclaration = new DateTime(2016, 1, 17),
                /// <summary>
                /// 变更原因
                /// </summary>
                Reason = "*******************",

                /// <summary>
                /// 总股本
                /// </summary>
                TotalShares = 0,
                /// <summary>
                /// 流通A股
                /// </summary>
                SharesA = 0,
                /// <summary>
                /// 高管股
                /// </summary>
                ExecutiveShares = 0,
                /// <summary>
                /// 限售A股
                /// </summary>
                RestrictedSharesA = 0,
                /// <summary>
                /// 流通B股
                /// </summary>
                SharesB = 0,
                /// <summary>
                /// 限售B股
                /// </summary>
                RestrictedSharesB = 0,
                /// <summary>
                /// 流通H股
                /// </summary>
                SharesH = 0,
                /// <summary>
                /// 国家股
                /// </summary>
                StateShares = 0,
                /// <summary>
                /// 国有法人股
                /// </summary>
                StateOwnedLegalPersonShares = 0,
                /// <summary>
                /// 境内法人股
                /// </summary>
                DomesticLegalPersonShares = 0,
                /// <summary>
                /// 境内发起人股
                /// </summary>
                DomesticSponsorsShares = 0,
                /// <summary>
                /// 募集法人股
                /// </summary>
                RaiseLegalPersonShares = 0,
                /// <summary>
                /// 一般法人股
                /// </summary>
                GeneralLegalPersonShares = 0,
                /// <summary>
                /// 战略投资者持股
                /// </summary>
                StrategicInvestorsShares = 0,
                /// <summary>
                /// 基金持股
                /// </summary>
                FundsShares = 0,
                /// <summary>
                /// 转配股
                /// </summary>
                TransferredAllottedShares = 0,
                /// <summary>
                /// 内部职工股
                /// </summary>
                InternalStaffShares = 0,
                /// <summary>
                /// 优先股
                /// </summary>
                PreferredStock = 0,
            };
            string fileName = "StockStructure.sdf";
            string fullPath = Path.Combine(directory, fileName);

            // Add
            using (IRepositoryContext context = ContextFactory.Create(ContextType.StockStructure, fullPath))
            {
                var repository = new Repository<StockStructure>(context);
                repository.Add(insertData);
                repository.UnitOfWork.Commit();
            }

            // Read
            StockStructure readData;
            using (IRepositoryContext context = ContextFactory.Create(ContextType.StockStructure, fullPath))
            {
                var repository = new Repository<StockStructure>(context);
                readData = repository.Get(insertData.DateOfChange);
            }
            Assert.IsNotNull(readData);
            Assert.AreEqual(insertData.DateOfChange, readData.DateOfChange);

            // update
            StockStructure updatedData = readData;
            updatedData.SharesA = 100;
            using (IRepositoryContext context = ContextFactory.Create(ContextType.StockStructure, fullPath))
            {
                var repository = new Repository<StockStructure>(context);
                repository.Update(updatedData);
                repository.UnitOfWork.Commit();
            }
            // Read
            using (IRepositoryContext context = ContextFactory.Create(ContextType.StockStructure, fullPath))
            {
                var repository = new Repository<StockStructure>(context);
                readData = repository.Get(insertData.DateOfChange);
            }
            Assert.AreEqual(readData.SharesA, 100);
        }
Ejemplo n.º 3
0
        public static StockStructure ToDataObject(this IStockStructure self)
        {
            StockStructure outputData = new StockStructure
            {
                DateOfChange = self.DateOfChange,
                DateOfDeclaration = self.DateOfDeclaration,
                DomesticLegalPersonShares = self.DomesticLegalPersonShares,
                DomesticSponsorsShares = self.DomesticSponsorsShares,
                ExecutiveShares = self.ExecutiveShares,
                FundsShares = self.FundsShares,
                GeneralLegalPersonShares = self.GeneralLegalPersonShares,
                InternalStaffShares = self.InternalStaffShares,
                PreferredStock = self.PreferredStock,
                RaiseLegalPersonShares = self.RaiseLegalPersonShares,
                Reason = self.Reason,
                RestrictedSharesA = self.RestrictedSharesA,
                RestrictedSharesB = self.RestrictedSharesB,
                SharesA = self.SharesA,
                SharesB = self.SharesB,
                SharesH = self.SharesH,
                StateOwnedLegalPersonShares = self.StateOwnedLegalPersonShares,
                StateShares = self.StateShares,
                StrategicInvestorsShares = self.StrategicInvestorsShares,
                TotalShares = self.TotalShares,
                TransferredAllottedShares = self.TransferredAllottedShares
            };

            return outputData;
        }