添加新建页面刷新事件
This commit is contained in:
commit
2c2867ae69
3 files changed
+118
-21
No files matched your search
@@ -9,15 +9,21 @@
|
|||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="900" d:DesignWidth="550">
|
d:DesignHeight="900" d:DesignWidth="550">
|
||||||
<Grid Background="White" Cursor="">
|
<Grid Background="White" Cursor="">
|
||||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,30,0,0" x:Name="comboBoxMachine" VerticalAlignment="Top" Width="270" FontSize="15" IsEditable="True" BorderBrush="#FF673AB7"
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,30,0,0" x:Name="comboBoxMachine" VerticalAlignment="Top" Width="270"
|
||||||
DropDownClosed="comboBoxMachine_DropDownClosed" IsReadOnly="True" />
|
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" DropDownClosed="comboBoxMachine_DropDownClosed" IsReadOnly="True" />
|
||||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,30,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Machine}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,30,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Machine}"
|
||||||
<Button Content="{x:Static lang:Resources.Multi}" Height="35" Margin="450,30,0,0" VerticalAlignment="Top" Width="80" Click="Multi_Click" HorizontalAlignment="Left"/>
|
VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,80,0,0" x:Name="comboBoxProgram" VerticalAlignment="Top" Width="270" FontSize="15" IsEditable="True" BorderBrush="#FF673AB7"
|
<Button Content="{x:Static lang:Resources.Multi}" Height="35" Margin="450,30,0,0" VerticalAlignment="Top" Width="80"
|
||||||
DropDownClosed="comboBoxProgram_DropDownClosed" TextBoxBase.TextChanged="comboBoxProgram_TextChanged"/>
|
Click="Multi_Click" HorizontalAlignment="Left"/>
|
||||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,80,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.process}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,80,0,0" x:Name="comboBoxProgram" VerticalAlignment="Top" Width="270"
|
||||||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,130,0,0" x:Name="comboBoxDyelot" VerticalAlignment="Top" Width="270" FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" />
|
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" DropDownClosed="comboBoxProgram_DropDownClosed"
|
||||||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,130,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Dyelot}" VerticalAlignment="Top" Width="120" FontSize="25"/>
|
TextBoxBase.TextChanged="comboBoxProgram_TextChanged"/>
|
||||||
|
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,80,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.process}"
|
||||||
|
VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||||
|
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,130,0,0" x:Name="comboBoxDyelot" VerticalAlignment="Top" Width="270"
|
||||||
|
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" />
|
||||||
|
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,130,0,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Dyelot}"
|
||||||
|
VerticalAlignment="Top" Width="120" FontSize="25"/>
|
||||||
<DataGrid x:Name="Grid_data" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=90}"
|
<DataGrid x:Name="Grid_data" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=90}"
|
||||||
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
|
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
|
||||||
GridLinesVisibility="All" ColumnHeaderHeight="40" MouseDoubleClick="Grid_data_MouseDoubleClick"
|
GridLinesVisibility="All" ColumnHeaderHeight="40" MouseDoubleClick="Grid_data_MouseDoubleClick"
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
using Newtonsoft.Json.Linq;
|
||||||
|
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
||||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||||
using System;
|
using System;
|
||||||
@@ -17,9 +18,11 @@ using System.Windows.Media;
|
|||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using System.Windows.Navigation;
|
using System.Windows.Navigation;
|
||||||
using System.Windows.Shapes;
|
using System.Windows.Shapes;
|
||||||
|
using System.Xml.Linq;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
|
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
|
||||||
|
using static System.Windows.Forms.AxHost;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.View
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||||
{
|
{
|
||||||
@@ -30,7 +33,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
||||||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
||||||
DataTable ProgramName;
|
DataTable ProgramName = new DataTable();
|
||||||
DataTable dat = new DataTable();
|
DataTable dat = new DataTable();
|
||||||
public ProductionPlanningEdit()
|
public ProductionPlanningEdit()
|
||||||
{
|
{
|
||||||
@@ -68,12 +71,75 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
{
|
{
|
||||||
if(!string.IsNullOrEmpty(e.Groups)) comboBoxMachine.Text = e.Groups;
|
if(!string.IsNullOrEmpty(e.Groups)) comboBoxMachine.Text = e.Groups;
|
||||||
comboBoxDyelot.Text = null;
|
comboBoxDyelot.Text = null;
|
||||||
comboBoxDyelot.IsEnabled = false;
|
comboBoxDyelot.IsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Button_Click(object sender, RoutedEventArgs e)
|
private void Button_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
string[] sArray = Regex.Split(comboBoxMachine.Text, @"\+", RegexOptions.IgnoreCase);
|
||||||
|
if (sArray.Length <= 1)
|
||||||
|
{
|
||||||
|
//单机器信息写入
|
||||||
|
string sTime;
|
||||||
|
string StartTime_;
|
||||||
|
string WorkOrder_ = comboBoxMachine.Text + "_" + DateTime.Now.ToString("yyMMddHHmmss");
|
||||||
|
string ProgramName_ = comboBoxProgram.Text;
|
||||||
|
string ProgramID_ = ProgramName.Select("ProgramName='" + ProgramName_ + "'").
|
||||||
|
First().Field<object>("ProgramID").ToString();
|
||||||
|
string Machines_ = comboBoxMachine.Text;
|
||||||
|
string State_ = "100";
|
||||||
|
string Dyelot_ = comboBoxDyelot.Text;
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
try
|
||||||
|
{
|
||||||
|
sTime = SQLiteHelpers.ExecuteDataSet(
|
||||||
|
"select * from WorkOrder where Machines='" + comboBoxMachine.Text + "' order by EndTime desc", null).
|
||||||
|
Tables[0].Select().First().Field<object>("ProgramID").ToString(); //读取计划表写入缓存
|
||||||
|
if (DateTime.Now < DateTime.Parse(sTime))
|
||||||
|
{
|
||||||
|
StartTime_=DateTime.Parse(sTime).AddMinutes(1).ToString("yy/MM/dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StartTime_= DateTime.Now.AddMinutes(1).ToString("yy/MM/dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
StartTime_= DateTime.Now.AddMinutes(1).ToString("yy/MM/dd HH:mm:ss");
|
||||||
|
}
|
||||||
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
|
|
||||||
|
string Time_ = DateTime.Parse(ProgramName.Select("ProgramName='" + ProgramName_ + "'").
|
||||||
|
First().Field<object>("Time").ToString()).ToString("HH:mm:ss");
|
||||||
|
string EndTime_ = (DateTime.Parse(StartTime_)+ DateTime.Parse(Time_).TimeOfDay).ToString();
|
||||||
|
|
||||||
|
//插入数据信息
|
||||||
|
Dictionary<string, object> WorkOrder_new = new Dictionary<string, object>();//缓存函数
|
||||||
|
WorkOrder_new.Add("StartTime", StartTime_);
|
||||||
|
WorkOrder_new.Add("EndTime", EndTime_);
|
||||||
|
WorkOrder_new.Add("Time", Time_);
|
||||||
|
WorkOrder_new.Add("WorkOrder", WorkOrder_);
|
||||||
|
WorkOrder_new.Add("ProgramName", ProgramName_);
|
||||||
|
WorkOrder_new.Add("ProgramID", ProgramID_);
|
||||||
|
WorkOrder_new.Add("Machines", Machines_);
|
||||||
|
WorkOrder_new.Add("State", State_);
|
||||||
|
WorkOrder_new.Add("Dyelot", Dyelot_);
|
||||||
|
WorkOrder_new.Add("Remark", null);
|
||||||
|
WorkOrder_new.Add("lock", 0);
|
||||||
|
WorkOrder_new.Add("color", null);
|
||||||
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
|
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);// 执行插入
|
||||||
|
SQLiteHelpers.Close(); //关闭连接
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{//多机器载入
|
||||||
|
|
||||||
|
}
|
||||||
|
this.Visibility = Visibility.Collapsed;
|
||||||
|
ProductionPlanningView.UI = true;
|
||||||
}
|
}
|
||||||
private void Button_Quit(object sender, RoutedEventArgs e)//退出
|
private void Button_Quit(object sender, RoutedEventArgs e)//退出
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ using System.Runtime.Serialization;
|
|||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using SkiaSharp;
|
using SkiaSharp;
|
||||||
|
using System.Windows.Threading;
|
||||||
|
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.View
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||||
@@ -55,6 +56,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new ProductionPlanningModel();
|
DataContext = new ProductionPlanningModel();
|
||||||
Sdatepicker.Language = XmlLanguage.GetLanguage(Configini.IniReadvalue("SYS", "Language"));
|
Sdatepicker.Language = XmlLanguage.GetLanguage(Configini.IniReadvalue("SYS", "Language"));
|
||||||
|
CountDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
private readonly UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "SCCM.ini");
|
||||||
@@ -80,7 +82,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ObservableCollection<ContextMenuItem> ganttTaskContextMenuItems = new ObservableCollection<ContextMenuItem>();
|
private ObservableCollection<ContextMenuItem> ganttTaskContextMenuItems = new ObservableCollection<ContextMenuItem>();
|
||||||
private void GanttChartNEW()
|
public void GanttChartNEW()
|
||||||
{
|
{
|
||||||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
||||||
SQLiteHelpers.Open(); //打开数据库
|
SQLiteHelpers.Open(); //打开数据库
|
||||||
@@ -94,27 +96,26 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
GanttChart.Initialize(minDate, maxDate);
|
GanttChart.Initialize(minDate, maxDate);
|
||||||
var gridLineTimeLine = GanttChart.CreateTimeLine(new PeriodDaySplitter(minDate, maxDate), FormatDay);
|
var gridLineTimeLine = GanttChart.CreateTimeLine(new PeriodDaySplitter(minDate, maxDate), FormatDay);
|
||||||
GanttChart.CreateTimeLine(new PeriodHourSplitter(minDate, maxDate), FormatHour);
|
GanttChart.CreateTimeLine(new PeriodHourSplitter(minDate, maxDate), FormatHour);
|
||||||
|
|
||||||
// Set the timeline to atatch gridlines to
|
// Set the timeline to atatch gridlines to
|
||||||
GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground);
|
GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground);
|
||||||
var rowgroup = GanttChart.CreateGanttRowGroup();
|
var rowgroup = GanttChart.CreateGanttRowGroup();
|
||||||
|
|
||||||
//生成表信息
|
//生成表信息
|
||||||
List<string> Chart_machines = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换列名为机台
|
List<string> Chart_machines = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换列名为机台
|
||||||
for (int i= 0; i<Chart_machines.Count(); i++)//列表机台号
|
for (int i = 0; i < Chart_machines.Count(); i++)//列表机台号
|
||||||
{
|
{
|
||||||
var row = GanttChart.CreateGanttRow(rowgroup, Chart_machines[i]);
|
var row = GanttChart.CreateGanttRow(rowgroup, Chart_machines[i]);
|
||||||
DataRow[] dataRows = WorkOrder.Select("Machines='"+ Chart_machines[i]+"'");
|
DataRow[] dataRows = WorkOrder.Select("Machines='" + Chart_machines[i] + "'");
|
||||||
|
|
||||||
for (int j = 0; j < dataRows.Count(); j++) //列表排程
|
for (int j = 0; j < dataRows.Count(); j++) //列表排程
|
||||||
{
|
{
|
||||||
// if(string.IsNullOrEmpty(dataRows[j].Field<string>("color")))
|
GanttChart.AddGanttTask(row, new GanttTask()
|
||||||
|
{
|
||||||
GanttChart.AddGanttTask(row, new GanttTask() {
|
|
||||||
Start = DateTime.Parse(dataRows[j].Field<string>("StartTime")),
|
Start = DateTime.Parse(dataRows[j].Field<string>("StartTime")),
|
||||||
End = DateTime.Parse(dataRows[j].Field<string>("EndTime")),
|
End = DateTime.Parse(dataRows[j].Field<string>("EndTime")),
|
||||||
Name = Properties.Resources.ProcessName +";"+ dataRows[j].Field<string>("ProgramName"),
|
Name = Properties.Resources.ProcessName + ";" + dataRows[j].Field<string>("ProgramName"),
|
||||||
TaskProgressVisibility = System.Windows.Visibility.Hidden });
|
TaskProgressVisibility = System.Windows.Visibility.Hidden
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}//创建日程图
|
}//创建日程图
|
||||||
@@ -174,25 +175,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}
|
}
|
||||||
private void WorkOrderNumder_Click(object sender, RoutedEventArgs e)
|
private void WorkOrderNumder_Click(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
Picture.Width = 0;
|
||||||
// Select_WorkOrderNumder.Text;
|
// Select_WorkOrderNumder.Text;
|
||||||
}
|
}
|
||||||
private void ListViewItem_Before(object sender, MouseButtonEventArgs e)//前一天
|
private void ListViewItem_Before(object sender, MouseButtonEventArgs e)//前一天
|
||||||
{
|
{
|
||||||
|
Picture.Width = 0;
|
||||||
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(-1).ToString("yyyy/MM/dd");
|
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(-1).ToString("yyyy/MM/dd");
|
||||||
}
|
}
|
||||||
private void ListViewItem_Today(object sender, MouseButtonEventArgs e)//今天
|
private void ListViewItem_Today(object sender, MouseButtonEventArgs e)//今天
|
||||||
{
|
{
|
||||||
|
Picture.Width = 0;
|
||||||
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
|
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
|
||||||
}
|
}
|
||||||
private void ListViewItem_DayAfter(object sender, MouseButtonEventArgs e)//后一天
|
private void ListViewItem_DayAfter(object sender, MouseButtonEventArgs e)//后一天
|
||||||
{
|
{
|
||||||
|
Picture.Width = 0;
|
||||||
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd");
|
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd");
|
||||||
}
|
}
|
||||||
private void Sdatepicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)//时间控件
|
private void Sdatepicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)//时间控件
|
||||||
{
|
{
|
||||||
|
Picture.Width = 0;
|
||||||
minDate = DateTime.Parse(sender.ToString());
|
minDate = DateTime.Parse(sender.ToString());
|
||||||
maxDate = DateTime.Parse(sender.ToString()).AddDays(1);
|
maxDate = DateTime.Parse(sender.ToString()).AddDays(1);
|
||||||
GanttChartNEW();
|
GanttChartNEW();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void CountDown()
|
||||||
|
{
|
||||||
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||||
|
{
|
||||||
|
Interval = TimeSpan.FromSeconds(1)//秒
|
||||||
|
};
|
||||||
|
timer1s.Tick += Tick_Event_1S;
|
||||||
|
timer1s.Start();
|
||||||
|
}
|
||||||
|
public static bool UI;
|
||||||
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
|
{
|
||||||
|
if (UI)
|
||||||
|
{
|
||||||
|
GanttChartNEW();
|
||||||
|
UI= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user