Пример #1
0
        private void mould_Search_Click(object sender, RoutedEventArgs e)
        {
            mould  mould   = new mould();
            string content = et3.Text;

            //mould.content = content;
            this.NavigationService.Navigate(mould);
        }
Пример #2
0
        private void mould_Search_Click(object sender, RoutedEventArgs e)
        {
            mould           mould   = new mould();
            string          content = et3.Text;
            MySqlConnection conn    = new MySqlConnection(connectStr);
            string          sql     = string.Format("select * from mould where MD_ID = ('{0}')", content);

            try
            {
                conn.Open();
                MySqlCommand    cmd    = new MySqlCommand(sql, conn);
                MySqlDataReader reader = cmd.ExecuteReader();
                if (reader.Read())
                {
                    mould.id = et3.Text;
                    this.NavigationService.Navigate(mould);
                }
                else
                {
                    MessageBox.Show("您输入的模具号不存在,请重新输入!");
                }
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    MessageBox.Show("连接数据库失败,请联系管理员");
                    break;

                default:
                    MessageBox.Show("无效用户名或密码,请重试");
                    break;
                }
            }
        }