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 XGL.Data.DBService; using XGL.Models; namespace XGLFinishPro.Views { /// /// AddReportFrom.xaml 的交互逻辑 /// public partial class AddReportFrom : Window { FormingMachineService formingMachineService = new FormingMachineService(); string type; report report; public AddReportFrom(string type, report report = null) { InitializeComponent(); this.type = type; this.report = report; } private void TextBox_GotFocus(object sender, RoutedEventArgs e) { if (sender is TextBox tb) { if (FindName(tb.Name + 'C') is RadioButton rb && rb.IsChecked == true) { MessageBoxResult messageBoxResult = MessageBox.Show("已选择点检结果是否继续输入异常实际情况?", "提示", MessageBoxButton.OK, MessageBoxImage.Information); if (messageBoxResult == MessageBoxResult.OK) { rb.IsChecked = false; } } else if (FindName(tb.Name + 'W') is RadioButton rb2 && rb2.IsChecked == true) { MessageBoxResult messageBoxResult = MessageBox.Show("已选择点检结果是否继续输入异常实际情况?", "提示", MessageBoxButton.OK, MessageBoxImage.Information); if (messageBoxResult == MessageBoxResult.OK) { rb2.IsChecked = false; } } } } private void AddButton_Click(object sender, RoutedEventArgs e) { if (report == null || string.IsNullOrEmpty(report.Id)) { report = new report { Id = Guid.NewGuid().ToString(), CreateTime = DateTime.Now, team = LoginPage.team }; } #region 赋值 if (!string.IsNullOrEmpty(this.clear.Text)) { report.clear = this.clear.Text; } else if (this.clearC.IsChecked == true) { report.clear = "√"; } else if (this.clearW.IsChecked == true) { report.clear = "×"; } if (!string.IsNullOrEmpty(this.equipStatus.Text)) { report.equipStatus = this.equipStatus.Text; } else if (this.equipStatusC.IsChecked == true) { report.equipStatus = "√"; } else if (this.equipStatusW.IsChecked == true) { report.equipStatus = "×"; } if (!string.IsNullOrEmpty(this.isClear.Text)) { report.isClear = this.isClear.Text; } else if (this.isClearC.IsChecked == true) { report.isClear = "√"; } else if (this.isClearW.IsChecked == true) { report.isClear = "×"; } if (!string.IsNullOrEmpty(this.isLineClear.Text)) { report.isLineClear = this.isLineClear.Text; } else if (this.isLineClearC.IsChecked == true) { report.isLineClear = "√"; } else if (this.isLineClearW.IsChecked == true) { report.isLineClear = "×"; } if (!string.IsNullOrEmpty(this.lineClear.Text)) { report.lineClear = this.lineClear.Text; } else if (this.lineClearC.IsChecked == true) { report.lineClear = "√"; } else if (this.lineClearW.IsChecked == true) { report.lineClear = "×"; } if (!string.IsNullOrEmpty(this.residue.Text)) { report.residue = this.residue.Text; } else if (this.residueC.IsChecked == true) { report.residue = "√"; } else if (this.residueW.IsChecked == true) { report.residue = "×"; } if (!string.IsNullOrEmpty(this.StampCorrect.Text)) { report.StampCorrect = this.StampCorrect.Text; } else if (this.StampCorrectC.IsChecked == true) { report.StampCorrect = "√"; } else if (this.StampCorrectW.IsChecked == true) { report.StampCorrect = "×"; } if (!string.IsNullOrEmpty(this.unqualified.Text)) { report.unqualified = this.unqualified.Text; } else if (this.unqualifiedC.IsChecked == true) { report.unqualified = "√"; } else if (this.unqualifiedW.IsChecked == true) { report.unqualified = "×"; } if (!string.IsNullOrEmpty(this.UserKnow.Text)) { report.UserKnow = this.UserKnow.Text; } else if (this.UserKnowC.IsChecked == true) { report.UserKnow = "√"; } else if (this.UserKnowW.IsChecked == true) { report.UserKnow = "×"; } if (!string.IsNullOrEmpty(this.qualified.Text)) { report.qualified = this.qualified.Text; } else if (this.qualifiedC.IsChecked == true) { report.qualified = "√"; } else if (this.qualifiedW.IsChecked == true) { report.qualified = "×"; } if (!string.IsNullOrEmpty(this.positionCorrect.Text)) { report.positionCorrect = this.positionCorrect.Text; } else if (this.positionCorrectC.IsChecked == true) { report.positionCorrect = "√"; } else if (this.positionCorrectW.IsChecked == true) { report.positionCorrect = "×"; } if (this.OpenLine.IsChecked == true) { report.OpenLineCheckBox = "√"; } else { report.OpenLineCheckBox = "×"; } if (this.ReplaceLine.IsChecked == true) { report.ReplaceLineCheckBox = "√"; } else { report.ReplaceLineCheckBox = "×"; } #endregion if (this.type == "Add") { if (formingMachineService.AddReport(report) > 0) { MessageBox.Show("新增成功!"); this.Close(); } else { MessageBox.Show("新增失败!"); report = null; } } else { if (formingMachineService.EditReport(report) > 0) { MessageBox.Show("修改成功!"); this.Close(); } else { MessageBox.Show("修改失败!"); } } } private void CloseButton_Click(object sender, RoutedEventArgs e) { this.Close(); } private void Window_Loaded(object sender, RoutedEventArgs e) { if (this.type == "Add") { this.WindowTitle.Text = "新增点检记录"; } else { this.WindowTitle.Text = "修改点检记录"; if (report.clear == "√") { this.clearC.IsChecked = true; } else if (report.clear == "×") { this.clearW.IsChecked = true; } else { this.clear.Text = report.clear; } if (report.equipStatus == "√") { this.equipStatusC.IsChecked = true; } else if (report.equipStatus == "×") { this.equipStatusW.IsChecked = true; } else { this.equipStatus.Text = report.equipStatus; } if (report.isClear == "√") { this.isClearC.IsChecked = true; } else if (report.isClear == "×") { this.isClearW.IsChecked = true; } else { this.isClear.Text = report.isClear; } if (report.isLineClear == "√") { this.isLineClearC.IsChecked = true; } else if (report.isLineClear == "×") { this.isLineClearW.IsChecked = true; } else { this.isLineClear.Text = report.isLineClear; } if (report.lineClear == "√") { this.lineClearC.IsChecked = true; } else if (report.lineClear == "×") { this.lineClearW.IsChecked = true; } else { this.lineClear.Text = report.lineClear; } if (report.residue == "√") { this.residueC.IsChecked = true; } else if (report.residue == "×") { this.residueW.IsChecked = true; } else { this.residue.Text = report.residue; } if (report.StampCorrect == "√") { this.StampCorrectC.IsChecked = true; } else if (report.StampCorrect == "×") { this.StampCorrectW.IsChecked = true; } else { this.StampCorrect.Text = report.StampCorrect; } if (report.unqualified == "√") { this.unqualifiedC.IsChecked = true; } else if (report.unqualified == "×") { this.unqualifiedW.IsChecked = true; } else { this.unqualified.Text = report.unqualified; } if (report.UserKnow == "√") { this.UserKnowC.IsChecked = true; } else if (report.UserKnow == "×") { this.UserKnowW.IsChecked = true; } else { this.UserKnow.Text = report.UserKnow; } if (report.qualified == "√") { this.qualifiedC.IsChecked = true; } else if (report.qualified == "×") { this.qualifiedW.IsChecked = true; } else { this.qualified.Text = report.qualified; } if (report.positionCorrect == "√") { this.positionCorrectC.IsChecked = true; } else if (report.positionCorrect == "×") { this.positionCorrectW.IsChecked = true; } else { this.positionCorrect.Text = report.positionCorrect; } if (report.OpenLineCheckBox == "√") { this.OpenLine.IsChecked = true; } else if (report.ReplaceLineCheckBox == "√") { this.ReplaceLine.IsChecked = true; } } } } }