private void btnSave_Click(object sender, RoutedEventArgs e) { if (_companyname.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入来源单位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_province.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择来源产地(省)!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_city.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择来源产地(市)!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_region.SelectedIndex < 1) { Toolkit.MessageBox.Show("请选择来源产地(区)!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_contacter.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入负责人姓名!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_phone.Text.Trim().Length == 0) { Toolkit.MessageBox.Show("请输入手机!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (_phone.Text.Trim().Length != 11) { Toolkit.MessageBox.Show("手机号必须为11位!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } if (flag == 0) { bool upd = operationContract.UpdateTCompany(_companyname.Text, _phone.Text, (_region.SelectedItem as Label).Tag.ToString(), _contacter.Text, companyId); if (upd) { Toolkit.MessageBox.Show("档案信息更新成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); company.refresh(); this.Close(); return; } else { Toolkit.MessageBox.Show("档案信息更新失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } } else { bool ins = operationContract.AddTCompany(_companyname.Text, (_region.SelectedItem as Label).Tag.ToString(), "1", deptId, PubClass.userInfo.ID, DateTime.Now, _phone.Text, _contacter.Text); if (ins) { Toolkit.MessageBox.Show("档案信息新增成功!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); company.refresh(); this.Close(); return; } else { Toolkit.MessageBox.Show("档案信息新增失败!", "系统提示", MessageBoxButton.OK, MessageBoxImage.Information); return; } } }