//保存信息 private void Save_Click(object sender, RoutedEventArgs e) { //验证信息 if (tb_Cno.Text == "" || tb_Cname.Text == "" || tb_Cphone.Text == "" || tb_Caddr.Text == "") { MessageBox.Show("请输入完整顾客信息", "错误", MessageBoxButton.OK, MessageBoxImage.Error); return; } //顾客信息 Customer customer = new Customer(tb_Cno.Text, tb_Cname.Text, tb_Caddr.Text, tb_Cphone.Text); try { adapter.AddOneCustomer(customer); MessageBox.Show("添加商品成功", "提醒", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show("异常发生,请检查数据库连接或数据是否符合标准", "错误", MessageBoxButton.OK, MessageBoxImage.Error); //写入日志 } }