예제 #1
0
 //保存新初始值
 public bool SetIniValue(int UsrNum, IniValue NewIniValue)
 {
     //插入财务指标信息
     InsertIniValue("财务指标季末记录", NewIniValue.FinancialTargetIniValueCollection);
     //插入产品库存初始值
     InsertIniValue("产品库存", NewIniValue.ProductIniNum);
     //插入产品研发状态
     InsertIniValue("产品研发状态", NewIniValue.ProductReaschIniStatus);
     //筹资记录
     InsertIniValue("筹资记录", NewIniValue.FinanceServiceIni);
     //生产线信息
     InsertIniValue("生产线状态", NewIniValue.ProductLineIniStatus);
     //市场初始资格
     InsertIniValue("市场准入状态", NewIniValue.MarketQuaIni);
     //应收账款
     InsertIniValue("应收款信息", NewIniValue.UncollectibleAccountsIni);
     //原材料信息
     InsertIniValue("原材料状态信息", NewIniValue.RawMaterialNumIni);
     return true;
 }
예제 #2
0
        //读取默认初始值..参数结构如何设计
        public IniValue GetDefaultIniValue(int UsrNum)
        {
            IniValue IniValueEntity = new IniValue(UsrNum);
            string sql;
            DataTable datatable = new DataTable();
            OleDbDataAdapter adapter;
            //读取财务指标季末记录汇总初始值并匹配目标格式
            IniValueEntity.FinancialTargetIniValueCollection = new DataTable();
            IniValueEntity.FinancialTargetIniValueCollection.Columns.Add("财务指标编号");
            IniValueEntity.FinancialTargetIniValueCollection.Columns.Add("年份");
            IniValueEntity.FinancialTargetIniValueCollection.Columns.Add("季度");
            IniValueEntity.FinancialTargetIniValueCollection.Columns.Add("用户编号");
            IniValueEntity.FinancialTargetIniValueCollection.Columns.Add("财务指标值");

            sql = "SELECT 财务指标编号,默认初始值 FROM 财务指标信息汇总";
            adapter = new OleDbDataAdapter(sql, conn);
            adapter.Fill(datatable);

            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                DataRow row = IniValueEntity.FinancialTargetIniValueCollection.NewRow();
                row["财务指标编号"] = datatable.Rows[i][0];
                row["年份"] = 0;
                row["季度"] = 0;
                row["用户编号"] = UsrNum;
                row["财务指标值"] = datatable.Rows[i][1];
                IniValueEntity.FinancialTargetIniValueCollection.Rows.Add(row);

            }
            //Console.WriteLine(IniValueEntity.FinancialTargetIniValueCollection.Rows[20][4].ToString());//显示是否读取成功

            //产品库存初始值
            IniValueEntity.ProductIniNum = new DataTable();
            IniValueEntity.ProductIniNum.Columns.Add("用户编号");
            IniValueEntity.ProductIniNum.Columns.Add("产品编号");
            IniValueEntity.ProductIniNum.Columns.Add("产品数量");
            sql = "SELECT 产品编号,初始库存量 FROM 产品信息";
            adapter = new OleDbDataAdapter(sql, conn);
            datatable=new DataTable();
            adapter.Fill(datatable);
            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                DataRow row = IniValueEntity.ProductIniNum.NewRow();
                row["用户编号"] = UsrNum;
                row["产品编号"] = datatable.Rows[i][0];
                row["产品数量"] = datatable.Rows[i][1];
                IniValueEntity.ProductIniNum.Rows.Add(row);
            }
            //产品研发状态初始化,不用显示
            IniValueEntity.ProductReaschIniStatus = new DataTable();
            IniValueEntity.ProductReaschIniStatus.Columns.Add("用户编号");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("产品编号");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("已投资年限");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("是否研发成功");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("投资起始年份");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("投资起始季度");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("投资结束年份");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("投资结束季度");
            IniValueEntity.ProductReaschIniStatus.Columns.Add("是否正在研发");
            for (int i = 0; i < 4; i++)
            {
                DataRow row = IniValueEntity.ProductReaschIniStatus.NewRow();
                if (i == 0)
                {
                    row["用户编号"] = UsrNum;
                    row["产品编号"] = i + 1;
                    row["已投资年限"] = 0;
                    row["是否研发成功"] = 1; //row["是否研发成功"] = true;
                    row["投资起始年份"] = 0;
                    row["投资起始季度"] = 0;
                    row["投资结束年份"] = 0;
                    row["投资结束季度"] = 0;
                    row["是否正在研发"] = 0; //row["是否正在研发"] = false;

                }
                else
                {
                    row["用户编号"] = UsrNum;
                    row["产品编号"] = i + 1;
                    row["已投资年限"] = 0;
                    row["是否研发成功"] = 0; //row["是否研发成功"] = false;
                    row["投资起始年份"] = 0;
                    row["投资起始季度"] = 0;
                    row["投资结束年份"] = 0;
                    row["投资结束季度"] = 0;
                    row["是否正在研发"] = 0; //row["是否正在研发"] = false;
                }
                IniValueEntity.ProductReaschIniStatus.Rows.Add(row);
            }

            //筹资记录初始化,更改或不该?
            IniValueEntity.FinanceServiceIni = new DataTable();
            //IniValueEntity.FinanceServiceIni.Columns.Add("筹资编号");//自动编号
            IniValueEntity.FinanceServiceIni.Columns.Add("筹资类型");
            IniValueEntity.FinanceServiceIni.Columns.Add("用户编号");
            IniValueEntity.FinanceServiceIni.Columns.Add("筹资年份");
            IniValueEntity.FinanceServiceIni.Columns.Add("筹资季度");
            IniValueEntity.FinanceServiceIni.Columns.Add("筹资金额");
            IniValueEntity.FinanceServiceIni.Columns.Add("是否结清");
            IniValueEntity.FinanceServiceIni.Columns.Add("已过周期");
            IniValueEntity.FinanceServiceIni.Columns.Add("还款周期");
            sql = "SELECT 筹资类型,筹资金额,周期 FROM 筹资初始状态表";
            adapter = new OleDbDataAdapter(sql, conn);
            datatable = new DataTable();
            adapter.Fill(datatable);
            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                DataRow row = IniValueEntity.FinanceServiceIni.NewRow();
                //row["筹资编号"] = i+1;
                row["筹资类型"] = datatable.Rows[i][0];
                row["用户编号"] = UsrNum;
                row["筹资年份"] = 1;
                row["筹资季度"] = 1;
                row["筹资金额"] = datatable.Rows[i][1];
                row["是否结清"] = 0;//row["是否结清"] = false;
                row["已过周期"] = 0;
                row["还款周期"] = datatable.Rows[i][2];
                IniValueEntity.FinanceServiceIni.Rows.Add(row);
            }

            //生产线信息
            IniValueEntity.ProductLineIniStatus = new DataTable();
            //IniValueEntity.ProductLineIniStatus.Columns.Add("生产线编号");//自动编号
            IniValueEntity.ProductLineIniStatus.Columns.Add("生产线类型");
            IniValueEntity.ProductLineIniStatus.Columns.Add("厂房编号");
            IniValueEntity.ProductLineIniStatus.Columns.Add("当前产品生产时长");
            IniValueEntity.ProductLineIniStatus.Columns.Add("产品编号");
            IniValueEntity.ProductLineIniStatus.Columns.Add("用户编号");
            IniValueEntity.ProductLineIniStatus.Columns.Add("获取年份");
            IniValueEntity.ProductLineIniStatus.Columns.Add("获取季度");
            IniValueEntity.ProductLineIniStatus.Columns.Add("失去年份");
            IniValueEntity.ProductLineIniStatus.Columns.Add("失去季度");
            IniValueEntity.ProductLineIniStatus.Columns.Add("残值");
            IniValueEntity.ProductLineIniStatus.Columns.Add("已建设周期");
            IniValueEntity.ProductLineIniStatus.Columns.Add("转产完成周期");
            IniValueEntity.ProductLineIniStatus.Columns.Add("转产目标产品编号");
            IniValueEntity.ProductLineIniStatus.Columns.Add("生产线状态");
            IniValueEntity.ProductLineIniStatus.Columns.Add("余值");
            IniValueEntity.ProductLineIniStatus.Columns.Add("建设开始年份");
            IniValueEntity.ProductLineIniStatus.Columns.Add("建设开始季度");
            IniValueEntity.ProductLineIniStatus.Columns.Add("转产开始年份");
            IniValueEntity.ProductLineIniStatus.Columns.Add("转产开始季度");
            sql = "SELECT 生产线编号,生产线类型,厂房编号,当前产品生产时长,产品编号,生产线状态 FROM 生产线初始状态";
            adapter = new OleDbDataAdapter(sql, conn);
            datatable = new DataTable();
            adapter.Fill(datatable);
            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                DataRow row = IniValueEntity.ProductLineIniStatus.NewRow();
                //row["生产线编号"] = datatable.Rows[i][0];
                row["生产线类型"] = datatable.Rows[i][1];
                row["厂房编号"] = datatable.Rows[i][2];
                row["当前产品生产时长"] = datatable.Rows[i][3];
                row["产品编号"] = datatable.Rows[i][4];
                row["用户编号"] = UsrNum;
                row["获取年份"] = 0;
                row["获取季度"] = 0;
                row["失去年份"] = 0;
                row["失去季度"] = 0;
                row["失去年份"] = 0;
                if(i<3)
                {
                    row["残值"]=1;
                }
                else if(i==3)
                {
                    row["残值"]=2;
                }
                else {row["残值"]=0;}
                row["已建设周期"] = 0;
                row["转产完成周期"] = 0;
                row["转产目标产品编号"] = 0;
                row["生产线状态"] = datatable.Rows[i][5];
                if(i<3)
                {
                    row["余值"]=5;
                }
                else if(i==3)
                {
                    row["余值"]=8;
                }
                else {row["余值"]=0;}
                row["建设开始年份"] = 0;
                row["建设开始季度"] = 0;
                row["转产开始年份"] = 0;
                row["转产开始季度"] = 0;

                IniValueEntity.ProductLineIniStatus.Rows.Add(row);
            }
            //市场初始资格
            IniValueEntity.MarketQuaIni=new DataTable();
            IniValueEntity.MarketQuaIni.Columns.Add("用户编号");
            IniValueEntity.MarketQuaIni.Columns.Add("市场编号");
            IniValueEntity.MarketQuaIni.Columns.Add("已投资年限");
            IniValueEntity.MarketQuaIni.Columns.Add("是否获取准入资格");
            IniValueEntity.MarketQuaIni.Columns.Add("投资起始年份");
            IniValueEntity.MarketQuaIni.Columns.Add("完成投资年份");
            IniValueEntity.MarketQuaIni.Columns.Add("是否正在投资");
            for (int i = 0; i < 5; i++)
            {
                DataRow row = IniValueEntity.MarketQuaIni.NewRow();
                row["用户编号"] = UsrNum;
                row["市场编号"] = i + 1;
                row["已投资年限"] = 0;
                if (i == 0) row["是否获取准入资格"] = 1;//row["是否获取准入资格"] = true;
                else row["是否获取准入资格"] = 0;//row["是否获取准入资格"] = false;
                row["投资起始年份"] = 0;
                row["完成投资年份"] = 0;
                row["是否正在投资"] = 0; //row["是否正在投资"] = false;
                IniValueEntity.MarketQuaIni.Rows.Add(row);
            }
            //厂房信息??
            //应收账款信息
            IniValueEntity.UncollectibleAccountsIni = new DataTable();
            //IniValueEntity.UncollectibleAccountsIni.Columns.Add("应收款信息编号");//自动编号
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("用户编号");//
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("财务指标编号");
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("收款周期");
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("已过时间");
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("是否完成收款");
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("应收款金额");
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("开始年份");
            IniValueEntity.UncollectibleAccountsIni.Columns.Add("开始季度");
            sql = "SELECT 财务指标编号,收款周期,已过时间,是否完成收款,应收款金额 FROM 应收款初始信息表";
            adapter = new OleDbDataAdapter(sql, conn);
            datatable = new DataTable();
            adapter.Fill(datatable);
            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                DataRow row = IniValueEntity.UncollectibleAccountsIni.NewRow();
                //row["应收款信息编号"] = i+1;
                row["用户编号"] = UsrNum;
                row["财务指标编号"] = datatable.Rows[i][0];
                row["收款周期"] = datatable.Rows[i][1];
                row["已过时间"] = datatable.Rows[i][2];
                row["是否完成收款"] = Convert.ToInt32(datatable.Rows[i][3]);
                row["应收款金额"] = datatable.Rows[i][4];
                row["开始年份"] = 1;
                row["开始季度"] = 1;
                IniValueEntity.UncollectibleAccountsIni.Rows.Add(row);
            }
            //原材料信息
            IniValueEntity.RawMaterialNumIni = new DataTable();
            IniValueEntity.RawMaterialNumIni.Columns.Add("原材料编号");
            IniValueEntity.RawMaterialNumIni.Columns.Add("用户编号");
            IniValueEntity.RawMaterialNumIni.Columns.Add("原材料数量");
            IniValueEntity.RawMaterialNumIni.Columns.Add("订单数量");
            IniValueEntity.RawMaterialNumIni.Columns.Add("在途数量");
            sql = "SELECT 原材料编号,初始原料数量,初始原料订单 FROM 原材料信息";
            adapter = new OleDbDataAdapter(sql, conn);
            datatable = new DataTable();
            adapter.Fill(datatable);
            for (int i = 0; i < datatable.Rows.Count; i++)
            {
                DataRow row = IniValueEntity.RawMaterialNumIni.NewRow();
                row["原材料编号"] = datatable.Rows[i][0];
                row["用户编号"] = UsrNum;
                row["原材料数量"] = datatable.Rows[i][1];
                row["订单数量"] = datatable.Rows[i][2];
                row["在途数量"] = 0;

                IniValueEntity.RawMaterialNumIni.Rows.Add(row);
            }
            return IniValueEntity;
        }