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
{
///
/// Page_FirstControl.xaml 的交互逻辑
///
public partial class Page_FirstControl : UserControl
{
//委托事件
public delegate void ShowPage(string testitem);
public static event ShowPage ShowpageEvent;
public Boolean inclusion = false;
public List lincl = new List();
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 incl)
{
lincl = incl;
if (lincl.Count>0)
{
this.txtinput.Visibility = Visibility.Visible;
}
else
{
this.txtinput.Visibility = Visibility.Hidden;
}
if (ShowpageEvent != null)
{
ShowpageEvent(testitems);
}
}
///
/// 装载事件
///
///
///
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 liststeel_id = new List();
List liststandard_id = new List();
List listtestitem_id = new List();
List list_lblsteel = new List();//钢种
List list_lblstandard = new List(); //评级标准
private List list_lbltestitems = new List();//检验项目
public string steel;
public string standard;
public string testitems;
public string catagory;
public string items;
public string testitems_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();
}
///
/// 初始化时显示钢种
///
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);
}
}
///
/// 鼠标移除钢种后颜色变回
///
///
///
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));
}
}
///
/// 鼠标在移动在钢种上方时有颜色变化
///
///
///
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;
}
}
///
/// 钢种点击事件,选中行变颜色
///
///
///
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();
}
///
/// 根据钢种返回一条记录
///
///
///
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;
}
///
/// 根据钢种显示标准
///
///
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;
}
}
///
/// 评级标准点击事件
///
///
///
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);
}
///
/// 根据标准返回一条记录
///
///
///
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;
}
///
/// 点击标准显示检验项目
///
///
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;
}
}
}
///
/// 检测项目点击事件
///
///
///
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");
//}
///
/// 根据评级标准与检验项目返回一条记录
///
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;
}
///
/// 是否显示录入按钮
///
private void IsShowTextInput()
{
if (standard != "" && testitems != "")
{
txtinput.Visibility = Visibility.Visible;
}
else
{
txtinput.Visibility = Visibility.Hidden;
//MessageBox.Show("请选择评级标准和检验项目");
}
if (ShowpageEvent != null)
{
ShowpageEvent(testitems);
}
}
///
/// 录入试样信息
///
///
///
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("请选择评级标准和检验项目");
}
}
}
}