Пример #1
0
        //用户注册输入编号时动态检验该编号是否可用
        private void RGnumber_KeyUp(object sender, KeyEventArgs e)
        {
            DBlink db = new DBlink();   //创建数据库连接对象

            if (db.DBconn())
            { //连接数据库
                string str = "select * from login_info where number='" + RGnumber.Text + "'";
                if (db.search(str))
                {
                    label11.Text = "*该编号不可用";
                }
                else
                {
                    label11.Text = "*编号可以使用";
                }
            }
            db.DBclose();//关闭数据连接
        }
        private void Frm_Child_Load(object sender, EventArgs e)
        {
            DBlink db = new DBlink();

            if (db.DBcon())             //填充Pname 数组
            {
                db.Get_guzhang_route(); //得到故障线路
            }
            db.DBclose();
            route_comboBox1.Items.Clear();//需要修改
            int i;

            for (i = 0; i < guzhang.rn.Count; i++)
            {
                route_comboBox1.Items.Add(guzhang.rn[i].ToString());//添加线路名
            }
            this.WindowState = FormWindowState.Maximized;
        }
Пример #3
0
        //当用户输入用户名完成时验证用户名是否可以注册
        private void RGname_Leave(object sender, EventArgs e)
        {
            DBlink db = new DBlink();   //创建数据库连接对象

            if (db.DBconn())            //创建数据库连接
            {
                string str = "select * from login_info where SF='" + quanju.sf + "'and username='******'";
                if (db.GetLoginData(str))//执行sql检测该用户是否已经被注册
                {
                    label9.Text = "该用户已经存在!";
                }
                else
                {
                    label9.Text = "恭喜,可以注册!";
                }
            }
            db.DBclose();   //关闭数据库连接
        }
        private void RbtnSelectedcheckBox1_CheckedChanged(object sender, EventArgs e)
        {
            // 添加线路
            DBlink db = new DBlink();

            if (db.DBcon())             //填充Pname 数组
            {
                db.Get_guzhang_route(); //得到故障线路
            }
            db.DBclose();
            route_comboBox1.Items.Clear();//需要修改
            int i;

            for (i = 0; i < guzhang.rn.Count; i++)
            {
                route_comboBox1.Items.Add(guzhang.rn[i].ToString());//添加线路名
            }
        }
        private void Route_comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            rn = route_comboBox1.Text;
            //添加年份
            DBlink db1 = new DBlink();

            if (db1.DBcon())     //填充Pname 数组
            {
                db1.GetYear(rn); //得到故障线路
            }
            db1.DBclose();
            year_comboBox1.Items.Clear();//

            for (int j = 0; j < guzhang.year.Count; j++)
            {
                year_comboBox1.Items.Add(guzhang.year[j].ToString());
            }
        }
Пример #6
0
        private void textBox3_Leave(object sender, EventArgs e)
        {
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            { //连接数据库
                string Str1  = "select count(*) from course_information where Id = " + textBox3.Text;
                string count = db3.Getstringsearch(Str1);
                if (count.Equals("0"))
                {
                    MessageBox.Show("该老师不存在,请重新输入");
                }
                else
                {
                    bool2 = true;
                }
            }
            db3.DBclose();//关闭数据连接
        }
        private void Barchart_Click(object sender, EventArgs e) //选择全部线路
        {
            route_comboBox1.Enabled = false;                    //选择框不可选
            single_or_all           = true;                     //当选择全部线路时,single_or_all为true

            //添加年份
            DBlink db1 = new DBlink();

            if (db1.DBcon())   //填充Pname 数组
            {
                db1.GetYear(); //得到故障线路
            }
            db1.DBclose();
            year_comboBox1.Items.Clear();//

            for (int j = 0; j < guzhang.year.Count; j++)
            {
                year_comboBox1.Items.Add(guzhang.year[j].ToString());
            }
        }
Пример #8
0
        private void textBox1_Leave(object sender, EventArgs e)
        {
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            { //连接数据库
                string Str1  = "select count(*) from course_information where Course_Id = " + textBox1.Text;
                string count = db3.Getstringsearch(Str1);
                if (count.Equals("1"))
                {
                    MessageBox.Show("该课程信息已经录入,请移步信息维护界面");
                    this.Close();
                }
                else
                {
                    bool1 = true;
                }
            }
            db3.DBclose();//关闭数据连接
        }
        //加载页面,通过用户名得到用户名的Id
        private void User_info_display_Load(object sender, EventArgs e)
        {
            panel1.Visible = false;//默认不可以看其他用户信息
            // 设置日历控件选择时间范围,生日不得超过今天
            dateTimePicker1.MinDate = new DateTime(1990, 1, 1);
            dateTimePicker1.MaxDate = DateTime.Today;
            if (Globel.id_tag.Equals("ts"))
            {
                panel1.Visible = true;//如果是教学秘书可以查看其他人的信息
            }
            else
            {
            }
            DBlink db = new DBlink();   //创建数据库连接对象

            if (db.DBconn())
            {          //创建数据库连接
                string Str1 = "select Id from login_info WHERE username = '******'";
                Globel.Id = db.Getstringsearch(Str1);
                string Str2 = "select name from user_information WHERE Id = '" + Globel.Id + "'";
                if (db.Getstringsearch(Str2).Equals(""))
                {
                    MessageBox.Show("您的个人信息还未录入,请先录入");
                    this.Close();
                }
                else
                {
                    string Str3 = "Select Count(*) from user_information";
                    MaxValue = db.GetIntsearch(Str3);
                    string Str4   = "select number from user_information WHERE Id = " + Globel.Id;
                    int    number = db.GetIntsearch(Str4);
                    string Str5   = "SELECT count(*) FROM user_information WHERE number <=" + number;
                    sta = db.GetIntsearch(Str5);
                    showInfo(sta - 1);
                }
            }
            db.DBclose();   //关闭数据库连接
        }
Пример #10
0
        //确定
        private void button3_Click(object sender, EventArgs e)
        {
            DBlink db = new DBlink();   //创建数据库连接对象

            if (db.DBconn())
            { //连接数据库
                string str1 = "insert into course_information(Course_Id,course_name,course_type,Obligatory,credit,Theoretical_hours,Experimental_hours,id) " +
                              "values('" + course_info.course_id + "','" + course_info.course_name + "','" + course_info.course_type + "','" + course_info.Obligatory + "','"
                              + course_info.credit + "','" + course_info.Theoretical_hours + "','"
                              + course_info.Experimental_hours + "','" + course_info.id + "');";
                string info = "提交成功!";
                if (db.UpdataDeletAdd(str1))
                {
                    DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question);
                    if (dr == DialogResult.OK)
                    {
                        this.Visible = false;//隐藏当前窗口
                    }
                }
            }

            db.DBclose();//关闭数据连接
        }
Пример #11
0
        private void button3_Click(object sender, EventArgs e)
        {
            ScoreInfo.id        = textBox1.Text;
            ScoreInfo.course_id = textBox2.Text;
            string delsql = "delete from score_info where Id= '" + ScoreInfo.id + "'and Course_Id = '" + ScoreInfo.course_id + "'";
            //delete from user_information where Id= 266;
            DBlink db4 = new DBlink();   //创建数据库连接对象

            if (db4.DBconn())
            { //连接数据库
                if (db4.UpdataDeletAdd(delsql))
                {
                    MessageBox.Show("删除记录成功!");
                    this.Close();
                }
                else
                {
                    MessageBox.Show("删除失败!");
                    this.Close();
                }
            }
            db4.DBclose();//关闭数据连接
        }
Пример #12
0
        //验证用户登录
        private void DoLogin_Click(object sender, EventArgs e)
        {
            DBlink db = new DBlink();                              //创建数据库连接对象

            Identification.identification(identity.SelectedIndex); //根据用户选择的值判断用户身份
            if (db.DBconn())
            {
                //数据库连接成功
                if (db.GetLoginData("select * from login_info where id_tag='" + Globel.id_tag + "'and username='******'"))
                {
                    //用户存在
                    if (int.Parse(LoginInfo.tag) == 1)             //账号已被审核允许登录
                    {
                        if (Tpass.Text.Equals(LoginInfo.password)) //登录成功
                        {
                            Globel.username = Tusername.Text;
                            new MainMenu().ShowDialog();//显示主菜单界面
                            this.Hide();
                            this.Visible = false;
                        }
                        else    //密码错误
                        {
                            label6.Text = "密码错误!";
                        }
                    }
                    else    //账号未审核
                    {
                        label6.Text = "该账号未审核,请联系管理员";
                    }
                }
                else
                {
                    label6.Text = "登录失败,用户名不存在!";
                }
            }
            db.DBclose();//关闭数据库连接
        }
Пример #13
0
        private void button7_Click_1(object sender, EventArgs e)
        {
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            {                                               //连接数据库
                string Str1    = "select COUNT(*) from course_information WHERE Course_Id = " + textBox4.Text;
                string count   = db3.Getstringsearch(Str1); // 执行查询
                string Str2    = "select number from course_information WHERE Course_Id = " + textBox4.Text;
                int    counter = db3.GetIntsearch(Str2);
                if (count.Equals("0"))
                {
                    MessageBox.Show("抱歉未查询到该课程信息");
                    this.Close();
                }
                else if (count.Equals("1"))
                {
                    string Str4 = "SELECT count(*) FROM course_information WHERE number <= " + counter;
                    sta = db3.GetIntsearch(Str4);
                    showInfo(sta - 1);
                }
            }
            db3.DBclose();//关闭数据连接
        }
        //更新按钮
        private void button1_Click(object sender, EventArgs e)
        {
            User_info.name = textBox2.Text;
            if (radioButton1.Checked)
            {
                User_info.sex = radioButton1.Text;
            }
            else
            {
                User_info.sex = radioButton2.Text;
            }
            User_info.birth      = dateTimePicker1.Value.Date.ToLongDateString();
            User_info.College_Id = comboBox1.SelectedItem.ToString();
            User_info.Speciality = textBox3.Text;
            User_info.Hobby      = "";
            if (checkBox1.Checked)
            {
                User_info.Hobby += checkBox1.Text;
            }
            if (checkBox2.Checked)
            {
                User_info.Hobby += "、" + checkBox2.Text;
            }
            if (checkBox3.Checked)
            {
                User_info.Hobby += "、" + checkBox3.Text;
            }
            if (checkBox4.Checked)
            {
                User_info.Hobby += "、" + checkBox4.Text;
            }
            if (checkBox5.Checked)
            {
                User_info.Hobby += "、" + checkBox5.Text;
            }
            if (checkBox6.Checked)
            {
                User_info.Hobby += "、" + checkBox6.Text;
            }
            User_info.Political_Outlook = comboBox2.SelectedItem.ToString();
            User_info.qualifications    = comboBox3.SelectedItem.ToString();
            User_info.id_tag            = Globel.id_tag;

            string uptsql;

            uptsql = "update user_information set name='" + User_info.name + "', sex='" + User_info.sex + "', birth='" + User_info.birth + "', College_Id='" + User_info.College_Id +
                     "', Speciality='" + User_info.Speciality + "', Hobby='" + User_info.Hobby + "', Political_Outlook ='" + User_info.Political_Outlook +
                     "', qualifications='" + User_info.qualifications + "'where Id=" + Globel.Id;
            DBlink db3 = new DBlink();   //创建数据库连接对象

            if (db3.DBconn())
            { //连接数据库
                string Str1 = "select Id from login_info WHERE username = '******'";
                Globel.Id = db3.Getstringsearch(Str1);
                string Str2 = "select name from user_information WHERE Id = '" + Globel.Id + "'";
                if (!db3.Getstringsearch(Str2).Equals(textBox2.Text))
                {
                    MessageBox.Show("您不能修改其他用户信息");
                    this.Close();
                }
                else
                {
                    if (db3.UpdataDeletAdd(uptsql))
                    {
                        MessageBox.Show("用户信息更新成功", "更新成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    else
                    {
                        MessageBox.Show("未更新,请检查!", "无更新", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            db3.DBclose();//关闭数据连接
            //showInfo(state);
        }
Пример #15
0
        //提交用户信息
        private void button1_Click(object sender, EventArgs e)
        {
            //格式化用户所提交之信息
            User_info.id   = textBox1.Text;
            Globel.Id      = User_info.id;
            User_info.name = Textname.Text;
            if (radioButton1.Checked)
            {
                User_info.sex = radioButton1.Text;
            }
            else
            {
                User_info.sex = radioButton2.Text;
            }
            User_info.birth = dateTimePicker1.Value.Date.ToLongDateString();
            //MessageBox.Show(DateTime.Now.ToShortDateString().ToString());
            User_info.College_Id = chooseCollege.SelectedItem.ToString();
            User_info.Speciality = textBox2.Text;
            User_info.Hobby      = "";
            if (checkBox1.Checked)
            {
                User_info.Hobby += checkBox1.Text;
            }
            if (checkBox2.Checked)
            {
                User_info.Hobby += "、" + checkBox2.Text;
            }
            if (checkBox3.Checked)
            {
                User_info.Hobby += "、" + checkBox3.Text;
            }
            if (checkBox4.Checked)
            {
                User_info.Hobby += "、" + checkBox4.Text;
            }
            if (checkBox5.Checked)
            {
                User_info.Hobby += "、" + checkBox5.Text;
            }
            if (checkBox6.Checked)
            {
                User_info.Hobby += "、" + checkBox6.Text;
            }
            User_info.Political_Outlook = comboBox2.SelectedItem.ToString();
            User_info.qualifications    = comboBox3.SelectedItem.ToString();
            User_info.id_tag            = Globel.id_tag;
            //满足条件才能提交信息
            if (bool1 == true)
            {
                DBlink db = new DBlink(); //创建数据库连接对象
                if (db.DBconn())
                {                         //连接数据库
                    string str1 = "insert into user_information(Id,name,sex,birth,College_Id,Speciality,Hobby,Political_Outlook,qualifications,id_tag) " +
                                  "values('" + User_info.id + "','" + User_info.name + "','" + User_info.sex + "','" + User_info.birth + "','" + User_info.College_Id + "','" + User_info.Speciality + "','"
                                  + User_info.Hobby + "','" + User_info.Political_Outlook + "','" + User_info.qualifications + "','" + User_info.id_tag + "');";
                    string info = "提交成功!";

                    if (db.UpdataDeletAdd(str1))
                    {
                        DialogResult dr = MessageBox.Show(info, "标题", MessageBoxButtons.OK, MessageBoxIcon.Question);
                        if (dr == DialogResult.OK)
                        {
                            this.Visible = false;//隐藏当前窗口
                        }
                    }
                }

                db.DBclose();//关闭数据连接
            }
            else
            {
                MessageBox.Show("您的学号输入错误,请核对");
            }
        }
        private DataTable Create_DataTable()//11-9-2125选择全部线路柱状图
        {
            //创建一个dataTable chart 的数据源
            DataTable dt1 = new DataTable();

            dt1.Columns.Add("日期");//添加5列数据
            dt1.Columns.Add("断裂");
            dt1.Columns.Add("拉伸");
            dt1.Columns.Add("进水");
            dt1.Columns.Add("异常");
            dt1.Columns.Add("其他");            //添加5列
            double[] month = new double[100]; //月份
            double[] date1 = new double[100];
            string[] type  = new string[100];

            double  resultmonth = 0;
            DataRow dr;

            //添加行数据
            //连接数据库
            DBlink db = new DBlink();

            if (db.DBcon())
            {
                db.Getmonth_guzhang(year);//输入线路名得到故障日期和类型
            }
            db.DBclose();
            for (int i = 0; i < guzhang.date.Count; i++)
            {
                date1[i] = guzhang.date[i];                    //获得月份
                type[i]  = guzhang.guzhang_type[i].ToString(); //获得对应的故障类型
            }

            DBlink db1 = new DBlink();

            if (db1.DBcon())
            {
                db1.Getmonth(year);//输入线路名得到故障日期月份
            }
            db1.DBclose();
            for (int i = 0; i < guzhang.date.Count; i++)
            {
                month[i] = guzhang.date[i];//7 8 9 10 11
            }
            double[] num = new double[] { 0, 0, 0, 0, 0 };

            for (int k = 0; k < month.Length; k++)     //已有月份month[0,1,2]=8,9,10
            {
                for (int i = 0; i < date1.Length; i++) //与实际对比
                {
                    if (month[k] == date1[i])          //比如date1[0]==month[0]=8
                    {
                        resultmonth = month[k];
                        string type1 = type[i]; //type[0]=断裂
                        switch (type1)          //某一月份的故障类型统计
                        {
                        case "断裂":              //断裂
                            num[0]++;
                            break;

                        case "拉伸":
                            num[1]++;
                            break;

                        case "接头盒进水":
                            num[2]++;
                            break;

                        case "异常":
                            num[3]++;
                            break;

                        case "其他":
                            num[4]++;
                            break;
                        }
                    }
                }

                dr       = dt1.NewRow();
                dr["日期"] = month[k] + "月"; //8,9,10月}
                dr["断裂"] = num[0];
                dr["拉伸"] = num[1];
                dr["进水"] = num[2];
                dr["异常"] = num[3];
                dr["其他"] = num[4];
                dt1.Rows.Add(dr);
                for (int i = 0; i < 5; i++)
                {
                    num[i] = 0;
                }
            }

            return(dt1);
        }
        private void Btn_beixian_Click(object sender, EventArgs e)
        {
            chart1.Visible = true;
            label3.Visible = true;
            try
            {
                chart1.Series.Clear();          //每次输入之后清空
                Series ser = new Series(rn);    // 实例化序列图对象
                ser.IsValueShownAsLabel = true; //显示每个节点信息

                chart1.Series.Add(ser);         //向chart1中添加序列对象

                #region 数据库连接操作,得到日期差值和光功率数值
                DBlink db1 = new DBlink();
                if (db1.DBcon())
                {
                    db1.Get_datediff(time2, time1); //输入线路名,得到对应的光功率和日期
                }
                db1.DBclose();
                DBlink db = new DBlink();
                if (db.DBcon())
                {
                    db.Get_Beixian(rn, time1, time2);//输入线路名,起止时间得到对应的光功率和日期
                }
                db.DBclose();
                #endregion
                rqcz = date.rqcz[0] + 1;              //得到选中的日期差值 比如10月20日与10月19
                for (int i = 0; i < rqcz; i++)        //统计日期的个数
                {
                    x[i] = (DateTime)date.dateset[i]; //日期
                    y[i] = date.beixian[i];           //将光功率赋给y轴
                    sum  = sum + y[i];
                }
                //预测部分 得到预测的光功率值
                for (int i = 0; i < rqcz; i++)//rqcz=7 x[0-6] x[7] y[7]预测
                {
                    ser.Points.AddXY(x[i], y[i]);
                }//向xy轴添加元素}
                avg = sum / rqcz;



                chart1.Series[0].ChartType = SeriesChartType.Spline; //第一条样条图类型
                                                                     //设置标题
                chart1.Titles[0].Text      = string.Format("{0}备线衰耗值显示", rn);
                chart1.Titles[0].ForeColor = Color.RoyalBlue;
                chart1.Titles[0].ForeColor = Color.RoyalBlue;
                if (avg > 3)
                {
                    MessageBox.Show("备纤状态异常,可能出现拉伸、弯曲,请检查备纤!");
                }
                else
                {
                    if (avg > 10)
                    {
                        MessageBox.Show("光缆已经断了,请前去排除故障!");
                    }
                    else
                    {
                        MessageBox.Show("光缆平均备纤衰耗值:" + avg);
                    }
                }
            }
            catch (System.Exception ex)
            { }
        }
        private void RbtnPie_CheckedChanged(object sender, EventArgs e) //
        {
            if (!single_or_all)                                         //绘制单条线路上的数据
            {
                guzhang_bar_chart.Visible = false;
                guzhang_pie_chart.Visible = true;
                double s = 0; //总
                              //List<String> xData = new List<String>();//故障类型就5种
                              //List<Double> yData = new List<Double>();
                double[] sum          = new double[5];
                double[] pro          = new double[5];
                string[] guzhang_Type = new string[] { "断裂", "拉伸", "接头盒进水", "异常", "其他" };
                double[] yData        = new double[5];//故障类型的数量5中

                DBlink db = new DBlink();
                if (db.DBcon())
                {
                    db.Gettype_count(rn, year);//输入线路名得到故障类型和数目
                }
                db.DBclose();

                for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                {
                    sum[i] = double.Parse(guzhang.count[i].ToString()); //得到故障数量
                                                                        //  guzhang_Type[i] = guzhang.guzhang_type[i].ToString();//
                                                                        //textBox1.Text= guzhang.guzhang_type[i].ToString();
                                                                        //guzhang_Type[i] =guzhangtype_comboBox1.Items[i].ToString();//此处不能赋值
                }
                guzhang.guzhang_type.CopyTo(guzhang_Type);
                for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                {
                    s += sum[i];
                }
                for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                {
                    pro[i] = sum[i] * (1 / s);

                    yData[i] = double.Parse(pro[i].ToString("0.00"));
                }
                guzhang_pie_chart.Series[0].Points.DataBindXY(guzhang_Type, yData);
                guzhang_pie_chart.Series[0]["PieLabelStyle"] = "Outside"; //将文字移到外侧
                guzhang_pie_chart.Series[0]["PieLineColor"]  = "Black";   //绘制黑色的连线。
            }
            if (single_or_all)                                            //绘制全部线路
            {
                guzhang_bar_chart.Visible = false;
                guzhang_pie_chart.Visible = true;
                double s = 0; //总
                              //List<String> xData = new List<String>();//故障类型就5种
                              //List<Double> yData = new List<Double>();
                double[] sum          = new double[5];
                double[] pro          = new double[5];
                string[] guzhang_Type = new string[5];
                double[] yData        = new double[5];//故障类型的数量5中

                DBlink db = new DBlink();
                if (db.DBcon())
                {
                    db.Gettype_count(year);//输入线路名得到故障类型和数目
                }
                db.DBclose();

                for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                {
                    sum[i] = double.Parse(guzhang.count[i].ToString()); //得到故障数量
                                                                        //  guzhang_Type[i] = guzhang.guzhang_type[i].ToString();//
                                                                        //textBox1.Text= guzhang.guzhang_type[i].ToString();
                                                                        //guzhang_Type[i] =guzhangtype_comboBox1.Items[i].ToString();//此处不能赋值
                }
                guzhang.guzhang_type.CopyTo(guzhang_Type);              //将 ArrayList中guzhang.guzhang_type复制到数组guzhang_Type

                for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                {
                    s += sum[i];
                }
                for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                {
                    pro[i] = sum[i] * (1 / s);

                    yData[i] = double.Parse(pro[i].ToString("0.00"));
                }
                guzhang_pie_chart.Series[0].Points.DataBindXY(guzhang_Type, yData);
            }
        }//用饼状图实现年份故障类型分析
        private void DataAnalysis_Click(object sender, EventArgs e)
        {
            if (!single_or_all)      //如果选择某条线路
            {
                if (rbtnBar.Checked) //当选择柱状图时
                {
                    DataTable dt1 = default(DataTable);
                    dt1 = Create_DataTable(rn); //返回值给dt1//调用
                                                //设置图表数据源
                    guzhang_bar_chart.DataSource = dt1;
                    //绑定数据
                    guzhang_bar_chart.DataBind();
                }

                if (rbtnPie.Checked)
                {
                    double s = 0; //总
                                  //List<String> xData = new List<String>();//故障类型就5种
                                  //List<Double> yData = new List<Double>();
                    double[] sum          = new double[5];
                    double[] pro          = new double[5];
                    string[] guzhang_Type = new string[5];
                    double[] yData        = new double[5];//故障类型的数量5中

                    DBlink db = new DBlink();
                    if (db.DBcon())
                    {
                        db.Gettype_count(rn, year);//输入线路名得到故障类型和数目
                    }
                    db.DBclose();

                    for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                    {
                        sum[i] = double.Parse(guzhang.count[i].ToString()); //得到故障数量
                                                                            //  guzhang_Type[i] = guzhang.guzhang_type[i].ToString();//
                                                                            //textBox1.Text= guzhang.guzhang_type[i].ToString();
                                                                            //guzhang_Type[i] =guzhangtype_comboBox1.Items[i].ToString();//此处不能赋值
                    }
                    guzhang.guzhang_type.CopyTo(guzhang_Type);
                    for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                    {
                        s += sum[i];
                    }
                    for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                    {
                        pro[i]   = sum[i] * (1 / s);
                        yData[i] = double.Parse(pro[i].ToString("0.00"));
                    }
                    guzhang_pie_chart.Series[0].Points.DataBindXY(guzhang_Type, yData);
                }
            }

            if (single_or_all)       //如果选择所有线路
            {
                if (rbtnBar.Checked) //当选择柱状图时
                {
                    DataTable dt1 = default(DataTable);
                    dt1 = Create_DataTable(); //返回值给dt2//调用
                                              //设置图表数据源
                    guzhang_bar_chart.DataSource = dt1;
                    //绑定数据
                    guzhang_bar_chart.DataBind();
                }

                if (rbtnPie.Checked)
                {
                    double s = 0; //总
                                  //List<String> xData = new List<String>();//故障类型就5种
                                  //List<Double> yData = new List<Double>();
                    double[] sum          = new double[5];
                    double[] pro          = new double[5];
                    string[] guzhang_Type = new string[5];
                    double[] yData        = new double[5];//故障类型的数量5中

                    DBlink db = new DBlink();
                    if (db.DBcon())
                    {
                        db.Gettype_count(year);//输入线路名得到故障类型和数目
                    }
                    db.DBclose();

                    for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                    {
                        sum[i] = double.Parse(guzhang.count[i].ToString()); //得到故障数量
                                                                            //  guzhang_Type[i] = guzhang.guzhang_type[i].ToString();//
                                                                            //textBox1.Text= guzhang.guzhang_type[i].ToString();
                                                                            //guzhang_Type[i] =guzhangtype_comboBox1.Items[i].ToString();//此处不能赋值
                    }
                    guzhang.guzhang_type.CopyTo(guzhang_Type);              //将 ArrayList中guzhang.guzhang_type复制到数组guzhang_Type

                    for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                    {
                        s += sum[i];
                    }
                    for (int i = 0; i < guzhang.guzhang_type.Count; i++)
                    {
                        double tmp = 1 / s;
                        pro[i]   = sum[i] * tmp;
                        yData[i] = double.Parse(pro[i].ToString("0.00"));
                    }
                    guzhang_pie_chart.Series[0].Points.DataBindXY(guzhang_Type, yData);
                }
            }
        }