123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- 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.Shapes;
- using System.IO;
- using System.Data.SQLite;
- using System.Data;
- namespace AIRS
- {
- /// <summary>
- /// FeildParam.xaml 的交互逻辑
- /// </summary>
- public partial class FeildParam : Window
- {
- public string standard = "";
- public string ret_shape = "";
- public double ret_dia = 0;
- public int ret_mul = 0;
- private string path = Directory.GetCurrentDirectory(); //程序工作目录
- System.Data.SQLite.SQLiteConnection conn = new System.Data.SQLite.SQLiteConnection();
- System.Data.SQLite.SQLiteConnectionStringBuilder connstr = new System.Data.SQLite.SQLiteConnectionStringBuilder();
- private string _shape = "";
- private string _diameter = "";
- private string _multiple = "";
- public FeildParam()
- {
- InitializeComponent();
- }
- private void rdb_circle_Checked(object sender, RoutedEventArgs e)
- {
- _shape = "Circle";
- }
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
- connstr.DataSource = path + "\\datas.db";
- conn.ConnectionString = connstr.ToString();
- conn.Open();
- System.Data.SQLite.SQLiteDataAdapter da = new SQLiteDataAdapter("select * from t_standard where opt_standard='" + standard + "'", conn);
- DataTable ds = new DataTable();
- da.Fill(ds);
- if(ds.Rows.Count>0)
- {
- if(ds.Rows[0][2].ToString().Substring(0,2)=="GB" && ds.Rows[0][4]!= DBNull.Value)
- {
- _shape = ds.Rows[0][4].ToString();
- if(_shape=="Circle")
- {
- rdb_circle.IsChecked = true;
- }
- else
- {
- rdb_rect.IsChecked = true;
- }
- _diameter = ds.Rows[0][5].ToString();
- String[] dia = _diameter.Split(',');
- foreach(string dd in dia)
- {
- ComboBoxItem cbbi = new ComboBoxItem();
- cbbi.Content = dd;
- cbbdiameter.Items.Add(cbbi);
- }
- cbbdiameter.SelectedIndex = 0;
- _multiple = ds.Rows[0][6].ToString();
- String[] mul = _multiple.Split(',');
- foreach (string mull in mul)
- {
- ComboBoxItem cbbi = new ComboBoxItem();
- cbbi.Content = mull;
- cbbmultiple.Items.Add(cbbi);
- }
- cbbmultiple.SelectedIndex = 0;
- }
- else
- {
- ComboBoxItem comboBox = new ComboBoxItem();
- comboBox.Content = "70";
- cbbdiameter.Items.Add(comboBox);
- comboBox = new ComboBoxItem();
- comboBox.Content = "80";
- cbbdiameter.Items.Add(comboBox);
- comboBox = new ComboBoxItem();
- comboBox.Content = "100";
- cbbmultiple.Items.Add(comboBox);
- comboBox = new ComboBoxItem();
- comboBox.Content = "500";
- cbbmultiple.Items.Add(comboBox);
- }
- }
- else
- {
- ComboBoxItem comboBox = new ComboBoxItem();
- comboBox.Content = "70";
- cbbdiameter.Items.Add(comboBox);
- comboBox = new ComboBoxItem();
- comboBox.Content = "80";
- cbbdiameter.Items.Add(comboBox);
- comboBox = new ComboBoxItem();
- comboBox.Content = "100";
- cbbmultiple.Items.Add(comboBox);
- comboBox = new ComboBoxItem();
- comboBox.Content = "500";
- cbbmultiple.Items.Add(comboBox);
- }
- }
- private void rdb_rect_Checked(object sender, RoutedEventArgs e)
- {
- _shape = "Rectangle";
- }
- private void BtnExit_Click(object sender, RoutedEventArgs e)
- {
- this.DialogResult = false;
- }
- private void BtnLogin_Click(object sender, RoutedEventArgs e)
- {
- ret_shape = _shape;
- if(!Double.TryParse(cbbdiameter.Text, out ret_dia))
- {
- MessageBox.Show("直径输入错误!", "提示");
- cbbdiameter.Focus();
- return;
- }
- if (!Int32.TryParse(cbbmultiple.Text, out ret_mul))
- {
- MessageBox.Show("放大倍数输入错误!", "提示");
- cbbmultiple.Focus();
- return;
- }
- this.DialogResult = true;
- }
- }
- }
|