You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.2 KiB

using EC.AutoWeightServer.Center;
using EC.AutoWeightServer.Model.State;
using System.Windows.Forms;
namespace EC.AutoWeightServer.UI
{
public partial class FrmBill : Form
{
private FrmMainServer _mainServer;
public FrmBill()
{
InitializeComponent();
BindData();
}
public FrmBill(FrmMainServer server)
{
InitializeComponent();
_mainServer = server;
BindData();
}
public void BindData()
{
var billList = ServiceCenter.BillService.GetTodayBillList();
foreach (var bill in billList)
{
var index = dataGridView.Rows.Add();
var i = 0;
dataGridView.Rows[index].Cells[i++].Value = bill.SerialNumber;
dataGridView.Rows[index].Cells[i++].Value = bill.SiteName;
dataGridView.Rows[index].Cells[i++].Value = bill.SupplierName;
dataGridView.Rows[index].Cells[i++].Value = bill.MaterialNo;
dataGridView.Rows[index].Cells[i++].Value = bill.LicensePlate;
dataGridView.Rows[index].Cells[i++].Value = bill.TrailerPlate;
dataGridView.Rows[index].Cells[i++].Value = bill.DriverName;
dataGridView.Rows[index].Cells[i++].Value = bill.Driver2Name;
dataGridView.Rows[index].Cells[i++].Value = bill.BillWeight;
dataGridView.Rows[index].Cells[i++].Value = bill.InWeight;
dataGridView.Rows[index].Cells[i++].Value = bill.OutWeight;
dataGridView.Rows[index].Cells[i++].Value = bill.NetWeight;
dataGridView.Rows[index].Cells[i++].Value = bill.InStartTime;
dataGridView.Rows[index].Cells[i++].Value = bill.OutStartTime;
dataGridView.Rows[index].Cells[i++].Value = BillStateExt.GetBillStateDesc(bill.State);
}
var btn = new DataGridViewButtonColumn
{
Name = "btnPrint",
HeaderText = "操作",
DefaultCellStyle = { NullValue = "打印" }
};
dataGridView.Columns.Add(btn);
}
private void dataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex < 0 || dataGridView.CurrentRow == null) return;
if (dataGridView.Columns[e.ColumnIndex].Name == "btnPrint")
{
if (_mainServer == null) return;
var cell = dataGridView.CurrentRow.Cells;
var billEntity = ServiceCenter.BillService.GetBillBySerialNumber(cell[0].Value.ToString());
_mainServer.DeviceCenter.PrintBill(billEntity);
}
}
}
}