5 changed files with 493 additions and 3 deletions
@ -0,0 +1,125 @@ |
|||
<UserControl x:Class="SunlightCentralizedControlManagement_SCCM_.View.DyeingPlanView" |
|||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View" |
|||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties" |
|||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes" |
|||
mc:Ignorable="d" Loaded="UserControl_Loaded" |
|||
d:DesignHeight="900" d:DesignWidth="1100"> |
|||
<Grid Background="White" Cursor=""> |
|||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="140,30,10,0" x:Name="comboBoxWorkOrder" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" DropDownClosed="comboBoxMachine_DropDownClosed" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,30,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.orders}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="140,80,10,0" x:Name="comboBoxDyelot" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" Background="White" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,80,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Dyelot}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<ComboBox HorizontalAlignment="Left" Height="30" Margin="140,130,10,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,130,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Machine}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,180,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.ColorNumber}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,180,10,0" x:Name="TEXTColorNumber" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,230,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.ColorName}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,230,10,0" x:Name="TEXTColorName" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,280,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Client}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,280,10,0" x:Name="TEXTClient" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,330,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.ClothSpecies}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,330,10,0" x:Name="TEXTClothSpecies" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,380,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.BathRatio}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,380,10,0" x:Name="TEXTBathRatio" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,430,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.Total}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,430,10,0" x:Name="TEXTTotal" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
<TextBlock HorizontalAlignment="Left" Height="40" Margin="10,480,280,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.USER}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<TextBox HorizontalAlignment="Left" Height="30" Margin="140,480,10,0" x:Name="TEXTUSER" VerticalAlignment="Top" Width="270" |
|||
FontSize="15" BorderBrush="#FF673AB7" /> |
|||
|
|||
<ComboBox HorizontalAlignment="Right" Height="30" Margin="150,30,50,0" x:Name="comboBoxProgram" VerticalAlignment="Top" Width="470" |
|||
FontSize="15" IsEditable="True" BorderBrush="#FF673AB7" DropDownClosed="comboBoxProgram_DropDownClosed" |
|||
TextBoxBase.TextChanged="comboBoxProgram_TextChanged"/> |
|||
<TextBlock HorizontalAlignment="Right" Height="40" Margin="10,30,480,0" TextWrapping="Wrap" Text="{x:Static lang:Resources.process}" |
|||
VerticalAlignment="Top" Width="120" FontSize="25"/> |
|||
<DataGrid x:Name="Grid_data" AlternationCount="2" IsReadOnly="True" d:ItemsSource="{d:SampleData ItemCount=99}" |
|||
Background="White" HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" |
|||
GridLinesVisibility="All" ColumnHeaderHeight="40" MouseDoubleClick="Grid_data_MouseDoubleClick" |
|||
Grid.ColumnSpan="2" CanUserResizeRows="False" AutoGenerateColumns="False" MinColumnWidth="30" |
|||
CanUserAddRows="False" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectionMode="Single" |
|||
Margin="0,100,10,60" Width="600" HorizontalAlignment="Right" > |
|||
<DataGrid.RowStyle > |
|||
<Style TargetType="{x:Type DataGridRow}"> |
|||
<Setter Property="Height" Value="25" /> |
|||
<Setter Property="FontSize" Value="15" /> |
|||
<Style.Triggers> |
|||
<Trigger Property="ItemsControl.AlternationIndex" Value="0"> |
|||
<Setter Property="Background" Value="#FFFFFFFF" /> |
|||
</Trigger> |
|||
<Trigger Property="ItemsControl.AlternationIndex" Value="1"> |
|||
<Setter Property="Background" Value="#FFF0F0F0" /> |
|||
</Trigger> |
|||
<Trigger Property="IsMouseOver" Value="False"/> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</DataGrid.RowStyle> |
|||
<DataGrid.CellStyle> |
|||
<Style TargetType="DataGridCell"> |
|||
<Setter Property="BorderThickness" Value="0"/> |
|||
<Setter Property="MinWidth" Value="20"/> |
|||
<Style.Triggers> |
|||
<Trigger Property="IsSelected" Value="True"> |
|||
<Setter Property="Background" Value="#FFC0C0C0"/> |
|||
<Setter Property="BorderBrush" Value="#FFC0C0C0"/> |
|||
<Setter Property="Foreground" Value="Black"/> |
|||
</Trigger> |
|||
</Style.Triggers> |
|||
</Style> |
|||
</DataGrid.CellStyle> |
|||
<DataGrid.ContextMenu> |
|||
<ContextMenu> |
|||
<MenuItem Header="{x:Static lang:Resources.edit}" Click="MenuItem_edit"/> |
|||
<MenuItem Header="{x:Static lang:Resources.Insert}" /> |
|||
</ContextMenu> |
|||
</DataGrid.ContextMenu> |
|||
<DataGrid.Columns> |
|||
<!--列信息绑定--> |
|||
<DataGridTextColumn Binding="{Binding ProgramID}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Program}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.Step}" Binding="{Binding Step}" Width="40" IsReadOnly="True" /> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.Code}" Width="0" MinWidth="0" MaxWidth="0" Binding="{Binding StepID}" IsReadOnly="True"/> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.Directives}" Width="150" Binding="{Binding StepName}" IsReadOnly="True"/> |
|||
<DataGridTextColumn Header="{x:Static lang:Resources.ParameterSet}" Width="*" Binding="{Binding ParameterName}" IsReadOnly="True"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter1}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter2}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter3}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter4}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter5}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter6}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter7}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter8}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter9}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
<DataGridTextColumn Binding="{Binding Parameter10}" Width="0" MinWidth="0" MaxWidth="0"/> |
|||
</DataGrid.Columns> |
|||
</DataGrid> |
|||
|
|||
|
|||
<Button x:Name="Save" Content="{x:Static lang:Resources.Save}" HorizontalAlignment="Right" Height="35" Margin="450,0,50,10" VerticalAlignment="Bottom" Width="80" Click="Button_Click"/> |
|||
<Button HorizontalAlignment="Left" Height="35" Margin="0,0,50,10" VerticalAlignment="Bottom" Width="60" Click="Button_Quit" Background="{x:Null}" BorderBrush="{x:Null}" Foreground="{x:Null}"> |
|||
<materialDesign:PackIcon Kind="ArrowRight" Foreground="#FF00204E" HorizontalAlignment="Center" VerticalAlignment="Center" Width="50" Height="35" /> |
|||
</Button> |
|||
</Grid> |
|||
</UserControl> |
@ -0,0 +1,358 @@ |
|||
using Newtonsoft.Json.Linq; |
|||
using nGantt.GanttChart; |
|||
using SunlightCentralizedControlManagement_SCCM_.UserClass; |
|||
using SunlightCentralizedControlManagement_SCCM_.ViewModel; |
|||
using SunlightCentralizedControlManagement_SCCM_.WindowsView; |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Data; |
|||
using System.Linq; |
|||
using System.Text; |
|||
using System.Text.RegularExpressions; |
|||
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.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 |
|||
{ |
|||
/// <summary>
|
|||
/// ProductionPlanningEdit.xaml 的交互逻辑
|
|||
/// </summary>
|
|||
public partial class DyeingPlanView : UserControl |
|||
{ |
|||
private SQLiteHelper SQLiteHelpers = null; //定义数据库
|
|||
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
|
|||
DataTable ProgramName = new DataTable(); |
|||
DataTable WorkOrder =new DataTable(); |
|||
DataTable dat = new DataTable(); |
|||
public string WorkOrder_n; |
|||
public DyeingPlanView() |
|||
{ |
|||
InitializeComponent(); |
|||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|||
SQLiteHelpers.Open(); //打开数据库
|
|||
ProgramName = SQLiteHelpers.ExecuteDataSet("select * from ProgramName order by ProgramID desc", null).Tables[0];//缓存
|
|||
SQLiteHelpers.Close(); //关闭连接
|
|||
comboBoxMachine.ItemsSource = MainWindowViewModel.Machines.AsEnumerable().Select(rowdata => rowdata.Field<string>("name")).ToList();//转换机台
|
|||
comboBoxProgram.ItemsSource = ProgramName.AsEnumerable().Select(rowdata => rowdata.Field<string>("ProgramName")).ToList();//转换工艺代码
|
|||
|
|||
|
|||
} |
|||
private void UserControl_Loaded(object sender, RoutedEventArgs e) |
|||
{ |
|||
|
|||
} |
|||
private void comboBoxMachine_DropDownClosed(object sender, EventArgs e)//机台选择
|
|||
{ |
|||
string[] sArray = Regex.Split(comboBoxMachine.Text, @"\+", RegexOptions.IgnoreCase); |
|||
if (sArray.Length <= 1) |
|||
{ |
|||
comboBoxDyelot.IsEnabled = true; |
|||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|||
SQLiteHelpers.Open(); //打开数据库
|
|||
DataTable DatDyelot = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Machine='" + comboBoxMachine.Text + "' and State='101' order by Dyelot desc", null).Tables[0]; //读取计划表写入缓存
|
|||
SQLiteHelpers.Close(); //关闭连接
|
|||
comboBoxDyelot.ItemsSource = DatDyelot.AsEnumerable().Select(rowdata => rowdata.Field<string>("Dyelot")).ToList();//转换代码
|
|||
} |
|||
} |
|||
private void Multi_Click(object sender, RoutedEventArgs e)//机台组
|
|||
{ |
|||
MachineSelection machineSelection = new MachineSelection(); |
|||
machineSelection.AddressUpdated += new MachineSelection.AddressUpdateHandler(Address_Multi_Click); |
|||
//machineSelection.data = "ID";
|
|||
machineSelection.ShowDialog(); |
|||
} |
|||
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; |
|||
} |
|||
|
|||
private void Button_Click(object sender, RoutedEventArgs e)//保存按钮
|
|||
{ |
|||
if (string.IsNullOrEmpty(comboBoxMachine.Text)) |
|||
{ |
|||
MessageBox.Show("Not Machine", "SCCM", MessageBoxButton.OK, MessageBoxImage.Question); |
|||
return; |
|||
} |
|||
if (string.IsNullOrEmpty(comboBoxProgram.Text)) |
|||
{ |
|||
MessageBox.Show("Not Program", "SCCM", MessageBoxButton.OK, MessageBoxImage.Question); |
|||
return; |
|||
} |
|||
string[] pArray = Regex.Split(comboBoxProgram.Text, @"\+", RegexOptions.IgnoreCase); |
|||
|
|||
|
|||
//单机器信息写入
|
|||
string sTime; |
|||
string StartTime_; |
|||
string WorkOrder_ = comboBoxMachine.Text + "_" + DateTime.Now.ToString("yyMMddHHmmss"); |
|||
if (!string.IsNullOrEmpty(WorkOrder_n)) WorkOrder_ = WorkOrder_n; |
|||
string ProgramName_ = comboBoxProgram.Text; |
|||
string ProgramID_ = null; |
|||
for (int j = 0; j < pArray.Length; j++) |
|||
{ |
|||
try |
|||
{ |
|||
if (j == 0) |
|||
{ |
|||
ProgramID_ = ProgramName.Select("ProgramName='" + pArray[j] + "'"). |
|||
First().Field<object>("ProgramID").ToString(); |
|||
} |
|||
else |
|||
{ |
|||
ProgramID_ = ProgramID_ + "+" + ProgramName.Select("ProgramName='" + pArray[j] + "'"). |
|||
First().Field<object>("ProgramID").ToString(); |
|||
} |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
MessageBox.Show("Not Program", "SCCM", MessageBoxButton.OK, MessageBoxImage.Question); |
|||
return; |
|||
} |
|||
} |
|||
string Machines_ = comboBoxMachine.Text; |
|||
string State_ = "100"; |
|||
string Dyelot_ = comboBoxDyelot.Text; |
|||
// string color_ = color_color.Background.ToString();
|
|||
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>("EndTime").ToString(); //读取计划表写入缓存
|
|||
if (DateTime.Now < DateTime.Parse(sTime)) |
|||
{ |
|||
StartTime_ = DateTime.Parse(sTime).AddMinutes(1).ToString("yyyy/MM/dd HH:mm:ss"); |
|||
} |
|||
else |
|||
{ |
|||
StartTime_ = DateTime.Now.AddMinutes(1).ToString("yyyy/MM/dd HH:mm:ss"); |
|||
} |
|||
} |
|||
catch (Exception) |
|||
{ |
|||
StartTime_ = DateTime.Now.AddMinutes(1).ToString("yyyy/MM/dd HH:mm:ss"); |
|||
} |
|||
|
|||
string Time_ = "0:00"; |
|||
for (int k = 0; k < pArray.Length; k++) |
|||
{ |
|||
string t = ProgramName.Select("ProgramName='" + pArray[k] + "'"). |
|||
First().Field<object>("Time").ToString(); |
|||
Time_ = (DateTime.Parse(Time_) + DateTime.Parse(t).TimeOfDay).ToString("HH:mm:ss"); |
|||
} |
|||
string EndTime_ = (DateTime.Parse(StartTime_) + DateTime.Parse(Time_).TimeOfDay).ToString("yyyy/MM/dd HH:mm:ss"); |
|||
|
|||
//插入数据信息
|
|||
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", color_);
|
|||
SQLiteHelpers.InsertData("WorkOrder", WorkOrder_new);// 执行插入
|
|||
|
|||
Dictionary<string, object> WorkOrder_DAT = new Dictionary<string, object>();//缓存函数
|
|||
for (int x = 0; x < dat.Rows.Count; x++) |
|||
{ |
|||
WorkOrder_DAT.Add("WorkOrder", WorkOrder_); |
|||
WorkOrder_DAT.Add("Dyelot", Dyelot_); |
|||
WorkOrder_DAT.Add("ProgramID", dat.Rows[x]["ProgramID"]); |
|||
WorkOrder_DAT.Add("Program", dat.Rows[x]["Program"]); |
|||
WorkOrder_DAT.Add("Step", dat.Rows[x]["Step"]); |
|||
WorkOrder_DAT.Add("StepID", dat.Rows[x]["StepID"]); |
|||
WorkOrder_DAT.Add("StepName", dat.Rows[x]["StepName"]); |
|||
WorkOrder_DAT.Add("ParameterName", dat.Rows[x]["ParameterName"]); |
|||
WorkOrder_DAT.Add("Parameter1", dat.Rows[x]["Parameter1"]); |
|||
WorkOrder_DAT.Add("Parameter2", dat.Rows[x]["Parameter2"]); |
|||
WorkOrder_DAT.Add("Parameter3", dat.Rows[x]["Parameter3"]); |
|||
WorkOrder_DAT.Add("Parameter4", dat.Rows[x]["Parameter4"]); |
|||
WorkOrder_DAT.Add("Parameter5", dat.Rows[x]["Parameter5"]); |
|||
WorkOrder_DAT.Add("Parameter6", dat.Rows[x]["Parameter6"]); |
|||
WorkOrder_DAT.Add("Parameter7", dat.Rows[x]["Parameter7"]); |
|||
WorkOrder_DAT.Add("Parameter8", dat.Rows[x]["Parameter8"]); |
|||
WorkOrder_DAT.Add("Parameter9", dat.Rows[x]["Parameter9"]); |
|||
WorkOrder_DAT.Add("Parameter10", dat.Rows[x]["Parameter10"]); |
|||
SQLiteHelpers.InsertData("WorkorderSteps", WorkOrder_DAT);//行插入
|
|||
WorkOrder_DAT.Clear(); |
|||
} |
|||
SQLiteHelpers.Close(); //关闭连接
|
|||
|
|||
this.Visibility = Visibility.Collapsed; |
|||
ProductionPlanningView.UI = true; |
|||
} |
|||
private void Button_Quit(object sender, RoutedEventArgs e)//退出
|
|||
{ |
|||
this.Visibility = Visibility.Collapsed; |
|||
} |
|||
|
|||
public void DatSteps(DataTable db)//行号刷新
|
|||
{ |
|||
int a = db.Rows.Count; |
|||
for (int i = 0; i < a; i++) |
|||
{ |
|||
DataRow dr = db.Rows[i]; |
|||
dr.BeginEdit(); |
|||
dr["Step"] = i + 1; |
|||
dr.EndEdit(); |
|||
} |
|||
} |
|||
private void comboBoxProgram_DropDownClosed(object sender, EventArgs e)//工艺选择事件
|
|||
{ |
|||
if (!string.IsNullOrEmpty(comboBoxProgram.Text)) |
|||
{ |
|||
dat.Clear(); |
|||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|||
SQLiteHelpers.Open(); //打开数据库
|
|||
dat = SQLiteHelpers.ExecuteDataSet( |
|||
"select * from ProgramSteps where Program='" + comboBoxProgram.SelectedValue + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
|||
SQLiteHelpers.Close(); //关闭连接
|
|||
DatSteps(dat); |
|||
Grid_data.ItemsSource = dat.DefaultView; |
|||
} |
|||
} |
|||
|
|||
private void comboBoxProgram_TextChanged(object sender, TextChangedEventArgs e) |
|||
{ |
|||
dat.Clear(); |
|||
string text = comboBoxProgram.Text; |
|||
if (!string.IsNullOrEmpty(text)) |
|||
{ |
|||
try |
|||
{ |
|||
string[] sArray = Regex.Split(text, @"\+", RegexOptions.IgnoreCase); |
|||
SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径
|
|||
SQLiteHelpers.Open(); //打开数据库
|
|||
for (int i = 0; i < sArray.Length; i++) |
|||
{ |
|||
DataTable temp = SQLiteHelpers.ExecuteDataSet( |
|||
"select * from ProgramSteps where Program='" + sArray[i] + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
|||
if (dat.Columns.Count == 0) dat = temp.Clone(); |
|||
foreach (DataRow drT in temp.Rows) |
|||
{ |
|||
dat.Rows.Add(drT.ItemArray); |
|||
} |
|||
}//以工艺名组合工艺细节
|
|||
if (!string.IsNullOrEmpty(WorkOrder_n)) |
|||
{ |
|||
dat = SQLiteHelpers.ExecuteDataSet( |
|||
"select * from WorkorderSteps where WorkOrder='" + WorkOrder_n + "' order by Step asc", null).Tables[0]; //读取计划表写入缓存
|
|||
}//插入工单不为空时载入细节信息
|
|||
SQLiteHelpers.Close(); //关闭连接
|
|||
DatSteps(dat); |
|||
Grid_data.ItemsSource = dat.DefaultView;//显示
|
|||
} |
|||
catch (Exception) { } |
|||
} |
|||
|
|||
}//工艺修改事件
|
|||
|
|||
private void color_color_MouseDoubleClick(object sender, MouseButtonEventArgs e)//颜色
|
|||
{ |
|||
System.Windows.Forms.ColorDialog colorDialog = new System.Windows.Forms.ColorDialog();//使用调色盘控件ColorDialog
|
|||
if (colorDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)//打开调色盘
|
|||
{ |
|||
|
|||
System.Drawing.Color DColor = colorDialog.Color;////获取选中色彩信息
|
|||
//System.Windows.Media.Color MColor = new System.Windows.Media.Color();//转换
|
|||
System.Windows.Media.Color MColor = System.Windows.Media.Color.FromArgb(DColor.A, DColor.R, DColor.G, DColor.B);//转换并配置ARGB参数
|
|||
// color_color.Background = new SolidColorBrush(MColor);//ARGB参数输出至Color的背景色
|
|||
//string colorCode = string.Format("{0:X2}", DColor.B) + string.Format("{0:X2}", DColor.G) + string.Format("{0:X2}", DColor.R);//反向十六进制RGB
|
|||
//string colorCode = string.Format("{0:X2}", DColor.R) + string.Format("{0:X2}", DColor.G) + string.Format("{0:X2}", DColor.B);//正向十六进制RGB
|
|||
//ColorCode_SQL = Convert.ToInt32(colorCode, 16);//十六进制RGB转存储数值
|
|||
|
|||
} |
|||
} |
|||
|
|||
//string ProgramID;
|
|||
//string ProgramNAME;
|
|||
string Numder = null; |
|||
string ID = null; |
|||
string P1, P2, P3, P4, P5; |
|||
|
|||
private void MenuItem_edit(object sender, RoutedEventArgs e) |
|||
{ |
|||
int rownum = Grid_data.SelectedIndex;//获取鼠标选中行并定义变量
|
|||
if (rownum != -1)//判断鼠标定位是否有效
|
|||
{ |
|||
ID = (Grid_data.Columns[2].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|||
Numder = (Grid_data.Columns[3].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|||
P1 = (Grid_data.Columns[6].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第6列,
|
|||
P2 = (Grid_data.Columns[7].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第7列,
|
|||
P3 = (Grid_data.Columns[8].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第8列,
|
|||
P4 = (Grid_data.Columns[9].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第9列,
|
|||
P5 = (Grid_data.Columns[10].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第10列,
|
|||
|
|||
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; } |
|||
if (ID == null) ID = dat.Rows.Count.ToString(); |
|||
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5); |
|||
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked); |
|||
viewstop.data = ID; |
|||
viewstop.ShowDialog(); |
|||
} |
|||
} |
|||
|
|||
private void Grid_data_MouseDoubleClick(object sender, MouseButtonEventArgs e) |
|||
{ |
|||
int rownum = Grid_data.SelectedIndex;//获取鼠标选中行并定义变量
|
|||
if (rownum != -1)//判断鼠标定位是否有效
|
|||
{ |
|||
ID = (Grid_data.Columns[2].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|||
Numder = (Grid_data.Columns[3].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第1列,
|
|||
P1 = (Grid_data.Columns[6].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第6列,
|
|||
P2 = (Grid_data.Columns[7].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第7列,
|
|||
P3 = (Grid_data.Columns[8].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第8列,
|
|||
P4 = (Grid_data.Columns[9].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第9列,
|
|||
P5 = (Grid_data.Columns[10].GetCellContent(Grid_data.Items[rownum]) as TextBlock).Text;//定位第10列,
|
|||
|
|||
if (string.IsNullOrEmpty(Numder)) { Numder = null; P1 = "0"; P2 = "0"; P3 = "0"; P4 = "0"; P5 = "0"; } |
|||
if (ID == null) ID = dat.Rows.Count.ToString(); |
|||
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5); |
|||
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked); |
|||
viewstop.data = ID; |
|||
viewstop.ShowDialog(); |
|||
} |
|||
} |
|||
private void Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
|||
{ |
|||
int i = dat.Rows.Count; |
|||
int n = StrToInt.To16Convert10(ID); |
|||
|
|||
DataRow dr = dat.Rows[n - 1]; |
|||
dr.BeginEdit(); |
|||
dr["StepID"] = e.StepID; |
|||
dr["StepName"] = e.StepNAME; |
|||
dr["ParameterName"] = e.PNAME; |
|||
dr["Parameter1"] = e.P1; |
|||
dr["Parameter2"] = e.P2; |
|||
dr["Parameter3"] = e.P3; |
|||
dr["Parameter4"] = e.P4; |
|||
dr["Parameter5"] = e.P5; |
|||
dr.EndEdit(); |
|||
|
|||
Grid_data.ItemsSource = dat.DefaultView; |
|||
} |
|||
} |
|||
} |
Loading…
Reference in new issue