|
|
using CommonFunc;
|
|
|
using CommonFunc.Tools;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Data;
|
|
|
using System.Diagnostics;
|
|
|
using System.Globalization;
|
|
|
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;
|
|
|
|
|
|
namespace XGL.Views
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// Classes.xaml 的交互逻辑
|
|
|
/// </summary>
|
|
|
public partial class Classes : Window
|
|
|
{
|
|
|
string deviceCode = Utils.GetAppSetting("DeviceCode");
|
|
|
FormingMachineService formingMachineService = new FormingMachineService();
|
|
|
DataTable table =new DataTable();
|
|
|
public Classes()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
//if (LoginUser.ShiftCode=="2")
|
|
|
//{
|
|
|
// var shi = formingMachineService.selectShiftsInfo(deviceCode, ((DateTime.ParseExact(LoginUser.WorkDate, "yyyy-MM-dd", CultureInfo.InvariantCulture)).AddDays(-1)).ToString("yyyy-MM-dd"),"2");
|
|
|
// if (shi != null && shi.Rows.Count > 0)
|
|
|
// {
|
|
|
// table = shi;
|
|
|
// // 遍历 DataTable 的每一行
|
|
|
// foreach (DataRow row in shi.Rows)
|
|
|
// {
|
|
|
// // 获取 shift_code 的值
|
|
|
// var shiftCode = row["shift_code"].ToString();
|
|
|
|
|
|
// // 根据 shift_code 的值设置 shift.Content
|
|
|
// if (shiftCode == "5")
|
|
|
// {
|
|
|
// shift.Content = "白班";
|
|
|
// }
|
|
|
// else if (shiftCode == "2")
|
|
|
// {
|
|
|
// shift.Content = "夜班";
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// shift.Content = "无";
|
|
|
// }
|
|
|
//}
|
|
|
//else
|
|
|
//{
|
|
|
// var shi = formingMachineService.selectShiftsInfo1(deviceCode, LoginUser.WorkDate);
|
|
|
// // 检查 DataTable 是否为空
|
|
|
// if (shi != null && shi.Rows.Count > 0)
|
|
|
// {
|
|
|
// table = shi;
|
|
|
// // 遍历 DataTable 的每一行
|
|
|
// foreach (DataRow row in shi.Rows)
|
|
|
// {
|
|
|
// // 获取 shift_code 的值
|
|
|
// var shiftCode = row["shift_code"].ToString();
|
|
|
|
|
|
// // 根据 shift_code 的值设置 shift.Content
|
|
|
// if (shiftCode == "5")
|
|
|
// {
|
|
|
// shift.Content = "白班";
|
|
|
// }
|
|
|
// else if (shiftCode == "2")
|
|
|
// {
|
|
|
// shift.Content = "夜班";
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// else
|
|
|
// {
|
|
|
// shift.Content = "无";
|
|
|
// // 处理 DataTable 为空的情况
|
|
|
// Console.WriteLine("未找到班次信息。");
|
|
|
// }
|
|
|
//}
|
|
|
}
|
|
|
|
|
|
private void Button_Click(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
var shi= formingMachineService.selectShiftsInfo(deviceCode, LoginUser.WorkDate, LoginUser.ShiftCode);
|
|
|
if (shi==null)
|
|
|
{
|
|
|
formingMachineService.ChangeShiftsInfo(deviceCode);
|
|
|
CustomMessageBox.Show("开始工作吧~", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success, 1500);
|
|
|
return;
|
|
|
}
|
|
|
if (shi.Rows.Count>0)
|
|
|
{
|
|
|
CustomMessageBox.Show("检测到有正在上班的班次,请先下班!!!!", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Warning);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
formingMachineService.ChangeShiftsInfo(deviceCode);
|
|
|
CustomMessageBox.Show("开始工作吧~", CustomMessageBoxButton.OK, CustomMessageBoxIcon.Success,1500);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private void Button_Click_1(object sender, RoutedEventArgs e)
|
|
|
{
|
|
|
if (CustomMessageBox.Show("下班后产量会计入下一班次,您确定要下班吗?", CustomMessageBoxButton.OKCancel, CustomMessageBoxIcon.Warning) == CustomMessageBoxResult.OK)
|
|
|
{
|
|
|
formingMachineService.ChangeShiftsInfo(deviceCode, LoginUser.WorkDate, LoginUser.ShiftCode);
|
|
|
//因为程序多开受限制,先启动一个中间程序,再启动本程序
|
|
|
//设置要启动的应用程序名称和参数
|
|
|
string appName = "RestartApp.exe"; // 替换为你的目标控制台应用程序的名称
|
|
|
string appArguments = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;//sresu;// 替换为你的应用程序需要的参数
|
|
|
|
|
|
// 创建进程启动信息
|
|
|
ProcessStartInfo startInfo = new ProcessStartInfo
|
|
|
{
|
|
|
FileName = appName,
|
|
|
Arguments = appArguments,
|
|
|
RedirectStandardOutput = false, // 可以选择是否重定向标准输出
|
|
|
UseShellExecute = false, // 必须设置为false,以便在控制台中启动应用程序
|
|
|
CreateNoWindow = false // 设置为true,以便在后台启动应用程序
|
|
|
};
|
|
|
|
|
|
// 创建并启动进程
|
|
|
Process process = new Process
|
|
|
{
|
|
|
StartInfo = startInfo
|
|
|
};
|
|
|
process.Start();
|
|
|
Environment.Exit(0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|