コード例 #1
0
ファイル: KSJS.xaml.cs プロジェクト: rhk824/SBTP1217
        private void Btn_Compute_Click(object sender, RoutedEventArgs e)
        {
            //int rows = DataGrid1.Items.Count;
            //double bj = 0, tpmj = 0;
            //for (int i = 0; i < rows; i++)
            //{
            //    bj = double.Parse((DataGrid1.Columns[1].GetCellContent(DataGrid1.Items[i]) as TextBlock).Text);
            //    tpmj = 3.14 * bj * bj;
            //    (DataGrid1.Columns[6].GetCellContent(DataGrid1.Items[i]) as TextBlock).Text = tpmj.ToString();

            //    //double klnd = double.Parse((DataGrid1.Columns[7].GetCellContent(DataGrid1.Items[i]) as TextBlock).Text);
            //    //double kllj = double.Parse((DataGrid1.Columns[8].GetCellContent(DataGrid1.Items[i]) as TextBlock).Text);
            //}
            this.DataGrid1.ItemsSource = null;
            double total_bj = 0, total_tpmj = 0;

            foreach (KSJS_Model item in list)
            {
                item.TPMJ   = Math.Round(3.14 * item.BJ * item.BJ, 2);
                total_bj   += item.BJ;
                total_tpmj += item.TPMJ;
            }
            this.DataGrid1.ItemsSource = list;

            KSJS_Model hj = new KSJS_Model();

            hj.BJ   = Math.Round(total_bj / list.Count, 2);
            hj.TPMJ = Math.Round(total_tpmj / list.Count, 2);
            List <KSJS_Model> hj_list = new List <KSJS_Model>();

            hj_list.Add(hj);
            this.DataGrid2.ItemsSource = hj_list;
        }
コード例 #2
0
ファイル: KSJS.xaml.cs プロジェクト: rhk824/SBTP1217
        private void Btn_Import_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog op = new OpenFileDialog();

            op.RestoreDirectory = true;
            op.Filter           = "EXCEL(*.xls)|*.xls";
            bool?b = op.ShowDialog();

            if (b == false)
            {
                return;
            }

            DataTable dt = Data.ExcelHelper.ReadExcelToTable(op.FileName);

            list = new List <KSJS_Model>();
            foreach (DataRow dr in dt.Rows)
            {
                KSJS_Model model = new KSJS_Model();
                model.JH = dr[2].ToString();
                model.BJ = Convert.ToDouble(dr[3]);
                list.Add(model);
            }

            this.DataGrid1.ItemsSource = list;
        }