Esempio n. 1
0
        void initidx()
        {
            if (isPerDiv100)
            {
                percdiv = 100;
            }

            //读取数据
            //select cast(ID as nvarchar(100)) id,sort, sort1,sort2,ord,indexname, definition,IMPORTANT,format,VALUE,UNIT,VALUENOTE,REFER1,REFER2,REFERTYPE,refernote,necessary from d_index where SORT0='863' order by ord,IMPORTANT
            SortIDX   sortidx;
            IndexData index;

            IEnumerable <string> sorts = idxDataSource.AsEnumerable().GroupBy(p => p.Field <string>("sort")).Select(p => p.Key);

            foreach (string sort in sorts)
            {
                sortidx = new SortIDX()
                {
                    name = sort + "指数", idx = 100
                };
                idxvm.sortgoods.Add(sortidx);
                sortidx = new SortIDX()
                {
                    name = sort + "指数", idx = 60
                };
                idxvm.sortbads.Add(sortidx);
                sortidx = new SortIDX()
                {
                    name = sort + "指数"
                };
                idxvm.sortidxes.Add(sortidx);



                IEnumerable <DataRow> drs = idxDataSource.AsEnumerable().Where(p => p.Field <string>("sort") == sort);
                foreach (DataRow dr in drs)
                {
                    if (dr["value"] is DBNull || dr["REFER1"] is DBNull || dr["IMPORTANT"] is DBNull || dr["REFERTYPE"] is DBNull)
                    {
                        continue;
                    }

                    index = new IndexData(sortidx)
                    {
                        id        = dr.Field <string>("id"),
                        name      = dr.Field <string>("indexname"),
                        define    = dr.Field <string>("definition"),
                        format    = dr.Field <string>("format"),
                        reftype   = dr.Field <string>("REFERTYPE"),
                        unit      = dr.Field <string>("UNIT"),
                        refnote   = dr.Field <string>("refernote"),
                        necessary = dr.Field <bool>("necessary"),
                        value     = double.Parse(dr["value"].ToString()),
                        ref1      = double.Parse(dr["REFER1"].ToString()),
                        important = int.Parse(dr["important"].ToString())
                    };
                    if (!(dr["REFER2"] is DBNull))
                    {
                        index.ref2 = double.Parse(dr["REFER2"].ToString());
                    }
                    if (index.unit == "%")
                    {
                        index.value = index.value / percdiv;
                        index.ref1  = index.ref1 / percdiv;
                        index.ref2  = index.ref2 / percdiv;
                    }

                    sortidx.indexes.Add(index);
                }
            }

            //计算指数
            foreach (SortIDX item in idxvm.sortidxes)
            {
                item.calidx();
            }

            //radgood.DataSource = sortgood;
            //radbad.DataSource = sortbad;
            //radidx.DataSource = sortidxes;


            grdMain.DataContext = idxvm;

            idxvm.selectSort = idxvm.sortidxes[0];
        }
Esempio n. 2
0
 private static void OnheightChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     IndexData Sender = (IndexData)d;
 }