From a93724a4eb32eb212f2cd6bb347e8d14cd716ee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83?= <15095123350@163.com> Date: Mon, 12 Aug 2024 11:16:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8A=A5=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shangjian/XGL/LoginPage.xaml.cs | 2 +- shangjian/XGL/Views/LanJu_Operator.xaml | 2 +- shangjian/XGLFinishPro/LoginPage.xaml.cs | 8 +- .../XGLFinishPro/Views/AddReportFrom.xaml | 180 ++++++++ .../XGLFinishPro/Views/AddReportFrom.xaml.cs | 402 ++++++++++++++++++ .../XGLFinishPro/Views/LanJu_Operator.xaml | 27 +- .../XGLFinishPro/Views/LanJu_Operator.xaml.cs | 6 +- shangjian/XGLFinishPro/Views/ReportForm.xaml | 321 ++++++++++++++ .../XGLFinishPro/Views/ReportForm.xaml.cs | 314 ++++++++++++++ shangjian/XGLFinishPro/XGLFinishPro.csproj | 14 + 10 files changed, 1265 insertions(+), 11 deletions(-) create mode 100644 shangjian/XGLFinishPro/Views/AddReportFrom.xaml create mode 100644 shangjian/XGLFinishPro/Views/AddReportFrom.xaml.cs create mode 100644 shangjian/XGLFinishPro/Views/ReportForm.xaml create mode 100644 shangjian/XGLFinishPro/Views/ReportForm.xaml.cs diff --git a/shangjian/XGL/LoginPage.xaml.cs b/shangjian/XGL/LoginPage.xaml.cs index 0758efc..bb987ff 100644 --- a/shangjian/XGL/LoginPage.xaml.cs +++ b/shangjian/XGL/LoginPage.xaml.cs @@ -54,7 +54,7 @@ namespace XGL //this.Hide(); //Main mainWindow = new Main(); //mainWindow.Show(); - //InitVersion(); + InitVersion(); //InitTeamInfo(); InitShiftInfo(); } diff --git a/shangjian/XGL/Views/LanJu_Operator.xaml b/shangjian/XGL/Views/LanJu_Operator.xaml index b25708e..2e4cb88 100644 --- a/shangjian/XGL/Views/LanJu_Operator.xaml +++ b/shangjian/XGL/Views/LanJu_Operator.xaml @@ -446,7 +446,7 @@ Background="#F2F3F5" Grid.Row="0" Grid.Column="9" > - + + + + + diff --git a/shangjian/XGLFinishPro/Views/AddReportFrom.xaml.cs b/shangjian/XGLFinishPro/Views/AddReportFrom.xaml.cs new file mode 100644 index 0000000..332ce3e --- /dev/null +++ b/shangjian/XGLFinishPro/Views/AddReportFrom.xaml.cs @@ -0,0 +1,402 @@ +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; + } + } + } + } +} diff --git a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml index fec8ff7..eb87827 100644 --- a/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml +++ b/shangjian/XGLFinishPro/Views/LanJu_Operator.xaml @@ -37,9 +37,9 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/shangjian/XGLFinishPro/Views/ReportForm.xaml.cs b/shangjian/XGLFinishPro/Views/ReportForm.xaml.cs new file mode 100644 index 0000000..0a47eea --- /dev/null +++ b/shangjian/XGLFinishPro/Views/ReportForm.xaml.cs @@ -0,0 +1,314 @@ +using CommonFunc.Tools; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Timers; +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 +{ + /// + /// ReportForm.xaml 的交互逻辑 + /// + public partial class ReportForm : Window + { + /// + /// 数据库交互 + /// + FormingMachineService formingMachineService = new FormingMachineService(); + private report editReport; + private List reports; + private Timer timer; + private readonly string OpenLineCheckBox = "OpenLineCheckBox"; + private readonly string ReplaceLineCheckBox = "ReplaceLineCheckBox"; + /// + /// 上一任务不良品是否处理并放置在不合格品区域 + /// + private readonly string unqualified = "unqualified"; + /// + /// 涉及内容物转换,上一任务内容物是否清理干净 + /// + private readonly string clear = "clear"; + /// + /// 上一任务剩余包材/内容物是否做好防护、标识并放在指定位置 + /// + private readonly string residue = "residue"; + /// + /// 流水线是否清理干净,无与当班次生产无关的东西存处 + /// + private readonly string lineClear = "lineClear"; + /// + /// 作业员是否清楚当班次操作 + /// + private readonly string UserKnow = "UserKnow"; + /// + /// 该班次内容物、包材是否符合 + /// + private readonly string qualified = "qualified"; + /// + /// 班次现场使用的设备是否可以正常工作 + /// + private readonly string equipStatus = "equipStatus"; + /// + /// 该班次生产批号是否正确 + /// + private readonly string StampCorrect = "StampCorrect"; + /// + /// 不良品是否处理干净并放置在不合格品区域 + /// + private readonly string isClear = "isClear"; + /// + /// 剩余包材/内容物是否做好防护并放在指定位置 + /// + private readonly string positionCorrect = "positionCorrect"; + /// + /// 流水线是否清理干净 + /// + private readonly string isLineClear = "isLineClear"; + /// + /// 班次 + /// + private readonly string team = "team"; + public ReportForm() + { + InitializeComponent(); + } + + private void Window_Loaded(object sender, RoutedEventArgs e) + { + this.Workshop.Text = string.Empty; + this.line.Text = string.Empty; + this.date.Text = string.Empty; + this.Workshop.Text = Utils.GetAppSetting("SiteCode"); + this.line.Text= Utils.GetAppSetting("LineCode"); + for (int i = 1; i <= 6; i++) + { + if (FindName(team + i) is TextBlock text11) + { + text11.Text = string.Empty; + } + if (FindName(unqualified + i) is TextBlock text) + { + text.Text = string.Empty; + } + if (FindName(clear + i) is TextBlock text1) + { + text1.Text = string.Empty; + } + if (FindName(residue + i) is TextBlock text2) + { + text2.Text = string.Empty; + } + if (FindName(lineClear + i) is TextBlock text3) + { + text3.Text = string.Empty; + } + if (FindName(UserKnow + i) is TextBlock text4) + { + text4.Text = string.Empty; + } + if (FindName(qualified + i) is TextBlock text5) + { + text5.Text = string.Empty; + } + if (FindName(equipStatus + i) is TextBlock text6) + { + text6.Text = string.Empty; + } + if (FindName(StampCorrect + i) is TextBlock text7) + { + text7.Text = string.Empty; + } + if (FindName(isClear + i) is TextBlock text8) + { + text8.Text = string.Empty; + } + if (FindName(positionCorrect + i) is TextBlock text9) + { + text9.Text = string.Empty; + } + if (FindName(isLineClear + i) is TextBlock text10) + { + text10.Text = string.Empty; + } + } + + GetData(); + + timer = new Timer(10000); + timer.Elapsed += Timer_Elapsed; + timer.Start(); + } + + private void Timer_Elapsed(object sender, ElapsedEventArgs e) + { + GetData(); + } + + private void GetData() + { + try + { + reports = formingMachineService.GetReportData(); + Dispatcher.Invoke(() => + { + this.date.Text = DateTime.Now.ToString("yyyy-MM-dd"); + for (int i = 0; i < reports.Count; i++) + { + if (FindName(unqualified + (i + 1)) is TextBlock text) + { + text.Text = reports[i].unqualified; + } + if (FindName(clear + (i + 1)) is TextBlock text1) + { + text1.Text = reports[i].clear; + } + if (FindName(residue + (i + 1)) is TextBlock text2) + { + text2.Text = reports[i].residue; + } + if (FindName(lineClear + (i + 1)) is TextBlock text3) + { + text3.Text = reports[i].lineClear; + } + if (FindName(UserKnow + (i + 1)) is TextBlock text4) + { + text4.Text = reports[i].UserKnow; + } + if (FindName(qualified + (i + 1)) is TextBlock text5) + { + text5.Text = reports[i].qualified; + } + if (FindName(equipStatus + (i + 1)) is TextBlock text6) + { + text6.Text = reports[i].equipStatus; + } + if (FindName(StampCorrect + (i + 1)) is TextBlock text7) + { + text7.Text = reports[i].StampCorrect; + } + if (FindName(isClear + (i + 1)) is TextBlock text8) + { + text8.Text = reports[i].isClear; + } + if (FindName(positionCorrect + (i + 1)) is TextBlock text9) + { + text9.Text = reports[i].positionCorrect; + } + if (FindName(isLineClear + (i + 1)) is TextBlock text10) + { + text10.Text = reports[i].isLineClear; + } + if (FindName(team + (i + 1)) is TextBlock text11) + { + text11.Text = reports[i].team == "2" ? "夜班" : "白班"; + } + if (FindName(OpenLineCheckBox + (i + 1)) is CheckBox checkBox) + { + checkBox.IsChecked = (reports[i].OpenLineCheckBox == "√"); + } + if (FindName(ReplaceLineCheckBox + (i + 1)) is CheckBox checkBox1) + { + checkBox1.IsChecked = (reports[i].ReplaceLineCheckBox == "√"); + } + } + }); + } + catch + { + + } + } + + private void Add_Click(object sender, RoutedEventArgs e) + { + new AddReportFrom("Add").ShowDialog(); + GetData(); + } + + private void Close_Click(object sender, RoutedEventArgs e) + { + this.Close(); + } + + private void Edit_Click(object sender, RoutedEventArgs e) + { + new AddReportFrom("Edit", editReport).ShowDialog(); + GetData(); + } + + private void ContextMenu_Opened(object sender, RoutedEventArgs e) + { + //获取鼠标位置 + Point mousePosition = Mouse.GetPosition(this); + Point top = this.TopLine.TransformToVisual(this).Transform(new Point(0, this.TopLine.Y1)); + Point bottom = this.BottomLine.TransformToVisual(this).Transform(new Point(0, this.BottomLine.Y1)); + if (mousePosition.Y > top.Y && mousePosition.Y < bottom.Y) + { + Point firstPoint = this.FirstLine.TransformToVisual(this).Transform(new Point(this.FirstLine.X1, 0)); + Point secondPoint = this.SecondLine.TransformToVisual(this).Transform(new Point(this.SecondLine.X1, 0)); + Point thirdLine = this.ThirdLine.TransformToVisual(this).Transform(new Point(this.ThirdLine.X1, 0)); + Point fourthLine = this.FourthLine.TransformToVisual(this).Transform(new Point(this.FourthLine.X1, 0)); + Point fifthLine = this.FifthLine.TransformToVisual(this).Transform(new Point(this.FifthLine.X1, 0)); + Point sixthLine = this.SixthLine.TransformToVisual(this).Transform(new Point(this.SixthLine.X1, 0)); + Point SeventhLine = this.SixthLine.TransformToVisual(this).Transform(new Point(this.SeventhLine.X1, 0)); + if (mousePosition.X > firstPoint.X && mousePosition.X < SeventhLine.X) + { + this.EditButton.Visibility = Visibility.Visible; + if (mousePosition.X > firstPoint.X && mousePosition.X < secondPoint.X) + { + editReport = reports[0]; + } + else if (mousePosition.X > secondPoint.X && mousePosition.X < thirdLine.X) + { + editReport = reports[1]; + } + else if (mousePosition.X > thirdLine.X && mousePosition.X < fourthLine.X) + { + editReport = reports[2]; + } + else if (mousePosition.X > fourthLine.X && mousePosition.X < fifthLine.X) + { + editReport = reports[3]; + } + else if (mousePosition.X > fifthLine.X && mousePosition.X < sixthLine.X) + { + editReport = reports[4]; + } + else if (mousePosition.X > sixthLine.X && mousePosition.X < SeventhLine.X) + { + editReport = reports[5]; + } + if (string.IsNullOrEmpty(editReport.Id)) + { + this.EditButton.Visibility = Visibility.Collapsed; + } + } + else + { + this.EditButton.Visibility = Visibility.Collapsed; + } + } + else + { + this.EditButton.Visibility = Visibility.Collapsed; + } + } + + private void Window_Closed(object sender, EventArgs e) + { + timer.Stop(); + } + } +} diff --git a/shangjian/XGLFinishPro/XGLFinishPro.csproj b/shangjian/XGLFinishPro/XGLFinishPro.csproj index c848b3c..4d8aa7e 100644 --- a/shangjian/XGLFinishPro/XGLFinishPro.csproj +++ b/shangjian/XGLFinishPro/XGLFinishPro.csproj @@ -406,6 +406,9 @@ UCUserList.xaml + + AddReportFrom.xaml + ExecReportWorkWin.xaml @@ -430,6 +433,9 @@ QitaoLvUC.xaml + + ReportForm.xaml + ShouPeiWin.xaml @@ -660,6 +666,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + MSBuild:Compile Designer @@ -692,6 +702,10 @@ Designer MSBuild:Compile + + MSBuild:Compile + Designer + Designer MSBuild:Compile