Ejemplo n.º 1
0
        protected override void OnPrimaryKeyChangedAsync()
        {
            AccessHelper access = new AccessHelper();
            List<School> schools = access.Select<School>(string.Format("uid='{0}'", PrimaryKey));

            if (schools.Count > 0)
                SchoolData = schools[0];
            else
                SchoolData = null;
        }
Ejemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         School s = new School();
         s.Title = txtTitle.Text;
         s.DSNS = txtDSNS.Text;
         s.Group = cboGroup.Text;
         s.Save();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
         DialogResult = DialogResult.None;
     }
 }
Ejemplo n.º 3
0
        private void ReadSchoolRecordFromExcel(string fileName, Dictionary<string, School> schools)
        {
            try
            {
                Dictionary<string, int> column_map = new Dictionary<string, int>(StringComparer.CurrentCultureIgnoreCase);

                Workbook book = new Workbook();
                book.Open(fileName, FileFormatType.Excel2007Xlsx);
                Worksheet sheet = book.Worksheets[0];
                ReadColumnName(column_map, sheet);

                for (int i = 1; i <= sheet.Cells.MaxDataRow; i++)
                {
                    string name = sheet.Cells[i, column_map["Name".ToLower()]].StringValue;

                    School school = new School();

                    if (schools.ContainsKey(name))
                        school = schools[name];
                    else
                        schools.Add(name, school);

                    school.DSNS = sheet.Cells[i, column_map["Name".ToLower()]].StringValue;
                    school.Title = sheet.Cells[i, column_map["Title".ToLower()]].StringValue;

                    if (column_map.ContainsKey("Group"))
                        school.Group = sheet.Cells[i, column_map["Group".ToLower()]].StringValue;

                    if (column_map.ContainsKey("Memo"))
                        school.Comment = sheet.Cells[i, column_map["Memo".ToLower()]].StringValue;
                }
            }
            catch (Exception ex)
            {
                ErrorBox.Show("讀取 Excel 錯誤!", ex);
            }
        }
Ejemplo n.º 4
0
        protected override void OnPrimaryKeyChangedAsync()
        {
            AccessHelper access = new AccessHelper();
            List<School> schools = access.Select<School>(string.Format("uid='{0}'", PrimaryKey));

            if (schools.Count > 0)
                SchoolData = schools[0];
            else
                throw new Exception("查不到學校資料:" + PrimaryKey);

            HashSet<string> tables = GetTables();

            //            Chart mc = new Chart();
            //            mc.ChartArea.AxisY2.IsMajorGridVisible = false;
            //            mc.ChartArea.AxisY.IsMajorGridVisible = false;
            //            mc.ChartArea.AxisX.IsMajorGridVisible = false;
            //            mc.ChartArea.AxisX2.IsMajorGridVisible = false;
            //            mc.ChartArea.AxisX.DefaultLabel.Format = "dd";
            //            mc.ChartArea.AxisY2.AxisLabels.IsDataPointNameVisible = false;

            //            Series serCount = new Series() { ChartType = ChartType.Line };
            //            serCount.Name = "取樣數";
            //            serCount.DefaultDataPoint.IsLabelVisible = true;
            //            serCount.IsPrimaryAxisY = false;

            //            Series serTraffic = new Series() { ChartType = ChartType.Bar };
            //            serTraffic.Name = "流量(MB)";
            //            serTraffic.IsPrimaryAxisY = true;

            //            List<DateTime> times = new List<DateTime>();
            //            for (int i = 8; i >= 0; i--)
            //            {
            //                times.Add(DateTime.Now.AddDays(-i));
            //            }

            //            foreach (DateTime dt in times)
            //            {
            //                string tableName = string.Format("log_client_{0:0000}_{1:00}_{2:00}", dt.Year, dt.Month, dt.Day);

            //                if (!tables.Contains(tableName))
            //                    continue;

            //                string cmd = @"select count(*) count,sum(bts+btr) traffic,trunc(stddev(spend)) spend,trunc(stddev(server_spend)) sspend,trunc(stddev(spend-server_spend)) network_spend
            //                from {0}
            //                where app in ('{1}')
            //                group by app";

            //                cmd = string.Format(cmd, tableName, SchoolData.DSNS);

            //                XElement records = Query(cmd);
            //                foreach (XElement record in records.Elements("Record"))
            //                {
            //                    int count = record.ElementInt("count", -1);
            //                    int totalSpend = record.ElementInt("spend", -1);
            //                    int serverSpend = record.ElementInt("sspend", -1);
            //                    int networkSpend = record.ElementInt("network_spend", -1);
            //                    int traffic = record.ElementInt("traffic", -1);

            //                    serTraffic.DataPoints.Add(new DataPoint(dt, traffic / 1024 / 1024));
            //                    serCount.DataPoints.Add(new DataPoint(dt, count));
            //                }
            //            }
            //            mc.SeriesCollection.Add(serTraffic);
            //            mc.SeriesCollection.Add(serCount);

            //            //Series s0 = new Series();
            //            //s0.IsPrimaryAxisY = true;
            //            ////mc.ChartArea.AxisY.DefaultLabel.Color = s0.DefaultDataPoint.Color = s0.DefaultDataPoint.BorderColor = Color.Green;
            //            //s0.ChartType = ChartType.Line;
            //            //for (int i = 1; i < 8; i++)
            //            //    s0.DataPoints.Add(new DataPoint(i, i * i));
            //            //mc.SeriesCollection.Add(s0);

            //            //Series s1 = new Series();
            //            //s1.IsPrimaryAxisY = false;
            //            ////mc.ChartArea.AxisY2.DefaultLabel.Color = s1.DefaultDataPoint.Color = Color.Blue;
            //            //s1.ChartType = ChartType.Bar;
            //            //for (int i = 1; i < 8; i++)
            //            //    s1.DataPoints.Add(new DataPoint(i, i * i * i));
            //            //mc.SeriesCollection.Add(s1);

            //            MainChart = mc;
        }
Ejemplo n.º 5
0
        private void frmSpecial_Load(object sender, EventArgs e)
        {
            AccessHelper helper = new AccessHelper();

            List<School> Schools = helper.Select<School>();

            School vSchool = new School();

            vSchool.DSNS = "dev.jh_kh";
            vSchool.Title = "高雄測試國中(內部)";

            Schools.Add(vSchool);

            cmbSchool.DataSource = Schools;
            cmbSchool.DisplayMember = "Title";
            cmbSchool.ValueMember = "DSNS";
        }
Ejemplo n.º 6
0
        protected override void OnPrimaryKeyChangedAsync()
        {
            AccessHelper  access  = new AccessHelper();
            List <School> schools = access.Select <School>(string.Format("uid='{0}'", PrimaryKey));

            if (schools.Count > 0)
            {
                SchoolData = schools[0];
            }
            else
            {
                throw new Exception("查不到學校資料:" + PrimaryKey);
            }

            HashSet <string> tables = GetTables();

//            Chart mc = new Chart();
//            mc.ChartArea.AxisY2.IsMajorGridVisible = false;
//            mc.ChartArea.AxisY.IsMajorGridVisible = false;
//            mc.ChartArea.AxisX.IsMajorGridVisible = false;
//            mc.ChartArea.AxisX2.IsMajorGridVisible = false;
//            mc.ChartArea.AxisX.DefaultLabel.Format = "dd";
//            mc.ChartArea.AxisY2.AxisLabels.IsDataPointNameVisible = false;

//            Series serCount = new Series() { ChartType = ChartType.Line };
//            serCount.Name = "取樣數";
//            serCount.DefaultDataPoint.IsLabelVisible = true;
//            serCount.IsPrimaryAxisY = false;

//            Series serTraffic = new Series() { ChartType = ChartType.Bar };
//            serTraffic.Name = "流量(MB)";
//            serTraffic.IsPrimaryAxisY = true;

//            List<DateTime> times = new List<DateTime>();
//            for (int i = 8; i >= 0; i--)
//            {
//                times.Add(DateTime.Now.AddDays(-i));
//            }

//            foreach (DateTime dt in times)
//            {
//                string tableName = string.Format("log_client_{0:0000}_{1:00}_{2:00}", dt.Year, dt.Month, dt.Day);

//                if (!tables.Contains(tableName))
//                    continue;

//                string cmd = @"select count(*) count,sum(bts+btr) traffic,trunc(stddev(spend)) spend,trunc(stddev(server_spend)) sspend,trunc(stddev(spend-server_spend)) network_spend
//                from {0}
//                where app in ('{1}')
//                group by app";

//                cmd = string.Format(cmd, tableName, SchoolData.DSNS);

//                XElement records = Query(cmd);
//                foreach (XElement record in records.Elements("Record"))
//                {
//                    int count = record.ElementInt("count", -1);
//                    int totalSpend = record.ElementInt("spend", -1);
//                    int serverSpend = record.ElementInt("sspend", -1);
//                    int networkSpend = record.ElementInt("network_spend", -1);
//                    int traffic = record.ElementInt("traffic", -1);

//                    serTraffic.DataPoints.Add(new DataPoint(dt, traffic / 1024 / 1024));
//                    serCount.DataPoints.Add(new DataPoint(dt, count));
//                }
//            }
//            mc.SeriesCollection.Add(serTraffic);
//            mc.SeriesCollection.Add(serCount);

//            //Series s0 = new Series();
//            //s0.IsPrimaryAxisY = true;
//            ////mc.ChartArea.AxisY.DefaultLabel.Color = s0.DefaultDataPoint.Color = s0.DefaultDataPoint.BorderColor = Color.Green;
//            //s0.ChartType = ChartType.Line;
//            //for (int i = 1; i < 8; i++)
//            //    s0.DataPoints.Add(new DataPoint(i, i * i));
//            //mc.SeriesCollection.Add(s0);

//            //Series s1 = new Series();
//            //s1.IsPrimaryAxisY = false;
//            ////mc.ChartArea.AxisY2.DefaultLabel.Color = s1.DefaultDataPoint.Color = Color.Blue;
//            //s1.ChartType = ChartType.Bar;
//            //for (int i = 1; i < 8; i++)
//            //    s1.DataPoints.Add(new DataPoint(i, i * i * i));
//            //mc.SeriesCollection.Add(s1);

//            MainChart = mc;
        }