更改FTP文件导入
This commit is contained in:
17
FATrace.App/frmMain.Designer.cs
generated
17
FATrace.App/frmMain.Designer.cs
generated
@@ -105,6 +105,7 @@ namespace FATrace.App
|
||||
dtpSearchStartTime = new DateTimePicker();
|
||||
dataGridView1 = new DataGridView();
|
||||
label22 = new Label();
|
||||
btnReprint = new Button();
|
||||
statusStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
||||
splitContainer1.Panel1.SuspendLayout();
|
||||
@@ -346,6 +347,7 @@ namespace FATrace.App
|
||||
// panel3
|
||||
//
|
||||
panel3.BorderStyle = BorderStyle.FixedSingle;
|
||||
panel3.Controls.Add(btnReprint);
|
||||
panel3.Controls.Add(pictureBox4);
|
||||
panel3.Controls.Add(btnWeightPrint);
|
||||
panel3.Controls.Add(txtCode);
|
||||
@@ -681,6 +683,7 @@ namespace FATrace.App
|
||||
//
|
||||
// btnRawName3
|
||||
//
|
||||
btnRawName3.Enabled = false;
|
||||
btnRawName3.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
btnRawName3.Location = new Point(321, 53);
|
||||
btnRawName3.Name = "btnRawName3";
|
||||
@@ -692,6 +695,7 @@ namespace FATrace.App
|
||||
//
|
||||
// btnRawName2
|
||||
//
|
||||
btnRawName2.Enabled = false;
|
||||
btnRawName2.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
btnRawName2.Location = new Point(24, 107);
|
||||
btnRawName2.Name = "btnRawName2";
|
||||
@@ -980,6 +984,18 @@ namespace FATrace.App
|
||||
label22.Text = "历史数据";
|
||||
label22.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// btnReprint
|
||||
//
|
||||
btnReprint.Font = new Font("微软雅黑", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
btnReprint.ForeColor = SystemColors.ControlDarkDark;
|
||||
btnReprint.Location = new Point(670, 5);
|
||||
btnReprint.Name = "btnReprint";
|
||||
btnReprint.Size = new Size(190, 44);
|
||||
btnReprint.TabIndex = 17;
|
||||
btnReprint.Text = "重新打印当前";
|
||||
btnReprint.UseVisualStyleBackColor = true;
|
||||
btnReprint.Click += btnReprint_Click;
|
||||
//
|
||||
// frmMain
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
@@ -1102,5 +1118,6 @@ namespace FATrace.App
|
||||
private PictureBox pictureBox4;
|
||||
private TextBox txtOpName;
|
||||
private Label label28;
|
||||
private Button btnReprint;
|
||||
}
|
||||
}
|
||||
@@ -664,23 +664,24 @@ namespace FATrace.App
|
||||
|
||||
//确认数据
|
||||
// 显示消息框,并等待用户响应
|
||||
DialogResult result = MessageBox.Show("确定要【打印】操作吗?", "确认操作", MessageBoxButtons.OKCancel);
|
||||
if (result==DialogResult.Cancel)
|
||||
DialogResult result = frmMessage.ShowConfirm("确定要【打印】操作吗?", "确认操作", this);
|
||||
if (result == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurWeight<2.0)
|
||||
if (CurWeight < 2.0)
|
||||
{
|
||||
//确认数据
|
||||
// 显示消息框,并等待用户响应
|
||||
DialogResult resultWeightCheck = MessageBox.Show("检测到当前的重量小于2g,确定要【打印】操作吗?", "确认操作", MessageBoxButtons.OKCancel);
|
||||
DialogResult resultWeightCheck = frmMessage.ShowConfirm("检测到当前的重量小于2g,确定要【打印】操作吗?", "确认操作", this);
|
||||
if (resultWeightCheck == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//新的剩余重量 Kg
|
||||
var NewRemainWeight = CurSelectedRawProInput.RemainWeight - CurWeight / 1000.0;
|
||||
|
||||
@@ -726,7 +727,7 @@ namespace FATrace.App
|
||||
RawName = CurSelectedRawProInput.RawName,
|
||||
RemainWeight = NewRemainWeight,
|
||||
Weight = CurWeight,
|
||||
DeliveryDate= DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
DeliveryDate = DateTime.Now.ToString("yyyy-MM-dd"),
|
||||
WeightTime = DateTime.Now,
|
||||
StockWeight = CurSelectedRawProInput.Weight,
|
||||
}).ExecuteAffrows();
|
||||
@@ -786,13 +787,19 @@ namespace FATrace.App
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 格式化重量显示,整数部分至少2位(不足补0),小数部分固定2位
|
||||
/// 格式化重量显示,自动适配整数部分位数(2-4位),小数部分固定2位
|
||||
/// </summary>
|
||||
/// <param name="weight">原始重量值</param>
|
||||
/// <returns>格式化后的重量字符串(如:09.50, 81.10, 100.00)</returns>
|
||||
/// /// <returns>格式化后的重量字符串(如:09.50, 81.10, 100.00, 1000.00)</returns>
|
||||
private string FormatWeight(double weight)
|
||||
{
|
||||
return weight.ToString("00.00");
|
||||
// 根据重量值大小决定格式
|
||||
if (weight >= 1000)
|
||||
return weight.ToString("0000.00"); // 四位整数:1000.00-9999.99
|
||||
else if (weight >= 100)
|
||||
return weight.ToString("000.00"); // 三位整数:100.00-999.99
|
||||
else
|
||||
return weight.ToString("00.00"); // 两位整数:00.00-99.99
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1276,5 +1283,62 @@ namespace FATrace.App
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重新打印之前最新的一个
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void btnReprint_Click(object sender, EventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (CurSelectedRawProInput == null)
|
||||
{
|
||||
MessageBox.Show("请先选择要称重的产品", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
var LastData = FSqlContext.FDb.Select<RawProUse>().OrderByDescending(a => a.WeightTime).First();
|
||||
if (LastData == null)
|
||||
{
|
||||
MessageBox.Show("没有找到最新的消息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
return;
|
||||
}
|
||||
|
||||
// 显示消息框,并等待用户响应
|
||||
DialogResult result = frmMessage.ShowConfirm($"确定要【重复打印】{LastData.InBagCode} 条码数据吗?", "确认操作", this);
|
||||
if (result == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// 执行打印
|
||||
try
|
||||
{
|
||||
UpdateStatusLabel(tslPrintState, "正在打印...", Color.Goldenrod, Color.White);
|
||||
CurZebraPrint.PrintWeight(LastData.InBagCode!, CurSelectedRawProInput.RawName!,
|
||||
CurWeight,
|
||||
CurSelectedRawProInput.Batch!,
|
||||
CurSelectedRawProInput.ShelfLife
|
||||
);
|
||||
SetPrinterStatusOk("打印成功");
|
||||
logger.Info($"打印成功:{CurSelectedRawProInput.RawName} {CurWeight}g 批号{CurSelectedRawProInput.Batch}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
SetPrinterStatusFail($"打印失败:{ex.Message}");
|
||||
logger.Error(ex, "打印失败");
|
||||
MessageBox.Show($"打印失败:{ex.Message}", "打印机错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
94
FATrace.App/frmMessage.Designer.cs
generated
Normal file
94
FATrace.App/frmMessage.Designer.cs
generated
Normal file
@@ -0,0 +1,94 @@
|
||||
namespace FATrace.App
|
||||
{
|
||||
partial class frmMessage
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmMessage));
|
||||
lblMessage = new Label();
|
||||
btnTrue = new Button();
|
||||
bntCancel = new Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// lblMessage
|
||||
//
|
||||
lblMessage.Font = new Font("微软雅黑", 21.75F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
lblMessage.ForeColor = Color.Blue;
|
||||
lblMessage.Location = new Point(22, 36);
|
||||
lblMessage.Name = "lblMessage";
|
||||
lblMessage.Size = new Size(710, 165);
|
||||
lblMessage.TabIndex = 0;
|
||||
lblMessage.Text = "消息内容";
|
||||
lblMessage.TextAlign = ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// btnTrue
|
||||
//
|
||||
btnTrue.Font = new Font("Microsoft YaHei UI", 21.75F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
btnTrue.ForeColor = SystemColors.ControlDarkDark;
|
||||
btnTrue.Location = new Point(180, 246);
|
||||
btnTrue.Name = "btnTrue";
|
||||
btnTrue.Size = new Size(146, 66);
|
||||
btnTrue.TabIndex = 1;
|
||||
btnTrue.Text = "确 认";
|
||||
btnTrue.UseVisualStyleBackColor = true;
|
||||
btnTrue.Click += btnTrue_Click;
|
||||
//
|
||||
// bntCancel
|
||||
//
|
||||
bntCancel.Font = new Font("Microsoft YaHei UI", 21.75F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
bntCancel.ForeColor = SystemColors.ControlDarkDark;
|
||||
bntCancel.Location = new Point(384, 246);
|
||||
bntCancel.Name = "bntCancel";
|
||||
bntCancel.Size = new Size(146, 66);
|
||||
bntCancel.TabIndex = 2;
|
||||
bntCancel.Text = "取 消";
|
||||
bntCancel.UseVisualStyleBackColor = true;
|
||||
bntCancel.Click += bntCancel_Click;
|
||||
//
|
||||
// frmMessage
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(744, 398);
|
||||
Controls.Add(bntCancel);
|
||||
Controls.Add(btnTrue);
|
||||
Controls.Add(lblMessage);
|
||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||
MaximizeBox = false;
|
||||
MinimizeBox = false;
|
||||
Name = "frmMessage";
|
||||
Text = "消息确认";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Label lblMessage;
|
||||
private Button btnTrue;
|
||||
private Button bntCancel;
|
||||
}
|
||||
}
|
||||
67
FATrace.App/frmMessage.cs
Normal file
67
FATrace.App/frmMessage.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace FATrace.App
|
||||
{
|
||||
public partial class frmMessage : Form
|
||||
{
|
||||
public frmMessage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
FormBorderStyle = FormBorderStyle.FixedDialog;
|
||||
ShowInTaskbar = false;
|
||||
AcceptButton = btnTrue;
|
||||
CancelButton = bntCancel;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示确认对话框(OK/Cancel)。
|
||||
/// </summary>
|
||||
/// <param name="message">提示内容</param>
|
||||
/// <param name="title">标题</param>
|
||||
/// <param name="owner">父窗口</param>
|
||||
/// <returns>DialogResult.OK 表示确认;DialogResult.Cancel 表示取消</returns>
|
||||
public static DialogResult ShowConfirm(string message, string title = "确认操作", IWin32Window? owner = null)
|
||||
{
|
||||
using (var f = new frmMessage())
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(title))
|
||||
f.Text = title;
|
||||
|
||||
f.SetMessageText(message);
|
||||
|
||||
return owner == null ? f.ShowDialog() : f.ShowDialog(owner);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置提示文本。
|
||||
/// </summary>
|
||||
/// <param name="message">提示内容</param>
|
||||
private void SetMessageText(string message)
|
||||
{
|
||||
lblMessage.Text = (message ?? string.Empty).Trim();
|
||||
}
|
||||
|
||||
private void btnTrue_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void bntCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
1253
FATrace.App/frmMessage.resx
Normal file
1253
FATrace.App/frmMessage.resx
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user