Browse Source

添加表单选择

master
忱 沈 2 years ago
parent
commit
ce4835ad11
  1. 34
      MainWindow.xaml.cs
  2. 4
      Windows/Print.xaml
  3. 41
      Windows/Print.xaml.cs
  4. 2
      formula_manage.csproj

34
MainWindow.xaml.cs

@ -122,9 +122,13 @@ namespace formula_manage
Grid_RRODUCT.ItemsSource = RRODUCTdataTable.DefaultView;
}
private void PrintForms()
private void PrintForms()//传入可用打印模板
{
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath);
int dirID=0;
DataTable Report = new DataTable();
Report.Columns.Add("NAME", typeof(string));
string Print_path = Configini.IniReadvalue("PRINTER", "P3");
string Print_path2 = Configini.IniReadvalue("PRINTER", "P12");
@ -132,9 +136,20 @@ namespace formula_manage
string Temp_s = Configini.IniReadvalue("PRINTER", "P14");
DirectoryInfo di = new DirectoryInfo(Print_path); //new文件夹
FileInfo[] files = di.GetFiles();//生成文件夹中的文件名合集
Forms_.ItemsSource = files;//加载合集
Forms_.DisplayMemberPath = "Name"; // 显示文件名
FileInfo[] files = di.GetFiles("*.frx");//生成文件夹中的文件名合集
foreach (FileInfo file in files)
{
DataRow reportDATA = Report.NewRow();//插件新行
Report.Rows.Add(reportDATA);//保存修改
reportDATA = Report.Rows[dirID++];//选择行
reportDATA.BeginEdit();//开始编辑
reportDATA["NAME"] = System.IO.Path.GetFileNameWithoutExtension(file.Name);//传入字符
reportDATA.EndEdit();//结束编辑
}
Forms_.ItemsSource = Report.DefaultView;//加载合集
Forms_.DisplayMemberPath = "NAME"; // 显示文件名
Forms_.Text = Temp_m;
}
@ -225,7 +240,6 @@ namespace formula_manage
}
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) //窗口关闭事件
{
string logpath = System.Environment.CurrentDirectory + "\\Log";//日志文件目录
@ -392,11 +406,9 @@ namespace formula_manage
Windows.RECIPE rECIPE = new Windows.RECIPE();
rECIPE.ShowDialog();//实例化并置顶打开设置窗口
}
private void PROCESS(object sender, RoutedEventArgs e)
{
}
private void WORKFLOW(object sender, RoutedEventArgs e)
{
Windows.Dissolve dissolve = new Windows.Dissolve();
@ -407,7 +419,6 @@ namespace formula_manage
Windows.Dissolve dissolve = new Windows.Dissolve();
dissolve.ShowDialog();//实例化并置顶打开设置窗口
}
private void print(object sender, RoutedEventArgs e)
{
Print.IsEnabled = false;
@ -425,19 +436,16 @@ namespace formula_manage
Print.IsEnabled = true;
}
private void fabric(object sender, RoutedEventArgs e)
{
fabric fabric_page = new fabric();
fabric_page.ShowDialog();//实例化并置顶打开窗口
}
private void color(object sender, RoutedEventArgs e)
{
color color_page = new color();
color_page.ShowDialog();//实例化并置顶打开窗口
}
private void client(object sender, RoutedEventArgs e)
{
client client_page = new client();
@ -447,12 +455,10 @@ namespace formula_manage
{
Confirm.IsEnabled = false;
}
private void delete(object sender, RoutedEventArgs e)
{
Delete.IsEnabled = false;
}
private async void save(object sender, RoutedEventArgs e) //保存按钮
{
@ -558,12 +564,10 @@ namespace formula_manage
UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(INIPath); //记录当前单序号
Configini.IniWritevalue("SOFTWARE_SET", " T3", str_Prepose);
}
private void Button_NewOrder(object sender, RoutedEventArgs e) //新料单按钮
{
Number_Event();
}
private void Machine_OnKeyDownd(object sender, System.Windows.Input.KeyEventArgs e) //机台回车跳转功能
{
if (e.Key == Key.Enter)

4
Windows/Print.xaml

@ -37,7 +37,7 @@
<Button Content="编辑模板" HorizontalAlignment="Left" Height="20" Margin="295,205,0,0" VerticalAlignment="Top" Width="70" Background="#FFF9F9F9" Click="Button_Click_12"/>
<TextBlock HorizontalAlignment="Left" Height="15" Margin="20,305,0,0" TextWrapping="Wrap" Text="管理打印模板:" VerticalAlignment="Top" Width="90"/>
<ComboBox HorizontalAlignment="Left" Height="20" Margin="110,305,0,0" VerticalAlignment="Top" Width="180" x:Name="Template" IsEditable="True"/>
<Button Content="删除模板" HorizontalAlignment="Left" Height="20" Margin="375,305,0,0" VerticalAlignment="Top" Width="70" Background="#FFF9F9F9" Click="Button_Click_3"/>
<Button Content="添加模板" HorizontalAlignment="Left" Height="20" Margin="295,305,0,0" VerticalAlignment="Top" Width="70" Background="#FFF9F9F9" Click="Button_Click_4"/>
<Button Content="删除模板" HorizontalAlignment="Left" Height="20" Margin="375,305,0,0" VerticalAlignment="Top" Width="70" Background="#FFF9F9F9" Click="Button_Click_4"/>
<Button Content="添加模板" HorizontalAlignment="Left" Height="20" Margin="295,305,0,0" VerticalAlignment="Top" Width="70" Background="#FFF9F9F9" Click="Button_Click_3"/>
</Grid>
</Window>

41
Windows/Print.xaml.cs

@ -81,11 +81,11 @@ namespace formula_manage.Windows
cbxPrinter3.IsEnabled = Printer3;
DirectoryInfo di_M = new DirectoryInfo(Print_path.Text); //new文件夹
FileInfo[] files_M = di_M.GetFiles();//生成文件夹中的文件名合集
FileInfo[] files_M = di_M.GetFiles("*.frx");//生成文件夹中的文件名合集
Template_M.ItemsSource = files_M;//加载合集
Template_M.DisplayMemberPath = "Name"; // 显示文件名
DirectoryInfo di_S = new DirectoryInfo(Print_path2.Text);
FileInfo[] files_S = di_M.GetFiles();
FileInfo[] files_S = di_S.GetFiles("*.frx");
Template_S.ItemsSource = files_S;
Template_S.DisplayMemberPath = "Name";
Template_M.Text = Temp_M;//传入保存的默认模板
@ -229,14 +229,47 @@ namespace formula_manage.Windows
return list;
}
private void Button_Click_3(object sender, RoutedEventArgs e)
private void Button_Click_3(object sender, RoutedEventArgs e)//新建模板文件
{
string Template_path = Print_path.Text + "/" + Template.Text;
string Template_DATA = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<Report ScriptLanguage=\"CSharp\" ReportInfo.Created=\"12/12/2023 23:59:59\" ReportInfo.Modified=\"12/12/2023 23:59:59\" ReportInfo.CreatorVersion=\"2023.12.12.0\">\r\n <Dictionary/>\r\n <ReportPage Name=\"Page1\" Watermark.Font=\"宋体, 60pt\">\r\n <ReportTitleBand Name=\"ReportTitle1\" Width=\"718.2\" Height=\"37.8\"/>\r\n <PageHeaderBand Name=\"PageHeader1\" Top=\"41.8\" Width=\"718.2\" Height=\"28.35\"/>\r\n <DataBand Name=\"Data1\" Top=\"74.15\" Width=\"718.2\" Height=\"75.6\"/>\r\n <PageFooterBand Name=\"PageFooter1\" Top=\"153.75\" Width=\"718.2\" Height=\"18.9\"/>\r\n </ReportPage>\r\n</Report>";
if (File.Exists(Template_path)) //判断文件是否存在
{
System.Windows.MessageBox.Show("模板已存在");
return;
}
if (string.IsNullOrEmpty(Template.Text))
{
System.Windows.MessageBox.Show("模板名不能为空");
return;
}
private void Button_Click_4(object sender, RoutedEventArgs e)
File.WriteAllText(Template_path + ".frx", Template_DATA);
var tuple = PrintHelper.Design(Template_path + ".frx");
if (!tuple.Item1)
{
System.Windows.MessageBox.Show($"打开设计器失败:{tuple.Item2}");
}
}
private void Button_Click_4(object sender, RoutedEventArgs e)//删除指定模板
{
try
{
string Template_path = Print_path.Text + "/" + Template.Text;
File.Delete(Template_path);
}
catch
{
System.Windows.MessageBox.Show("删除失败");
}
Template.Text = null;
DirectoryInfo di_M = new DirectoryInfo(Print_path.Text); //new文件夹
FileInfo[] files_M = di_M.GetFiles("*.frx");//生成文件夹中的文件名合集
Template.ItemsSource = files_M;//加载合集
Template.DisplayMemberPath = "Name"; // 显示文件名
}
}
}

2
formula_manage.csproj

@ -428,6 +428,8 @@
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="FastReport\FRX\test.frx" />
<None Include="FastReport\FRX\test1.frx" />
<None Include="FastReport\Localization\Arabic.frl" />
<None Include="FastReport\Localization\Armenian.frl" />
<None Include="FastReport\Localization\Chinese %28Simplified%29.frl" />

Loading…
Cancel
Save