예제 #1
0
        public static void Parse_All_Data_Grid(SQL_Connect_Builder builder)
        {
            DataTable dt = builder.Select_Table("AllDataGrid");

            foreach (DataRow dr in dt.Rows)
            {
                string name = dr[0].ToString();

                string table_type = dr[1].ToString();
                if (table_type == "OrderTable")
                {
                    // 这个地方数量不对
                    CreateSqlValueType[] create_sql_value_type = new CreateSqlValueType[1 + (dr.ItemArray.Length - 2) / 2];
                    create_sql_value_type[0] = new CreateSqlValueType("integer", "MyOrder", true);
                    for (int i = 0; i < (dr.ItemArray.Length - 12) / 2; i++)
                    {
                        if (dr[12 + i * 2].ToString() == "" || dr[12 + i * 2 + 1].ToString() == "")
                        {
                            break;
                        }
                        create_sql_value_type[1 + i] = new CreateSqlValueType(dr[12 + i * 2 + 1].ToString(), dr[12 + i * 2].ToString());
                    }
                    builder.Create_Table(name, create_sql_value_type);
                }
            }
        }
예제 #2
0
        // 读取所有的副窗体
        public static void Read_All_SubWindow(SQL_Connect_Builder sql_builder, ArrayList window_arraylist, Running_Data data)
        {
            string    where_cmd = "WindowName <> 'MainWindow'";
            DataTable dt        = sql_builder.Select_Table("ALLWindow", where_cmd);

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        SubWindow subwindow = new SubWindow(data);
                        subwindow.Name = dr[0].ToString();
                        Parse_SubWindow(subwindow, sql_builder, subwindow.MainGrid, data);
                        window_arraylist.Add(subwindow);
                    }
                }
            }
        }
예제 #3
0
 private void button_ok_Click(object sender, EventArgs e)
 {
     // admin进入
     if (textBox_username.Text == "admin" && textBox_password.Text == "admin")
     {
         username = textBox_username.Text;
         passion  = "管理员";
         this.Hide();
         MainView mv = new MainView();
         mv.Show();
     }
     else
     {
         string    myusername = textBox_username.Text.Trim();
         string    password   = textBox_password.Text.Trim();
         string    where_cmd  = "userID='" + myusername + "'";
         DataTable dt         = builder.Select_Table("usertable", where_cmd);
         if (dt != null)
         {
             if (dt.Rows.Count == 0)
             {
                 MessageBox.Show("用户名或密码错误!");
             }
             if (dt.Rows.Count > 0)
             {
                 username = dt.Rows[0][0].ToString();
                 passion  = dt.Rows[0][2].ToString();
                 this.Hide();
                 MainView mv = new MainView();
                 mv.Show();
                 if (passion == "用户")
                 {
                     mv.kehu_Show();
                 }
             }
         }
         else
         {
             MessageBox.Show("用户名或密码错误!");
         }
     }
 }
예제 #4
0
        public static void Parse_All_Table_Struct(SQL_Connect_Builder builder)
        {
            DataTable dt = builder.Select_Table("TableStruct");

            if (dt != null)
            {
                if (dt.Rows.Count > 0)
                {
                    int colcount = dt.Columns.Count;
                    foreach (DataRow dr in dt.Rows)
                    {
                        int value_count = 0;
                        for (int i = 0; i < colcount; i++)
                        {
                            if (dr[i].ToString() != "")
                            {
                                value_count++;
                            }
                            else
                            {
                                break;
                            }
                        }
                        int table_col_count = (value_count - 1) / 2;
                        CreateSqlValueType[] createsqlvaluetype = new CreateSqlValueType[table_col_count];
                        for (int j = 0; j < table_col_count; j++)
                        {
                            if (j == 0)
                            {
                                createsqlvaluetype[j] = new CreateSqlValueType(dr[2 + j * 2].ToString(), dr[1 + j * 2].ToString(), true);
                            }
                            else
                            {
                                createsqlvaluetype[j] = new CreateSqlValueType(dr[2 + j * 2].ToString(), dr[1 + j * 2].ToString());
                            }
                        }
                        builder.Create_Table(dr[0].ToString(), createsqlvaluetype);
                    }
                }
            }
        }
예제 #5
0
        CreateSqlValueType[] runtime_create_sql_value_type = new CreateSqlValueType[4];                      // 保存实时数据的表结构

        public MainWindow()
        {
            InitializeComponent();
            // 解析主界面
            // 解析所有的Grid
            this.Left   = 0;
            this.Top    = 0;
            this.Width  = ViewCaoZuo.width;
            this.Height = ViewCaoZuo.height;
            this.Name   = "MainWindow";
            DataTable dt = database_builder.Select_Table("Station_Info");

            running_data = new Running_Data(dt);

            // 解析所有表

            DataPrase.Parse_All_Table_Struct(database_builder);


            DataPrase.Parse_All_Data_Grid(database_builder);

            WPFDataStruct.WindowParsing.ParseWindow(this, database_builder, MainGrid);

            WPFDataStruct.WindowParsing.Read_All_SubWindow(database_builder, AllSubWindow, running_data);

            Add_Event();
            // 读取所有的窗体

            Read_All_Value();
            Read_All_RunTime_Table();
            Read_All_Station();

            // 初始化建立实时历史数据库的命令
            runtime_create_sql_value_type[0] = new CreateSqlValueType("nvarchar(50)", "TimeAndName", true);
            runtime_create_sql_value_type[1] = new CreateSqlValueType("nvarchar(50)", "Value_Name");
            runtime_create_sql_value_type[2] = new CreateSqlValueType("DateTime", "Time");
            runtime_create_sql_value_type[3] = new CreateSqlValueType("nvarchar(50)", "Value");
            // 初始化时钟
            savetimer.Interval = 10000;
            savetimer.Elapsed += new System.Timers.ElapsedEventHandler(Save_RunTimeValue_Tick);
            savetimer.Enabled  = true;


            //解析所有的保存数据
        }
예제 #6
0
        private void Draw(object sender, System.Timers.ElapsedEventArgs e)
        {
            // 绘制
            // new Action(() => { label.Content = " " + result1 + " "; })); continue;
            subgrid.Dispatcher.BeginInvoke(new Action(() =>
            {
                subgrid.Children.Clear();                        // 去掉所有的元素

                if (mydr == null || mybuilder == null)
                {
                    return;
                }
                // 画标记位置的虚线
                #region
                DoubleCollection dc = new DoubleCollection();
                dc.Add(2);
                dc.Add(2);
                for (int i = 0; i < timelabelcount; i++)
                {
                    // 画竖起的虚线
                    Line newline = new Line();
                    newline.X1   = (subgrid.Width / (timelabelcount - 1)) * i;
                    newline.X2   = (subgrid.Width / (timelabelcount - 1)) * i;
                    if (newline.X1 < 0 || newline.X1 > subgrid.Width)
                    {
                        continue;
                    }
                    newline.Y1 = 0;
                    newline.Y2 = subgrid.Height;
                    newline.StrokeDashArray = dc;
                    newline.Stroke          = System.Windows.Media.Brushes.Black;
                    newline.StrokeThickness = 1;
                    subgrid.Children.Add(newline);
                }

                for (int i = 0; i < label_count; i++)
                {
                    Line newline            = new Line();
                    newline.X1              = 0;
                    newline.X2              = subgrid.Width;
                    newline.Y1              = subgrid.Height - (subgrid.Height / (label_count - 1)) * i;
                    newline.Y2              = subgrid.Height - (subgrid.Height / (label_count - 1)) * i;
                    newline.StrokeDashArray = dc;
                    newline.Stroke          = System.Windows.Media.Brushes.Black;
                    newline.StrokeThickness = 1;
                    subgrid.Children.Add(newline);
                }
                #endregion

                // 读取相应时间段内的数据库表
                DateTime temp_start_time = starttime;
                DateTime endtime         = starttime.AddMinutes(timespan);

                while (endtime.Year != temp_start_time.Year || endtime.Month != temp_start_time.Month || endtime.Day != temp_start_time.Day)
                {
                    // 日期不同,说明跨了日期

                    string table_name = "runtimetable" + temp_start_time.ToString("yyyyMMdd");

                    DataTable dt = null;

                    bool exits = false;                                                             // 在内存中是否存在这样的一个表
                    foreach (object mydatatable in All_Used_Running_Table)
                    {
                        DataTable mydt = (DataTable)mydatatable;
                        if (mydt.TableName == table_name)
                        {
                            dt    = mydt;
                            exits = true;
                            break;
                        }
                    }
                    if (exits == false)
                    {
                        dt           = mybuilder.Select_Table(table_name, "Time>'" + temp_start_time.ToString("yyyy-MM-dd HH:mm:ss") + "'");
                        dt.TableName = table_name;
                        All_Used_Running_Table.Add(dt);
                    }

                    if (dt == null)
                    {
                        return;
                    }
                    if (dt.Rows.Count == 0)
                    {
                        return;
                    }
                    dt.Columns[1].ColumnName = "Value_Name";

                    // 绘图 共可以绘制10条图案
                    foreach (object lineobject in allline)
                    {
                        myline_Struct line_struct = (myline_Struct)lineobject;
                        string linename           = line_struct.LineName;
                        string color       = line_struct.LineColor;           // 颜色
                        DataRow[] linerows = null;
                        try
                        {
                            linerows = dt.Select("Value_Name='" + linename + "'");
                        }
                        catch { return; }
                        if (linerows == null)
                        {
                            return;
                        }
                        for (int i = 0; i < linerows.Length - 1; i++)
                        {
                            double value        = double.Parse(linerows[i][3].ToString());
                            DateTime value_time = DateTime.Parse(linerows[i][2].ToString());
                            double nextvalue    = double.Parse(linerows[i + 1][3].ToString());
                            DateTime next_time  = DateTime.Parse(linerows[i + 1][2].ToString());
                            Line newline        = new Line();
                            TimeSpan ts1        = value_time - starttime;
                            TimeSpan ts2        = next_time - starttime;
                            newline.X1          = ts1.TotalMinutes / (timespan) * subgrid.Width;
                            newline.X2          = ts2.TotalMinutes / (timespan) * subgrid.Width;
                            newline.Y1          = subgrid.Height - value / (maxvalue - minvalue) * subgrid.Height;
                            newline.Y2          = subgrid.Height - nextvalue / (maxvalue - minvalue) * subgrid.Height;
                            newline.Stroke      = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
                            subgrid.Children.Add(newline);
                        }
                    }

                    temp_start_time = DateTime.Parse(temp_start_time.AddDays(1).ToString("yyyy-MM-dd") + " 00:00:00");
                }

                // 再绘制新当天的图
                string todaytable_name = "runtimetable" + temp_start_time.ToString("yyyyMMdd");
                // DataTable todaydt = mybuilder.Select_Table(todaytable_name, "Time>'" + temp_start_time.ToString("yyyy-MM-dd HH:mm:ss") + "' and Time<'"+endtime.ToString("yyyy-MM-dd HH:mm:ss")+"'");

                DataTable todaydt = null;

                bool exits2 = false;                                                             // 在内存中是否存在这样的一个表
                foreach (object mydatatable in All_Used_Running_Table)
                {
                    DataTable mydt = (DataTable)mydatatable;
                    if (mydt.TableName == todaytable_name)
                    {
                        todaydt = mydt;
                        exits2  = true;
                        break;
                    }
                }
                if (exits2 == false)
                {
                    todaydt = mybuilder.Select_Table(todaytable_name, "Time>'" + temp_start_time.ToString("yyyy-MM-dd HH:mm:ss") + "' and Time<'" + endtime.ToString("yyyy-MM-dd HH:mm:ss") + "'");
                    if (todaydt == null)
                    {
                        return;
                    }
                    if (todaydt.Rows.Count == 0)
                    {
                        return;
                    }
                    todaydt.TableName = todaytable_name;
                    All_Used_Running_Table.Add(todaydt);
                }


                // 绘图
                todaydt.Columns[1].ColumnName = "Value_Name";

                // 绘图 共可以绘制10条图案
                foreach (object lineobject in allline)
                {
                    myline_Struct line_struct = (myline_Struct)lineobject;
                    string linename           = line_struct.LineName;
                    string color       = line_struct.LineColor;           // 颜色
                    DataRow[] linerows = null;
                    try
                    {
                        linerows = todaydt.Select("Value_Name='" + linename + "'");
                    }
                    catch { return; }
                    if (linerows == null)
                    {
                        return;
                    }
                    for (int i = 0; i < linerows.Length - 1; i++)
                    {
                        double value        = double.Parse(linerows[i][3].ToString());
                        DateTime value_time = DateTime.Parse(linerows[i][2].ToString());
                        double nextvalue    = double.Parse(linerows[i + 1][3].ToString());
                        DateTime next_time  = DateTime.Parse(linerows[i + 1][2].ToString());

                        Line newline   = new Line();
                        TimeSpan ts1   = value_time - starttime;
                        TimeSpan ts2   = next_time - starttime;
                        newline.X1     = ts1.TotalMinutes / (timespan) * subgrid.Width;
                        newline.X2     = ts2.TotalMinutes / (timespan) * subgrid.Width;
                        newline.Y1     = subgrid.Height - value / (maxvalue - minvalue) * subgrid.Height;
                        newline.Y2     = subgrid.Height - nextvalue / (maxvalue - minvalue) * subgrid.Height;
                        newline.Stroke = new SolidColorBrush((Color)ColorConverter.ConvertFromString(color));
                        subgrid.Children.Add(newline);
                    }
                }
            }));
        }
예제 #7
0
        // 解析主窗体
        public static void ParseWindow(Window mywindow, SQL_Connect_Builder sql_builder, Grid MainGrid)
        {
            //  解析所有的Grid
            #region
            string    where_cmd = "ParentWindow='" + mywindow.Name + "'";
            DataTable allgriddt = sql_builder.Select_Table("ALLGrid", where_cmd);
            if (allgriddt != null)
            {
                if (allgriddt.Rows.Count > 0)
                {
                    foreach (DataRow dr in allgriddt.Rows)
                    {
                        Grid grid = new Grid();

                        // 水平对齐
                        if (dr[3].ToString() == "Left")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Left;
                        }
                        if (dr[3].ToString() == "Center")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Center;
                        }
                        if (dr[3].ToString() == "Right")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Right;
                        }
                        if (dr[3].ToString() == "Stretch")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
                        }

                        // 垂直对齐
                        if (dr[4].ToString() == "Bottom")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Bottom;
                        }
                        if (dr[4].ToString() == "Center")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Center;
                        }
                        if (dr[4].ToString() == "Stretch")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Stretch;
                        }
                        if (dr[4].ToString() == "Top")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Top;
                        }

                        int marginLeft   = int.Parse(dr[5].ToString());
                        int marginRight  = int.Parse(dr[6].ToString());
                        int marginTop    = int.Parse(dr[7].ToString());
                        int marginBottom = int.Parse(dr[8].ToString());

                        grid.Margin     = new Thickness(marginLeft, marginTop, marginRight, marginBottom);
                        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(dr[9].ToString()));
                        grid.Name       = dr[0].ToString();

                        if (dr[10].ToString() != "")
                        {
                            grid.Width = double.Parse(dr[10].ToString());
                        }
                        if (dr[11].ToString() != "")
                        {
                            grid.Height = double.Parse(dr[11].ToString());
                        }
                        if (dr[2].ToString() == "MainGrid")
                        {
                            // 在主页面下

                            MainGrid.Children.Add(grid);
                        }
                        else
                        {
                            // 不在主页面下
                            string GridName = dr[2].ToString();
                            foreach (UIElement element in MainGrid.Children)
                            {
                                try
                                {
                                    Grid mygrid = (Grid)element;
                                    if (mygrid.Name == dr[2].ToString())
                                    {
                                        mygrid.Children.Add(grid);
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            #endregion
            //  解析所有的MyTreeView
            #region
            where_cmd = "ParentWindow='" + mywindow.Name + "'";
            DataTable allMyTreeView = sql_builder.Select_Table("ALLMyTreeView", where_cmd);
            if (allMyTreeView != null)
            {
                if (allMyTreeView.Rows.Count > 0)
                {
                    foreach (DataRow dr in allMyTreeView.Rows)
                    {
                        DataTable  TreeViewItemsdt = sql_builder.Select_Table(dr[0].ToString());
                        MyTreeView treeview        = new MyTreeView(TreeViewItemsdt);
                        treeview.Name = dr[0].ToString();
                        if (dr[3].ToString() == "Left")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Left;
                        }
                        if (dr[3].ToString() == "Center")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Center;
                        }
                        if (dr[3].ToString() == "Right")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Right;
                        }
                        if (dr[3].ToString() == "Stretch")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Stretch;
                        }

                        // 垂直对齐
                        if (dr[4].ToString() == "Bottom")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Bottom;
                        }
                        if (dr[4].ToString() == "Center")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Center;
                        }
                        if (dr[4].ToString() == "Stretch")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Stretch;
                        }
                        if (dr[4].ToString() == "Top")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Top;
                        }

                        int marginLeft   = int.Parse(dr[5].ToString());
                        int marginRight  = int.Parse(dr[6].ToString());
                        int marginTop    = int.Parse(dr[7].ToString());
                        int marginBottom = int.Parse(dr[8].ToString());

                        treeview.Margin     = new Thickness(marginLeft, marginTop, marginRight, marginBottom);
                        treeview.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(dr[9].ToString()));
                        treeview.Name       = dr[0].ToString();

                        if (dr[10].ToString() != "")
                        {
                            treeview.Width = double.Parse(dr[10].ToString());
                        }
                        if (dr[11].ToString() != "")
                        {
                            treeview.Height = double.Parse(dr[11].ToString());
                        }
                        if (dr[2].ToString() == "MainGrid")
                        {
                            // 在主页面下

                            MainGrid.Children.Add(treeview);
                        }
                        else
                        {
                            // 不在主页面下
                            string GridName = dr[2].ToString();
                            foreach (UIElement element in MainGrid.Children)
                            {
                                try
                                {
                                    Grid mygrid = (Grid)element;
                                    if (mygrid.Name == dr[2].ToString())
                                    {
                                        mygrid.Children.Add(treeview);
                                        break;
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            #endregion
        }
예제 #8
0
        //解析副窗体
        public static void Parse_SubWindow(UserControl subwindow, SQL_Connect_Builder sql_builder, Grid MainGrid, Running_Data data)
        {
            // 解析所有的Grid
            #region
            string    where_cmd = "ParentWindow='" + subwindow.Name + "'";
            DataTable allgriddt = sql_builder.Select_Table("ALLGrid", where_cmd);
            if (allgriddt != null)
            {
                if (allgriddt.Rows.Count > 0)
                {
                    foreach (DataRow dr in allgriddt.Rows)
                    {
                        Grid grid = new Grid();

                        // 水平对齐
                        if (dr[3].ToString() == "Left")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Left;
                        }
                        if (dr[3].ToString() == "Center")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Center;
                        }
                        if (dr[3].ToString() == "Right")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Right;
                        }
                        if (dr[3].ToString() == "Stretch")
                        {
                            grid.HorizontalAlignment = HorizontalAlignment.Stretch;
                        }

                        // 垂直对齐
                        if (dr[4].ToString() == "Bottom")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Bottom;
                        }
                        if (dr[4].ToString() == "Center")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Center;
                        }
                        if (dr[4].ToString() == "Stretch")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Stretch;
                        }
                        if (dr[4].ToString() == "Top")
                        {
                            grid.VerticalAlignment = VerticalAlignment.Top;
                        }

                        int marginLeft   = int.Parse(dr[5].ToString());
                        int marginRight  = int.Parse(dr[6].ToString());
                        int marginTop    = int.Parse(dr[7].ToString());
                        int marginBottom = int.Parse(dr[8].ToString());

                        grid.Margin     = new Thickness(marginLeft, marginTop, marginRight, marginBottom);
                        grid.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(dr[9].ToString()));
                        grid.Name       = dr[0].ToString();

                        if (dr[10].ToString() != "")
                        {
                            grid.Width = double.Parse(dr[10].ToString());
                        }
                        if (dr[11].ToString() != "")
                        {
                            grid.Height = double.Parse(dr[11].ToString());
                        }
                        if (dr[2].ToString() == "MainGrid")
                        {
                            // 在主页面下

                            MainGrid.Children.Add(grid);
                        }
                        else
                        {
                            // 不在主页面下
                            string GridName = dr[2].ToString();
                            foreach (UIElement element in MainGrid.Children)
                            {
                                try
                                {
                                    Grid mygrid = (Grid)element;
                                    if (mygrid.Name == dr[2].ToString())
                                    {
                                        mygrid.Children.Add(grid);
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            #endregion

            //  解析所有的MyTreeView
            #region
            where_cmd = "ParentWindow='" + subwindow.Name + "'";
            DataTable allMyTreeView = sql_builder.Select_Table("ALLMyTreeView", where_cmd);
            if (allMyTreeView != null)
            {
                if (allMyTreeView.Rows.Count > 0)
                {
                    foreach (DataRow dr in allMyTreeView.Rows)
                    {
                        DataTable  TreeViewItemsdt = sql_builder.Select_Table(dr[0].ToString());
                        MyTreeView treeview        = new MyTreeView(TreeViewItemsdt);
                        treeview.Name = dr[0].ToString();
                        if (dr[3].ToString() == "Left")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Left;
                        }
                        if (dr[3].ToString() == "Center")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Center;
                        }
                        if (dr[3].ToString() == "Right")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Right;
                        }
                        if (dr[3].ToString() == "Stretch")
                        {
                            treeview.HorizontalAlignment = HorizontalAlignment.Stretch;
                        }

                        // 垂直对齐
                        if (dr[4].ToString() == "Bottom")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Bottom;
                        }
                        if (dr[4].ToString() == "Center")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Center;
                        }
                        if (dr[4].ToString() == "Stretch")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Stretch;
                        }
                        if (dr[4].ToString() == "Top")
                        {
                            treeview.VerticalAlignment = VerticalAlignment.Top;
                        }

                        int marginLeft   = int.Parse(dr[5].ToString());
                        int marginRight  = int.Parse(dr[6].ToString());
                        int marginTop    = int.Parse(dr[7].ToString());
                        int marginBottom = int.Parse(dr[8].ToString());

                        treeview.Margin     = new Thickness(marginLeft, marginTop, marginRight, marginBottom);
                        treeview.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(dr[9].ToString()));
                        treeview.Name       = dr[0].ToString();

                        if (dr[10].ToString() != "")
                        {
                            treeview.Width = double.Parse(dr[10].ToString());
                        }
                        if (dr[11].ToString() != "")
                        {
                            treeview.Height = double.Parse(dr[11].ToString());
                        }
                        if (dr[2].ToString() == "MainGrid")
                        {
                            // 在主页面下

                            MainGrid.Children.Add(treeview);
                        }
                        else
                        {
                            // 不在主页面下
                            string GridName = dr[2].ToString();
                            foreach (UIElement element in MainGrid.Children)
                            {
                                try
                                {
                                    Grid mygrid = (Grid)element;
                                    if (mygrid.Name == dr[2].ToString())
                                    {
                                        mygrid.Children.Add(treeview);
                                        break;
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            #endregion

            // 解析所有的MyLabel
            #region
            DataTable AllMyLabeldt = sql_builder.Select_Table("AllMyLabel", where_cmd);
            if (AllMyLabeldt != null)
            {
                if (AllMyLabeldt.Rows.Count > 0)
                {
                    foreach (DataRow dr in AllMyLabeldt.Rows)
                    {
                        MyLabel mylabel = new MyLabel(dr, sql_builder, data);
                        if (dr[2].ToString() == "MainGrid")
                        {
                            // 在主页面下

                            MainGrid.Children.Add(mylabel);
                        }
                        else
                        {
                            // 不在主页面下
                            string GridName = dr[2].ToString();
                            foreach (UIElement element in MainGrid.Children)
                            {
                                try
                                {
                                    Grid mygrid = (Grid)element;
                                    if (mygrid.Name == dr[2].ToString())
                                    {
                                        mygrid.Children.Add(mylabel);
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            #endregion

            // 解析所有的MyChart
            #region
            DataTable AllMyChart = sql_builder.Select_Table("ALLMyChart", where_cmd);
            if (AllMyChart != null)
            {
                if (AllMyChart.Rows.Count > 0)
                {
                    foreach (DataRow dr in AllMyChart.Rows)
                    {
                        MyChart mychart = new MyChart(dr, sql_builder);
                        if (dr[2].ToString() == "MainGrid")
                        {
                            // 在主页面下

                            MainGrid.Children.Add(mychart);
                        }
                        else
                        {
                            // 不在主页面下
                            string GridName = dr[2].ToString();
                            foreach (UIElement element in MainGrid.Children)
                            {
                                try
                                {
                                    Grid mygrid = (Grid)element;
                                    if (mygrid.Name == dr[2].ToString())
                                    {
                                        mygrid.Children.Add(mychart);
                                    }
                                }
                                catch { }
                            }
                        }
                    }
                }
            }
            #endregion

            // 解析所有的MyDataGridView
            // 表格分种类
            #region
            DataTable AllDataGridView = sql_builder.Select_Table("AllDataGrid", where_cmd);
            if (AllDataGridView != null)
            {
                if (AllDataGridView.Rows.Count > 0)
                {
                    foreach (DataRow dr in AllDataGridView.Rows)
                    {
                        // 顺序表
                        if (dr[1].ToString() == "OrderTable")
                        {
                            // 读取表格
                            DataTable gongyibiao = sql_builder.Select_Table(dr[0].ToString());
                            if (gongyibiao == null)
                            {
                                return;
                            }

                            MyOrderDataGridView datagridview = new MyOrderDataGridView(gongyibiao, dr);
                            if (dr[3].ToString() == "MainGrid")
                            {
                                // 在主页面下
                                MainGrid.Children.Add(datagridview);
                            }
                            else
                            {
                                // 不在主页面下
                                string GridName = dr[3].ToString();
                                foreach (UIElement element in MainGrid.Children)
                                {
                                    try
                                    {
                                        Grid mygrid = (Grid)element;
                                        if (mygrid.Name == dr[2].ToString())
                                        {
                                            mygrid.Children.Add(datagridview);
                                        }
                                    }
                                    catch { }
                                }
                            }
                        }
                    }
                }
            }
            #endregion
        }
예제 #9
0
        private void thread()
        {
            if (isupdate == false)
            {
                isupdate = true;
            }
            else
            {
                return;
            }
            ArrayList list = FileCaozuo.Read_All_Files("D://data//", "*.txt");


            int count = 0;

            try
            {
                string    where_cmd = "mykey='mynum'";
                DataTable dt        = builder.Select_Table("tiaonum", where_cmd);
                count = int.Parse(dt.Rows[0][1].ToString());
            }
            catch { }

            for (int i = count; i < list.Count; i++)
            {
                CreateSqlValueType[] create_cmd = new CreateSqlValueType[2];
                create_cmd[0] = new CreateSqlValueType("float", "pos", true);
                create_cmd[1] = new CreateSqlValueType("float", "value");

                string name     = (string)list[i];
                string filename = string_caozuo.Get_Dian_String(name, 1);
                builder.Create_Table("data" + string_caozuo.Get_HengGang_String(filename, 1) + string_caozuo.Get_HengGang_String(filename, 2), create_cmd);

                wenjian     = i;
                wenjianzong = list.Count;


                string   mywhere_cmd = "mykey='mynum'";
                string[] update_cmd  = new string[1];
                update_cmd[0] = "num='" + i.ToString() + "'";

                builder.Updata("tiaonum", mywhere_cmd, update_cmd);

                // 读取全部数据
                string[] jizhun_list = FileCaozuo.Read_All_Line("D:\\data\\" + name);
                for (int j = 0; j < jizhun_list.Length; j++)
                {
                    try
                    {
                        shuju     = j;
                        shujuzong = jizhun_list.Length;
                        string pos   = string_caozuo.Get_Table_String(jizhun_list[j], 1);
                        string value = string_caozuo.Get_Table_String(jizhun_list[j], 2);



                        string[] insert_cmd = new string[2];
                        insert_cmd[0] = pos;
                        insert_cmd[1] = value;
                        bool result = builder.Insert("data" + string_caozuo.Get_HengGang_String(filename, 1) + string_caozuo.Get_HengGang_String(filename, 2), insert_cmd);
                    }
                    catch { }
                }
            }
            isupdate = false;
        }
예제 #10
0
        public MyLabel(DataRow dr, SQL_Connect_Builder builder, Running_Data data)
        {
            InitializeComponent();

            mydata = data;
            mydata.value_Change_Event += new EventHandler(Gengxin_Tick);

            // mydata的变化与mylabel的变化进行对接

            sqlbuilder = builder;

            ValueTable = builder.Select_Table("Value_Table");                //  数据字典表
            ValueTable.Columns[0].ColumnName = "Value_Name";

            this.Name = dr[0].ToString();

            ParentWindow = dr[1].ToString();

            ParentGrid = dr[2].ToString();


            try
            {
                Width = double.Parse(dr[3].ToString());
            }
            catch
            {
                Width = double.NaN;
            }

            try
            {
                Height = double.Parse(dr[4].ToString());
            }
            catch
            {
                Height = double.NaN;
            }
            try
            {
                this.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(dr[15].ToString()));
            }
            catch { }

            // 横对齐解析
            switch (dr[5].ToString())
            {
            case "Left":
                HorizontalAlignment = HorizontalAlignment.Left;
                break;

            case "Right":
                HorizontalAlignment = HorizontalAlignment.Right;
                break;

            case "Center":
                HorizontalAlignment = HorizontalAlignment.Center;
                break;

            case "Stretch":
                HorizontalAlignment = HorizontalAlignment.Stretch;
                break;

            default:
                HorizontalAlignment = HorizontalAlignment.Center;
                break;
            }

            // 纵对齐解析
            switch (dr[6].ToString())
            {
            case "Top":
                VerticalAlignment = VerticalAlignment.Top;
                break;

            case "Bottom":
                VerticalAlignment = VerticalAlignment.Bottom;
                break;

            case "Center":
                VerticalAlignment = VerticalAlignment.Center;
                break;

            case "Stretch":
                VerticalAlignment = VerticalAlignment.Stretch;
                break;

            default:
                VerticalAlignment = VerticalAlignment.Center;
                break;
            }

            MarginLeft   = double.Parse(dr[7].ToString());
            MarginRight  = double.Parse(dr[8].ToString());
            MarginTop    = double.Parse(dr[9].ToString());
            MarginBottom = double.Parse(dr[10].ToString());

            this.Margin = new Thickness(MarginLeft, MarginTop, MarginRight, MarginBottom);

            switch (dr[11].ToString())
            {
            case "Left":
                Label.HorizontalContentAlignment = HorizontalAlignment.Left;
                break;

            case "Right":
                Label.HorizontalContentAlignment = HorizontalAlignment.Right;
                break;

            case "Center":
                Label.HorizontalContentAlignment = HorizontalAlignment.Center;
                break;

            case "Stretch":
                Label.HorizontalContentAlignment = HorizontalAlignment.Stretch;
                break;

            default:
                Label.HorizontalContentAlignment = HorizontalAlignment.Center;
                break;
            }

            switch (dr[12].ToString())
            {
            case "Top":
                Label.VerticalContentAlignment = VerticalAlignment.Top;
                break;

            case "Bottom":
                Label.VerticalContentAlignment = VerticalAlignment.Bottom;
                break;

            case "Center":
                Label.VerticalContentAlignment = VerticalAlignment.Center;
                break;

            case "Stretch":
                Label.VerticalContentAlignment = VerticalAlignment.Stretch;
                break;

            default:
                Label.VerticalContentAlignment = VerticalAlignment.Center;
                break;
            }

            double myfontsize = double.Parse(dr[13].ToString());

            // Label.FontSize = myfontsize;
            this.FontSize = myfontsize;
            //label.FontSize = myfontsize;

            Value_Name = dr[14].ToString();
            ALLMyLabel_List.Add(this);
        }
예제 #11
0
        private void Show_Windows_Control(Form view)
        {
            view.Controls.Clear();
            DataTable dt = Main_DataBase_Builder.Select_Table(Selected_View_Name);

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    // 解析所有的标签
                    #region
                    if (dr[1].ToString() == "NormalLabel")
                    {
                        string    where_cmd = "labelname='" + dr[0].ToString() + "'";
                        DataTable labeldt   = Main_DataBase_Builder.Select_Table("Alllabel", where_cmd);
                        if (labeldt != null)
                        {
                            if (labeldt.Rows.Count > 0)
                            {
                                try
                                {
                                    DataRow labeldr = labeldt.Rows[0];
                                    NormalControls.MyLabel mylabel = new NormalControls.MyLabel("Normal");
                                    mylabel.MyName   = labeldr[0].ToString();
                                    mylabel.ViewName = view.Name;
                                    mylabel.Set_Text(labeldr[1].ToString());
                                    mylabel.Left   = int.Parse(labeldr[2].ToString());
                                    mylabel.Top    = int.Parse(labeldr[3].ToString());
                                    mylabel.Width  = int.Parse(labeldr[4].ToString());
                                    mylabel.Height = int.Parse(labeldr[5].ToString());
                                    mylabel.Set_BackColor(labeldr[6].ToString());
                                    mylabel.Set_FontSize(int.Parse(labeldr[8].ToString()));
                                    mylabel.Set_ForeColor(labeldr[9].ToString());
                                    view.Controls.Add(mylabel);
                                    //mylabel
                                }
                                catch { }
                            }
                        }
                    }
                    #endregion
                    // 解析所有的数据标签
                    #region
                    if (dr[1].ToString() == "ValueLabel")
                    {
                        NormalControls.MyLabel label = get_valuelabel(dr[0].ToString());
                        if (label != null)
                        {
                            view.Controls.Add(label);
                        }
                    }
                    #endregion

                    // 解析所有的按钮
                    #region
                    if (dr[1].ToString() == "Button")
                    {
                        string    where_cmd = "buttonname='" + dr[0].ToString() + "'";
                        DataTable buttondt  = Main_DataBase_Builder.Select_Table("AllButton", where_cmd);
                        if (buttondt != null)
                        {
                            if (buttondt.Rows.Count > 0)
                            {
                                try
                                {
                                    DataRow buttondr = buttondt.Rows[0];
                                    NormalControls.MyButton mybutton = new NormalControls.MyButton();
                                    mybutton.MyName   = buttondr[0].ToString();
                                    mybutton.ViewName = view.Name;
                                    mybutton.SetText(buttondr[1].ToString());
                                    mybutton.Left   = int.Parse(buttondr[2].ToString());
                                    mybutton.Top    = int.Parse(buttondr[3].ToString());
                                    mybutton.Width  = int.Parse(buttondr[4].ToString());
                                    mybutton.Height = int.Parse(buttondr[5].ToString());
                                    mybutton.Set_BackColor(buttondr[6].ToString());
                                    mybutton.Set_FontSize(int.Parse(buttondr[8].ToString()));
                                    mybutton.Set_ForeColor(buttondr[9].ToString());
                                    view.Controls.Add(mybutton);
                                    mybutton.Button_Press += new EventHandler(Press_Button);
                                    //mylabel
                                }
                                catch { }
                            }
                        }
                    }
                    #endregion
                }
            }
        }