Merge branch 'master' of http://www.scserverddns.top:13000/sc/formula_manage
This commit is contained in:
commit
f660b695f0
4 files changed
+231
-2
No files matched your search
+2
-2
@@ -223,8 +223,8 @@
|
|||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
<Button Content="确认" HorizontalAlignment="Right" Height="40" Width="80" Margin="0,0,140,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="confirm" Grid.Column="1"/>
|
<Button x:Name="Confirm" Content="确认" IsEnabled="False" HorizontalAlignment="Right" Height="40" Width="80" Margin="0,0,140,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="confirm" Grid.Column="1"/>
|
||||||
<Button Content="打印" HorizontalAlignment="Right" Height="40" Width="80" Margin="0,0,55,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="print" IsTabStop="False" Focusable ="False" Grid.Column="1"/>
|
<Button x:Name="Print" Content="打印" HorizontalAlignment="Right" Height="40" Width="80" Margin="0,0,55,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="print" IsTabStop="False" Focusable ="False" Grid.Column="1"/>
|
||||||
<Button x:Name="Save" Content="保存" IsEnabled="False" HorizontalAlignment="Left" Height="40" Width="80" Margin="15,0,0,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="save" IsTabStop="False" Focusable ="False"/>
|
<Button x:Name="Save" Content="保存" IsEnabled="False" HorizontalAlignment="Left" Height="40" Width="80" Margin="15,0,0,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="save" IsTabStop="False" Focusable ="False"/>
|
||||||
<Button x:Name="Delete" Content="删除" IsEnabled="False" HorizontalAlignment="Left" Height="40" Width="80" Margin="100,0,0,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="delete" IsTabStop="False" Focusable ="False"/>
|
<Button x:Name="Delete" Content="删除" IsEnabled="False" HorizontalAlignment="Left" Height="40" Width="80" Margin="100,0,0,20" VerticalAlignment="Bottom" FontSize="20" Background="#FFEFEFEF" BorderBrush="White" Click="delete" IsTabStop="False" Focusable ="False"/>
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,9 @@ using static System.Net.Mime.MediaTypeNames;
|
|||||||
using formula_manage.UserClass;
|
using formula_manage.UserClass;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Printing;
|
||||||
|
using System.Drawing.Printing;
|
||||||
|
using static System.Drawing.Printing.PrinterSettings;
|
||||||
|
|
||||||
namespace formula_manage
|
namespace formula_manage
|
||||||
{
|
{
|
||||||
@@ -341,6 +344,21 @@ namespace formula_manage
|
|||||||
|
|
||||||
private void print(object sender, RoutedEventArgs e)
|
private void print(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
Print.IsEnabled = false;
|
||||||
|
// var printServer = new PrintServer();
|
||||||
|
// PrinterList = printServer.GetPrintQueues();
|
||||||
|
// StringCollection strList = PrinterSettings.InstalledPrinters;
|
||||||
|
|
||||||
|
System.Windows.Controls.PrintDialog dialog = new System.Windows.Controls.PrintDialog();
|
||||||
|
//显示打印框,选择份数和打印机
|
||||||
|
if (dialog.ShowDialog() == true)
|
||||||
|
{
|
||||||
|
// dialog.PrintVisual(printArea, "Print Test");
|
||||||
|
// dialog.PrintVisual(richText, "测试");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Print.IsEnabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fabric(object sender, RoutedEventArgs e)
|
private void fabric(object sender, RoutedEventArgs e)
|
||||||
@@ -360,6 +378,7 @@ namespace formula_manage
|
|||||||
}
|
}
|
||||||
private void confirm(object sender, RoutedEventArgs e)
|
private void confirm(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
|
Confirm.IsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete(object sender, RoutedEventArgs e)
|
private void delete(object sender, RoutedEventArgs e)
|
||||||
@@ -686,6 +705,7 @@ namespace formula_manage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Save.IsEnabled = false;
|
Save.IsEnabled = false;
|
||||||
|
Confirm.IsEnabled = false;
|
||||||
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
||||||
}
|
}
|
||||||
private void CP_CONC_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//目标饱和度输入事件
|
private void CP_CONC_KeyUp(object sender, System.Windows.Input.KeyEventArgs e)//目标饱和度输入事件
|
||||||
@@ -738,6 +758,7 @@ namespace formula_manage
|
|||||||
rowadd["UNIT"] = "g";
|
rowadd["UNIT"] = "g";
|
||||||
RRODUCTdataTable.Rows.Add(rowadd);
|
RRODUCTdataTable.Rows.Add(rowadd);
|
||||||
Save.IsEnabled = true;
|
Save.IsEnabled = true;
|
||||||
|
Confirm.IsEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
||||||
@@ -834,6 +855,7 @@ namespace formula_manage
|
|||||||
row.EndEdit();
|
row.EndEdit();
|
||||||
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
DataGridHelper.SetRealTimeCommit(Grid_RRODUCT, true); //实时更新datagrid
|
||||||
Save.IsEnabled = false;
|
Save.IsEnabled = false;
|
||||||
|
Confirm.IsEnabled = false;
|
||||||
}
|
}
|
||||||
private void CP_PRODUCT_NAME_DropDownClosed(object sender, EventArgs e)//原料名选择事件
|
private void CP_PRODUCT_NAME_DropDownClosed(object sender, EventArgs e)//原料名选择事件
|
||||||
{
|
{
|
||||||
@@ -899,6 +921,7 @@ namespace formula_manage
|
|||||||
row.EndEdit();
|
row.EndEdit();
|
||||||
}
|
}
|
||||||
Save.IsEnabled = false;
|
Save.IsEnabled = false;
|
||||||
|
Confirm.IsEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,203 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing.Printing;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Management;
|
||||||
|
using System.Printing;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace formula_manage.UserClass
|
||||||
|
{
|
||||||
|
internal class UserPrint
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 判断是否连接打印机
|
||||||
|
/// </summary>
|
||||||
|
public bool CheckPrinter()
|
||||||
|
{
|
||||||
|
//取得默认打印机名
|
||||||
|
PrintDocument pdoc = new PrintDocument();
|
||||||
|
string printerName1 = pdoc.PrinterSettings.PrinterName;
|
||||||
|
|
||||||
|
//ManagementScope scope = new ManagementScope(@"\root\cimv2");
|
||||||
|
//scope.Connect();
|
||||||
|
|
||||||
|
// Select Printers from WMI Object Collections
|
||||||
|
ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer");
|
||||||
|
|
||||||
|
string printerName = "";
|
||||||
|
foreach (ManagementObject printer in searcher.Get())
|
||||||
|
{
|
||||||
|
printerName = printer["Name"].ToString().ToLower();
|
||||||
|
if (printerName.IndexOf(printerName1.ToLower()) > -1)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (printer["WorkOffline"].ToString().ToLower().Equals("true"))
|
||||||
|
{
|
||||||
|
switch (MessageBox.Show("默认打印机未连接或出错", "警告", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error))
|
||||||
|
{
|
||||||
|
case DialogResult.Retry:
|
||||||
|
CheckPrinter();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
// printer is offline by user
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// printer is not offline
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
switch (MessageBox.Show("默认打印机未连接或出错", "警告", MessageBoxButtons.AbortRetryIgnore, MessageBoxIcon.Error))
|
||||||
|
{
|
||||||
|
case DialogResult.Retry:
|
||||||
|
CheckPrinter();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断打印机状态,传Exception
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ex">Exception</param>
|
||||||
|
public void ErrerPrint(Exception ex)
|
||||||
|
{
|
||||||
|
PrintQueue pq = LocalPrintServer.GetDefaultPrintQueue();
|
||||||
|
string PrintStaticText = "";
|
||||||
|
bool isPrintErrer = false;
|
||||||
|
|
||||||
|
|
||||||
|
switch (pq.QueueStatus)
|
||||||
|
{
|
||||||
|
case PrintQueueStatus.Busy:
|
||||||
|
PrintStaticText = "打印机正忙";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.DoorOpen:
|
||||||
|
PrintStaticText = "打印机上的门已打开";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Error:
|
||||||
|
PrintStaticText = "由于错误情况,打印机无法打印。";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.IOActive:
|
||||||
|
PrintStaticText = "打印机正在与打印服务器交换数据";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Initializing:
|
||||||
|
PrintStaticText = "打印机正在初始化";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.ManualFeed:
|
||||||
|
PrintStaticText = "打印机正在等待用户将打印介质放入手动送纸盒";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.NoToner:
|
||||||
|
PrintStaticText = "打印机墨粉用完";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.None:
|
||||||
|
PrintStaticText = "未指定状态。";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.NotAvailable:
|
||||||
|
PrintStaticText = "状态信息不可用";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Offline:
|
||||||
|
PrintStaticText = "打印机处于脱机状态。";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.OutOfMemory:
|
||||||
|
PrintStaticText = "打印机无可用内存";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.OutputBinFull:
|
||||||
|
PrintStaticText = "打印机的输出纸盒已满";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.PagePunt:
|
||||||
|
PrintStaticText = "打印机不能打印当前页";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.PaperJam:
|
||||||
|
PrintStaticText = "打印机卡纸";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.PaperOut:
|
||||||
|
PrintStaticText = "打印机中没有或已用完当前打印作业所需的纸张类型";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.PaperProblem:
|
||||||
|
PrintStaticText = "打印机中的纸张导致未指定的错误情况";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Paused:
|
||||||
|
PrintStaticText = "打印队列已暂停";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.PendingDeletion:
|
||||||
|
PrintStaticText = "打印队列正在删除打印作业";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.PowerSave:
|
||||||
|
PrintStaticText = "打印机处于节能模式";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Printing:
|
||||||
|
PrintStaticText = "设备正在打印";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Processing:
|
||||||
|
PrintStaticText = "设备正在执行某种工作,如果此设备是集打印机、传真机和扫描仪于一体的多功能设备,则不需要打印";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.ServerUnknown:
|
||||||
|
PrintStaticText = "打印机处于错误状态";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.TonerLow:
|
||||||
|
PrintStaticText = "打印机中只剩下少量墨粉";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.UserIntervention:
|
||||||
|
PrintStaticText = "打印机要求通过用户操作来更正错误情况";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.Waiting:
|
||||||
|
PrintStaticText = "打印机正在等待打印作业";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
case PrintQueueStatus.WarmingUp:
|
||||||
|
PrintStaticText = "打印机正在预热";
|
||||||
|
isPrintErrer = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPrintErrer)
|
||||||
|
{
|
||||||
|
//WriteLog.SetString(PrintStaticText);
|
||||||
|
MessageBox.Show(PrintStaticText, "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
if (ex.Message == "The net printer is unavailable.")
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
MessageBox.Show("网络打印机不可用", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
|
// WriteLog.SetString(ex.Message);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// WriteLog.SetException(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -124,6 +124,8 @@
|
|||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="System.Data" />
|
<Reference Include="System.Data" />
|
||||||
<Reference Include="System.Drawing" />
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Management" />
|
||||||
|
<Reference Include="System.Printing" />
|
||||||
<Reference Include="System.Windows.Forms" />
|
<Reference Include="System.Windows.Forms" />
|
||||||
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
<HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
<HintPath>packages\MvvmLightLibs.5.4.1.1\lib\net45\System.Windows.Interactivity.dll</HintPath>
|
||||||
@@ -180,6 +182,7 @@
|
|||||||
<Compile Include="UserClass\IniFile.cs" />
|
<Compile Include="UserClass\IniFile.cs" />
|
||||||
<Compile Include="UserClass\PressKey.cs" />
|
<Compile Include="UserClass\PressKey.cs" />
|
||||||
<Compile Include="UserClass\DataTableForToObservableCollection.cs" />
|
<Compile Include="UserClass\DataTableForToObservableCollection.cs" />
|
||||||
|
<Compile Include="UserClass\UserPrint.cs" />
|
||||||
<Compile Include="ViewModel\MainWindowViewModel.cs" />
|
<Compile Include="ViewModel\MainWindowViewModel.cs" />
|
||||||
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
<Compile Include="ViewModel\ViewModelLocator.cs" />
|
||||||
<Compile Include="View\Formula.xaml.cs">
|
<Compile Include="View\Formula.xaml.cs">
|
||||||
|
|||||||
Reference in new issue
Block a user