Browse Source

添加新建页面刷新事件

master
sc 10 months ago
parent
commit
2c2867ae69
  1. 24
      View/ProductionPlanningEdit.xaml
  2. 76
      View/ProductionPlanningEdit.xaml.cs
  3. 63
      View/ProductionPlanningView.xaml.cs

24
View/ProductionPlanningEdit.xaml

@ -9,15 +9,21 @@
mc:Ignorable="d"
d:DesignHeight="900" d:DesignWidth="550">
<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"
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"/>
<Button Content="{x:Static lang:Resources.Multi}" Height="35" Margin="450,30,0,0" VerticalAlignment="Top" Width="80" Click="Multi_Click" HorizontalAlignment="Left"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,80,0,0" x:Name="comboBoxProgram" VerticalAlignment="Top" Width="270" FontSize="15" IsEditable="True" BorderBrush="#FF673AB7"
DropDownClosed="comboBoxProgram_DropDownClosed" 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"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,30,0,0" x:Name="comboBoxMachine" VerticalAlignment="Top" Width="270"
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"/>
<Button Content="{x:Static lang:Resources.Multi}" Height="35" Margin="450,30,0,0" VerticalAlignment="Top" Width="80"
Click="Multi_Click" HorizontalAlignment="Left"/>
<ComboBox HorizontalAlignment="Left" Height="30" Margin="150,80,0,0" x:Name="comboBoxProgram" VerticalAlignment="Top" Width="270"
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" DropDownClosed="comboBoxProgram_DropDownClosed"
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}"
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9"
GridLinesVisibility="All" ColumnHeaderHeight="40" MouseDoubleClick="Grid_data_MouseDoubleClick"

76
View/ProductionPlanningEdit.xaml.cs

@ -1,4 +1,5 @@
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using Newtonsoft.Json.Linq;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
using System;
@ -17,9 +18,11 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml.Linq;
using TouchSocket.Core;
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
using static System.Windows.Forms.AxHost;
namespace SunlightCentralizedControlManagement_SCCM_.View
{
@ -30,7 +33,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
{
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
DataTable ProgramName;
DataTable ProgramName = new DataTable();
DataTable dat = new DataTable();
public ProductionPlanningEdit()
{
@ -67,13 +70,76 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
private void Address_Multi_Click(object sender, MachineSelection.AddressUpdateEventArgs e)//机台组返回结果
{
if(!string.IsNullOrEmpty(e.Groups)) comboBoxMachine.Text = e.Groups;
comboBoxDyelot.Text = null;
comboBoxDyelot.IsEnabled = false;
comboBoxDyelot.Text = null;
comboBoxDyelot.IsEnabled = false;
}
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)//退出
{

63
View/ProductionPlanningView.xaml.cs

@ -41,6 +41,7 @@ using System.Runtime.Serialization;
using System.Windows.Markup;
using System.Collections.ObjectModel;
using SkiaSharp;
using System.Windows.Threading;
namespace SunlightCentralizedControlManagement_SCCM_.View
@ -55,6 +56,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
InitializeComponent();
DataContext = new ProductionPlanningModel();
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");
@ -64,7 +66,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
private DateTime minDate;
private DateTime maxDate;
private void UserControl_Loaded(object sender, RoutedEventArgs e)//打开页面时的操作
{
{
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
minDate = DateTime.Now.Date;
maxDate = minDate.AddDays(1);
@ -76,12 +78,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
ganttTaskContextMenuItems.Add(new ContextMenuItem(DeleteClicked, Properties.Resources.Delete + "..."));
GanttChart.GanttTaskContextMenuItems = ganttTaskContextMenuItems;
GanttChartNEW();
}
GanttChartNEW();
}
private ObservableCollection<ContextMenuItem> ganttTaskContextMenuItems = new ObservableCollection<ContextMenuItem>();
private void GanttChartNEW()
{
public void GanttChartNEW()
{
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
SQLiteHelpers.Open(); //打开数据库
WorkOrder = SQLiteHelpers.ExecuteDataSet(
@ -93,28 +95,27 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
GanttChart.ClearGantt();
GanttChart.Initialize(minDate, maxDate);
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
GanttChart.SetGridLinesTimeline(gridLineTimeLine, DetermineBackground);
var rowgroup = GanttChart.CreateGanttRowGroup();
//生成表信息
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]);
DataRow[] dataRows = WorkOrder.Select("Machines='"+ Chart_machines[i]+"'");
DataRow[] dataRows = WorkOrder.Select("Machines='" + Chart_machines[i] + "'");
for (int j = 0; j < dataRows.Count(); j++) //列表排程
{
// if(string.IsNullOrEmpty(dataRows[j].Field<string>("color")))
GanttChart.AddGanttTask(row, new GanttTask() {
Start = DateTime.Parse(dataRows[j].Field<string>("StartTime")),
End = DateTime.Parse(dataRows[j].Field<string>("EndTime")),
Name = Properties.Resources.ProcessName +";"+ dataRows[j].Field<string>("ProgramName"),
TaskProgressVisibility = System.Windows.Visibility.Hidden });
GanttChart.AddGanttTask(row, new GanttTask()
{
Start = DateTime.Parse(dataRows[j].Field<string>("StartTime")),
End = DateTime.Parse(dataRows[j].Field<string>("EndTime")),
Name = Properties.Resources.ProcessName + ";" + dataRows[j].Field<string>("ProgramName"),
TaskProgressVisibility = System.Windows.Visibility.Hidden
});
}
}
}//创建日程图
@ -174,25 +175,49 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
private void WorkOrderNumder_Click(object sender, RoutedEventArgs e)
{
Picture.Width = 0;
// Select_WorkOrderNumder.Text;
}
private void ListViewItem_Before(object sender, MouseButtonEventArgs e)//前一天
{
Picture.Width = 0;
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(-1).ToString("yyyy/MM/dd");
}
private void ListViewItem_Today(object sender, MouseButtonEventArgs e)//今天
{
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
Picture.Width = 0;
Sdatepicker.Text = DateTime.Now.ToString("yyyy/MM/dd");
}
private void ListViewItem_DayAfter(object sender, MouseButtonEventArgs e)//后一天
{
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd");
Picture.Width = 0;
Sdatepicker.Text = DateTime.Parse(Sdatepicker.Text).AddDays(1).ToString("yyyy/MM/dd");
}
private void Sdatepicker_SelectedDateChanged(object sender, SelectionChangedEventArgs e)//时间控件
{
Picture.Width = 0;
minDate = DateTime.Parse(sender.ToString());
maxDate = DateTime.Parse(sender.ToString()).AddDays(1);
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;
}
}
}
}

Loading…
Cancel
Save