123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Navigation;
- using System.Windows.Shapes;
- using System.Data;
- using System.Data.SQLite;
- using System.IO;
- using System.Windows.Interop;
- namespace AIRS.usercontrol
- {
- /// <summary>
- /// Page_FirstControl.xaml 的交互逻辑
- /// </summary>
- public partial class Page_FirstControl : UserControl
- {
- //委托事件
- public delegate void ShowPage(string testitem);
- public static event ShowPage ShowpageEvent;
- public Boolean inclusion = false;
- public List<String> lincl = new List<string>();
- public Page_FirstControl()
- {
- InitializeComponent();
- //显示试样信息
- //数据库
- connstr.DataSource = path + "\\datas.db";
- conn.ConnectionString = connstr.ToString();
- conn.Open();
- ShowSteel();
- //查询钢种
- Inclusion.inc_change += Show_Entry;
- lincl.Add("a");
- lincl.Add("b");
- lincl.Add("c");
- }
- private void Show_Entry(List<String> incl)
- {
- lincl = incl;
- if (lincl.Count>0)
- {
- this.txtinput.Visibility = Visibility.Visible;
- }
- else
- {
- this.txtinput.Visibility = Visibility.Hidden;
- }
- if (ShowpageEvent != null)
- {
- ShowpageEvent(testitems);
- }
- }
- /// <summary>
- /// 装载事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void userControlLoader(object sender, RoutedEventArgs e)
- {
- }
- private string path = Directory.GetCurrentDirectory();
- SQLiteConnection conn = new SQLiteConnection();
- SQLiteConnectionStringBuilder connstr = new SQLiteConnectionStringBuilder();
- SQLiteDataAdapter da = new SQLiteDataAdapter();
- List<string> liststeel_id = new List<string>();
- List<string> liststandard_id = new List<string>();
- List<string> listtestitem_id = new List<string>();
- List<Label> list_lblsteel = new List<Label>();//钢种
- List<Label> list_lblstandard = new List<Label>(); //评级标准
- private List<Label> list_lbltestitems = new List<Label>();//检验项目
- public string steel;
- public string standard;
- public string testitems;
- public string catagory;
- public string items;
- public string testitems_param;
- /// <summary>
- /// 更新首页显示信息
- /// </summary>
- /// <param name="steel"></param>
- /// <param name="standard"></param>
- /// <param name="testitem"></param>
- public void update_pagefirst_show(string _steel, string _standard, string _testitem)
- {
- if(_steel=="夹杂物")
- {
- inclusion = true;
- }
- else
- {
- inclusion = false;
- }
- //查找钢种
- for (int i = 0; i < list_lblsteel.Count; i++)
- {
- if (list_lblsteel[i].Content.ToString() == _steel)
- {
- list_lblsteel[i].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- this.steel = _steel;
- }
- else
- {
- list_lblsteel[i].Foreground = new SolidColorBrush(Colors.White);
- list_lblsteel[i].Background = null;
- }
- }
- try
- {
- da = new SQLiteDataAdapter("select * from t_steel where Isshow=1 and opt_steel='" + _steel + "'", conn);
- DataTable ds = new DataTable();
- da.Fill(ds);
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- catagory = ds.Rows[i][3].ToString();
- }
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- //根据钢种查询标准
- string standard_id = "";
- try
- {
- //查询标准
- Can_Standard.Children.Clear();//清空显示在页面的评级标准
- list_lblstandard.Clear();//清空评级标准list
- Can_Testitems.Children.Clear();//未选择评级标准应该不显示检验项目
- testitems = "";//清除未选择评级标准的检验项目
- Can_Testitems.Height = 5; //检验项目高度变小不会有垂直滚动条
- // SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_standard WHERE 钢种='" + steel + "'", conn);
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_standard WHERE opt_steel='" + find_steel_by_steel(_steel).Rows[0][0].ToString() + "'", conn);
- DataTable ds = new DataTable();
- dat.Fill(ds);
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- Label lblstandard = new Label();
- lblstandard.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(lblstandard_Click);
- lblstandard.MouseEnter += Lblstandard_MouseEnter;
- lblstandard.MouseLeave += Lblstandard_MouseLeave;
- lblstandard.Content = ds.Rows[i][2].ToString();
- lblstandard.Foreground = new SolidColorBrush(Colors.White);
- lblstandard.Width = 250;
- lblstandard.Height = 40;
- lblstandard.HorizontalContentAlignment = HorizontalAlignment.Center;
- lblstandard.VerticalContentAlignment = VerticalAlignment.Center;
- lblstandard.FontSize = 22;
- lblstandard.SetValue(Canvas.TopProperty, 0.0 + i * 50);
- lblstandard.SetValue(Canvas.LeftProperty, 0.0);
- lblstandard.SetValue(Canvas.RightProperty, double.NaN);
- lblstandard.SetValue(Canvas.BottomProperty, double.NaN);
- lblstandard.Tag = i.ToString();
- lblstandard.Cursor = Cursors.Hand;
- if (lblstandard.Content.ToString() == _standard)
- {
- lblstandard.Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- standard = _standard;
- standard_id = ds.Rows[i][1].ToString();
- }
- list_lblstandard.Add(lblstandard);
- Can_Standard.Children.Add(lblstandard);
- }
- Can_Standard.Height = ds.Rows.Count * 50;
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- //根据标准查询项目
- try
- {
- //查询标准
- Can_Testitems.Children.Clear();
- list_lbltestitems.Clear();
- testitems = "";//清除未选择评级标准的检验项目
- // SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_testitems WHERE 评级标准='" + standard + "'and Isshow=1", conn);
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_testitems WHERE opt_standard='" + find_steel_by_steel(_steel).Rows[0][0].ToString() + "'and Isshow=1", conn);
- DataTable ds = new DataTable();
- dat.Fill(ds);
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- Label lbltestitem = new Label();
- lbltestitem.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(lbltestitems_Click);
- lbltestitem.MouseEnter += Lbltestitem_MouseEnter;
- lbltestitem.MouseLeave += Lbltestitem_MouseLeave;
- if(inclusion)
- {
- lbltestitem.Content = ds.Rows[i][2].ToString() + " ▼";
- }
- else
- {
- lbltestitem.Content = ds.Rows[i][2].ToString();
- }
-
- lbltestitem.Foreground = new SolidColorBrush(Colors.White);
- lbltestitem.Width = 270;
- lbltestitem.Height = 40;
- lbltestitem.HorizontalContentAlignment = HorizontalAlignment.Center;
- lbltestitem.VerticalContentAlignment = VerticalAlignment.Center;
- lbltestitem.FontSize = 22;
- lbltestitem.SetValue(Canvas.TopProperty, 0.0 + i * 50);
- lbltestitem.SetValue(Canvas.LeftProperty, 0.0);
- lbltestitem.SetValue(Canvas.RightProperty, double.NaN);
- lbltestitem.SetValue(Canvas.BottomProperty, double.NaN);
- lbltestitem.Tag = i.ToString();
- lbltestitem.Cursor = Cursors.Hand;
- if (lbltestitem.Content.ToString().IndexOf( _testitem)>-1)
- {
- // lbltestitem.Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));//字体颜色
- lbltestitem.Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- testitems = _testitem;
- items = find_testitems(standard_id, testitems).Rows[0][4].ToString();
- }
- list_lbltestitems.Add(lbltestitem);
- Can_Testitems.Children.Add(lbltestitem);
- }
- Can_Testitems.Height = ds.Rows.Count * 50;
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- IsShowTextInput();
- }
- /// <summary>
- /// 初始化时显示钢种
- /// </summary>
- private void ShowSteel()
- {
- try
- {
- da = new SQLiteDataAdapter("select * from t_steel where Isshow=1", conn);
- DataTable ds = new DataTable();
- da.Fill(ds);
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- Label lblsteel = new Label();
- lblsteel.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(lblsteel_Click);
- lblsteel.MouseMove += Lblsteel_MouseMove;
- lblsteel.MouseLeave += Lblsteel_MouseLeave;
- lblsteel.Content = ds.Rows[i][1].ToString();
- liststeel_id.Add(ds.Rows[i][0].ToString());
- lblsteel.Foreground = new SolidColorBrush(Colors.White);
- // lblsteel.Background = new SolidColorBrush(Colors.AliceBlue);
- lblsteel.Width = 250;
- lblsteel.Height = 40;
- lblsteel.HorizontalContentAlignment = HorizontalAlignment.Center;
- lblsteel.VerticalContentAlignment = VerticalAlignment.Center;
- lblsteel.FontSize = 22;
- lblsteel.SetValue(Canvas.TopProperty, 0.0 + i * 50);
- lblsteel.SetValue(Canvas.LeftProperty, 0.0);
- lblsteel.SetValue(Canvas.RightProperty, double.NaN);
- lblsteel.SetValue(Canvas.BottomProperty, double.NaN);
- lblsteel.Tag = i.ToString();
- lblsteel.Cursor = Cursors.Hand;
- if (i == 0)
- {
- lblsteel.Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- //lblsteel.Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));//字体颜色
- // Click_Steel(ds.Rows[i][0].ToString());
- Click_Steel(ds.Rows[i][0].ToString());
- catagory = ds.Rows[i][3].ToString();
- steel = ds.Rows[i][1].ToString();//给钢种赋值
- Console.WriteLine("初始化时 steel" + steel + "Catagory" + catagory);
- IsShowTextInput();
- }
- list_lblsteel.Add(lblsteel);
- Can_Steel.Children.Add(lblsteel);
- //Console.WriteLine("控件的" + lblsteel);
- }
- Can_Steel.Height = ds.Rows.Count * (50);
- // Scrviewer_Steel.Height = ds.Rows.Count * (50) + 10;
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- /// <summary>
- /// 鼠标移除钢种后颜色变回
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Lblsteel_MouseLeave(object sender, MouseEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- list_lblsteel[index].Background = System.Windows.Media.Brushes.Transparent;
- list_lblsteel[index].Foreground = System.Windows.Media.Brushes.White;
- list_lblsteel[index].FontSize = 22;
- if (list_lblsteel[index].ToString().Substring(list_lblsteel[index].ToString().IndexOf(":") + 2) == steel)
- {
- list_lblsteel[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- ////以下是移除后选中的那条变为啥颜色
- //list_lblsteel[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- }
- }
- /// <summary>
- /// 鼠标在移动在钢种上方时有颜色变化
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Lblsteel_MouseMove(object sender, MouseEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- //list_lblsteel[index].Background = System.Windows.Media.Brushes.Transparent;
- if (list_lblsteel[index].ToString().Substring(list_lblsteel[index].ToString().IndexOf(":") + 2) == steel)
- {
- list_lblsteel[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- list_lblsteel[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lblsteel[index].FontSize = 24;
- }
- else
- {
- list_lblsteel[index].Background = new SolidColorBrush(Color.FromRgb(54, 62, 78));
- list_lblsteel[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lblsteel[index].FontSize = 24;
- }
- }
- /// <summary>
- /// 钢种点击事件,选中行变颜色
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lblsteel_Click(object sender, MouseButtonEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- for (int i = 0; i < list_lblsteel.Count; i++)
- {
- list_lblsteel[i].Foreground = new SolidColorBrush(Colors.White);
- list_lblsteel[i].Background = null;
- }
- // list_lblsteel[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lblsteel[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- if(list_lblsteel[index].Content.ToString().IndexOf("夹杂物")>-1)
- {
- inclusion = true;
- }
- else
- {
- inclusion = false;
- }
- steel = list_lblsteel[index].Content.ToString();
- catagory = find_steel_by_steel(steel).Rows[0][3].ToString();
- Console.WriteLine("点击后 steel" + steel + "Catagory" + catagory);
- //Click_Steel(list_lblsteel[index].ToString().Substring(list_lblsteel[index].ToString().IndexOf(":") + 2));
- Click_Steel(find_steel_by_steel(steel).Rows[0][0].ToString());
-
- IsShowTextInput();
- }
- /// <summary>
- /// 根据钢种返回一条记录
- /// </summary>
- /// <param name="steel"></param>
- /// <returns></returns>
- private DataTable find_steel_by_steel(string steel)
- {
- DataTable ds = new DataTable();
- try
- {
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_steel WHERE opt_steel='" + steel + "' and Isshow=1", conn);
- dat.Fill(ds);
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- return ds;
- }
- /// <summary>
- /// 根据钢种显示标准
- /// </summary>
- /// <param name="steel"></param>
- public void Click_Steel(string steel)
- {
- try
- {
- //查询标准
- Can_Standard.Children.Clear();//清空显示在页面的评级标准
- list_lblstandard.Clear();//清空评级标准list
- Can_Testitems.Children.Clear();//未选择评级标准应该不显示检验项目
- testitems = "";//清除未选择评级标准的检验项目
- Can_Testitems.Height = 5; //检验项目高度变小不会有垂直滚动条
- testitems_param = "";
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_standard WHERE opt_steel='" + steel + "'and Isshow=1", conn);
- DataTable ds = new DataTable();
- dat.Fill(ds);
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- Label lblstandard = new Label();
- lblstandard.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(lblstandard_Click);
- lblstandard.MouseEnter += Lblstandard_MouseEnter;
- lblstandard.MouseLeave += Lblstandard_MouseLeave;
- lblstandard.Content = ds.Rows[i][2].ToString();
- lblstandard.Foreground = new SolidColorBrush(Colors.White);
- lblstandard.Width = 250;
- lblstandard.Height = 40;
- lblstandard.HorizontalContentAlignment = HorizontalAlignment.Center;
- lblstandard.VerticalContentAlignment = VerticalAlignment.Center;
- lblstandard.FontSize = 22;
- lblstandard.SetValue(Canvas.TopProperty, 0.0 + i * 50);
- lblstandard.SetValue(Canvas.LeftProperty, 0.0);
- lblstandard.SetValue(Canvas.RightProperty, double.NaN);
- lblstandard.SetValue(Canvas.BottomProperty, double.NaN);
- lblstandard.Tag = i.ToString();
- lblstandard.Cursor = Cursors.Hand;
- if (i == 0)
- {
- //lblstandard.Foreground= new SolidColorBrush(Color.FromRgb(245, 154, 35));//字体颜色
- lblstandard.Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- Click_Standard(ds.Rows[i][0].ToString());
- standard = ds.Rows[i][2].ToString();
- string stanardid = ds.Rows[i][0].ToString();
- Console.WriteLine(testitems);
- items = find_testitems(ds.Rows[i][0].ToString(), testitems).Rows[0][4].ToString();
- // string steelid = find_steel_by_steel(steel).Rows[0][0].ToString();
- // string stanardid = find_standard_bysteel_id(steelid).Rows[0][0].ToString();
- if (find_testitems(stanardid, testitems).Rows[0][5].ToString() != "")
- {
- testitems_param = find_testitems(stanardid, testitems).Rows[0][5].ToString();
- }
- Console.WriteLine("看这里看这里 " + testitems_param);
- Console.WriteLine("standard " + standard);
- Console.WriteLine("testitmes " + testitems + "items" + items);
- IsShowTextInput();
- }
- list_lblstandard.Add(lblstandard);
- Can_Standard.Children.Add(lblstandard);
- }
- Can_Standard.Height = ds.Rows.Count * 50;
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- private void Lblstandard_MouseLeave(object sender, MouseEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- list_lblstandard[index].Background = System.Windows.Media.Brushes.Transparent;
- list_lblstandard[index].Foreground = System.Windows.Media.Brushes.White;
- list_lblstandard[index].FontSize = 22;
- if (list_lblstandard[index].ToString().Substring(list_lblstandard[index].ToString().IndexOf(":") + 2) == standard)
- {
- list_lblstandard[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- // list_lblstandard[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- }
- }
- private void Lblstandard_MouseEnter(object sender, MouseEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- //list_lblsteel[index].Background = System.Windows.Media.Brushes.Transparent;
- if (list_lblstandard[index].ToString().Substring(list_lblstandard[index].ToString().IndexOf(":") + 2) == standard)
- {
- list_lblstandard[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- list_lblstandard[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lblstandard[index].FontSize = 24;
- }
- else
- {
- list_lblstandard[index].Background = new SolidColorBrush(Color.FromRgb(54, 62, 78));
- list_lblstandard[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lblstandard[index].FontSize = 24;
- }
- }
- /// <summary>
- /// 评级标准点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lblstandard_Click(object sender, MouseButtonEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- for (int i = 0; i < list_lblstandard.Count; i++)
- {
- list_lblstandard[i].Foreground = new SolidColorBrush(Colors.White);//字体颜色
- list_lblstandard[i].Background = null;
- }
- //list_lblstandard[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));//字体颜色
- list_lblstandard[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- standard = list_lblstandard[index].ToString().Substring(list_lblstandard[index].ToString().IndexOf(":") + 2);
- //Click_Standard(list_lblstandard[index].ToString().Substring(list_lblstandard[index].ToString().IndexOf(":") + 2));
- //Console.WriteLine(find_steel_by_steel(steel).Rows[0][0].ToString()+"标准"+find_standard_bysteel_id(find_steel_by_steel(steel).Rows[0][0].ToString()).Rows[0][0].ToString());
- Click_Standard(find_standard_bysteel_id(find_steel_by_steel(steel).Rows[0][0].ToString()).Rows[0][0].ToString());
- IsShowTextInput();
- Console.WriteLine("点击standard" + standard);
- }
- /// <summary>
- /// 根据标准返回一条记录
- /// </summary>
- /// <param name="steel"></param>
- /// <returns></returns>
- private DataTable find_standard_bysteel_id(string steel_id)
- {
- DataTable ds = new DataTable();
- try
- {
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_standard WHERE opt_steel='" + steel_id + "' and Isshow=1", conn);
- dat.Fill(ds);
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- return ds;
- }
- /// <summary>
- /// 点击标准显示检验项目
- /// </summary>
- /// <param name="steel"></param>
- public void Click_Standard(string standard)
- {
- try
- {
- //查询标准
- Can_Testitems.Children.Clear();
- list_lbltestitems.Clear();
- testitems = "";//清除未选择评级标准的检验项目
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_testitems WHERE opt_standard='" + standard + "' and Isshow=1", conn);
- DataTable ds = new DataTable();
- dat.Fill(ds);
- for (int i = 0; i < ds.Rows.Count; i++)
- {
- Label lbltestitem = new Label();
- lbltestitem.PreviewMouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(lbltestitems_Click);
- lbltestitem.MouseEnter += Lbltestitem_MouseEnter;
- lbltestitem.MouseLeave += Lbltestitem_MouseLeave;
-
-
- lbltestitem.Foreground = new SolidColorBrush(Colors.White);
- if(inclusion)
- {
- lbltestitem.Content = ds.Rows[i][2].ToString() + " ▼";
- }
- else
- {
- lbltestitem.Content = ds.Rows[i][2].ToString();
- }
- lbltestitem.Width = 270;
- lbltestitem.Height = 40;
- lbltestitem.HorizontalContentAlignment = HorizontalAlignment.Center;
- lbltestitem.VerticalContentAlignment = VerticalAlignment.Center;
- lbltestitem.FontSize = 22;
- lbltestitem.SetValue(Canvas.TopProperty, 0.0 + i * 50);
- lbltestitem.SetValue(Canvas.LeftProperty, 0.0);
- lbltestitem.SetValue(Canvas.RightProperty, double.NaN);
- lbltestitem.SetValue(Canvas.BottomProperty, double.NaN);
- lbltestitem.Tag = i.ToString();
- lbltestitem.Cursor = Cursors.Hand;
- if (i == 0)
- {
- // lbltestitem.Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));//字体颜色
- lbltestitem.Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- testitems = ds.Rows[i][2].ToString();
- //string steelid = find_steel_by_steel(steel).Rows[0][0].ToString();
- //string stanardid = find_standard_bysteel_id(steelid).Rows[0][0].ToString();
- //Items = find_testitems(stanardid, testitems).Rows[0][4].ToString();
- //Console.WriteLine("testitems" + testitems);
- //Console.WriteLine("items" + Items);
- }
- list_lbltestitems.Add(lbltestitem);
- Can_Testitems.Children.Add(lbltestitem);
- }
- Can_Testitems.Height = ds.Rows.Count * 50;
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- }
- private void Lbltestitem_MouseLeave(object sender, MouseEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- list_lbltestitems[index].Background = System.Windows.Media.Brushes.Transparent;
- list_lbltestitems[index].Foreground = System.Windows.Media.Brushes.White;
- list_lbltestitems[index].FontSize = 22;
- // list_lbltestitems[index].Width = 250;
- if(inclusion)
- {
- //Can_Testitems.Children.Remove(Can_Testitems.FindName("inclusion") as Inclusion);
- //Can_Testitems.UnregisterName("inclusion");
- if (list_lbltestitems[index].Content.ToString().IndexOf(testitems)>-1)
- {
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- //list_lbltestitems[index].Width = 250;
- //list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- }
- }
- else
- {
- if (list_lbltestitems[index].Content.ToString() == testitems)
- {
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- //list_lbltestitems[index].Width = 250;
- //list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- }
- }
-
- }
- private void Lbltestitem_MouseEnter(object sender, MouseEventArgs e)
- {
- int index = int.Parse(((Label)sender).Tag.ToString());
- if(inclusion)
- {
- if (list_lbltestitems[index].Content.ToString().IndexOf(testitems)>-1)
- {
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lbltestitems[index].FontSize = 24;
- // list_lbltestitems[index].Width = 250 + 40;
- }
- else
- {
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(54, 62, 78));
- list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lbltestitems[index].FontSize = 24;
- // list_lbltestitems[index].Width = 250+40;
- }
- }
- else
- {
- if (list_lbltestitems[index].Content.ToString() == testitems)
- {
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lbltestitems[index].FontSize = 24;
- // list_lbltestitems[index].Width = 250 + 40;
- }
- else
- {
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(54, 62, 78));
- list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));
- list_lbltestitems[index].FontSize = 24;
- // list_lbltestitems[index].Width = 250+40;
- }
- }
-
- }
- /// <summary>
- /// 检测项目点击事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void lbltestitems_Click(object sender, MouseButtonEventArgs e)
- {
- testitems_param = "";
- int index = int.Parse(((Label)sender).Tag.ToString());
- for (int i = 0; i < list_lbltestitems.Count; i++)
- {
- list_lbltestitems[i].Foreground = new SolidColorBrush(Colors.White);//字体颜色
- list_lbltestitems[i].Background = null;
- }
- //list_lbltestitems[index].Foreground = new SolidColorBrush(Color.FromRgb(245, 154, 35));//字体颜色
- list_lbltestitems[index].Background = new SolidColorBrush(Color.FromRgb(0x43, 0x4e, 0x61));
- if(inclusion)
- {
- //testitems = "夹杂物评级";
- testitems = list_lbltestitems[index].Content.ToString();
- testitems = testitems.Replace("▼", "");
- testitems = testitems.Replace(" ", "");
- if (Can_Testitems.FindName("inclusion") as Inclusion == null)
- {
- Inclusion temp_inclusion = new Inclusion();
- lincl = temp_inclusion.inclusion;
- temp_inclusion.SetValue(Canvas.TopProperty, Convert.ToDouble(list_lbltestitems[index].GetValue(Canvas.TopProperty)) + list_lbltestitems[index].Height); ;
- temp_inclusion.SetValue(Canvas.LeftProperty, 0.0);
- temp_inclusion.SetValue(Canvas.BottomProperty, double.NaN);
- temp_inclusion.SetValue(Canvas.RightProperty, double.NaN);
- //temp_inclusion.MouseLeave += Inclusion_MouseLeave;
- Can_Testitems.Children.Add(temp_inclusion);
- Can_Testitems.RegisterName("inclusion", temp_inclusion);
- }
- else
- {
- Can_Testitems.Children.Remove(Can_Testitems.FindName("inclusion") as Inclusion);
- Can_Testitems.UnregisterName("inclusion");
- }
- }
- else
- {
- testitems = list_lbltestitems[index].Content.ToString();
- }
-
- string steelid = find_steel_by_steel(steel).Rows[0][0].ToString();
- string stanardid = find_standard_bysteel_id(steelid).Rows[0][0].ToString();
- items = find_testitems(stanardid, testitems).Rows[0][4].ToString();
- if (find_testitems(stanardid, testitems).Rows[0][5].ToString() != "")
- {
- testitems_param = find_testitems(stanardid, testitems).Rows[0][5].ToString();
- }
- IsShowTextInput();
- Console.WriteLine("微电机点击testitems" + testitems_param);
- Console.WriteLine("点击testitems" + testitems);
- Console.WriteLine("点击Items" + items);
- }
- //private void Inclusion_MouseLeave(object sender, MouseEventArgs e)
- //{
- // Can_Testitems.Children.Remove(Can_Testitems.FindName("inclusion") as Inclusion);
- // Can_Testitems.UnregisterName("inclusion");
- //}
- /// <summary>
- /// 根据评级标准与检验项目返回一条记录
- /// </summary>
- private DataTable find_testitems(string standard_id, string testitem)
- {
- DataTable ds = new DataTable();
- try
- {
- SQLiteDataAdapter dat = new SQLiteDataAdapter("select * from t_testitems WHERE opt_standard='" + standard_id + "'and opt_testitem='" + testitem + "' and Isshow=1", conn);
- dat.Fill(ds);
- }
- catch (Exception e)
- {
- System.Windows.MessageBox.Show(e.Message, "错误", MessageBoxButton.OK, MessageBoxImage.Error);
- }
- return ds;
- }
- /// <summary>
- /// 是否显示录入按钮
- /// </summary>
- private void IsShowTextInput()
- {
- if (standard != "" && testitems != "")
- {
- txtinput.Visibility = Visibility.Visible;
- }
- else
- {
- txtinput.Visibility = Visibility.Hidden;
- //MessageBox.Show("请选择评级标准和检验项目");
- }
- if (ShowpageEvent != null)
- {
- ShowpageEvent(testitems);
- }
- }
- /// <summary>
- /// 录入试样信息
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void Input_sample_information(object sender, MouseButtonEventArgs e)
- {
- if (standard != "" && testitems != "")
- {
- Sample_Information_Enter sample = new Sample_Information_Enter();
- //sample.Owner = this;
- HwndSource winformWindow = (HwndSource.FromDependencyObject(this) as HwndSource);
- if (winformWindow != null)
- new WindowInteropHelper(sample) { Owner = winformWindow.Handle };
- sample.input_Inspection_project.Content = standard + " " + testitems;
- sample.ShowDialog();
- }
- else
- {
- MessageBox.Show("请选择评级标准和检验项目");
- }
- }
- }
- }
|