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.
 
 

68 lines
1.7 KiB

using ButcherFactory.BO;
using ButcherFactory.BO.LocalBL;
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 ButcherFactory.Dialogs
{
public partial class WeightRecordDialog : Form
{
BindingList<CarcassSaleOut_Detail> list;
SaleOutStore_Detail mDetail;
long? mBatchID = null;
public bool Changed = false;
public WeightRecordDialog(SaleOutStore_Detail detail, bool readOnly,long? batchID)
{
InitializeComponent();
mDetail = detail;
mBatchID = batchID;
if (readOnly)
{
addBtn.Enabled = false;
deleteBtn.Enabled = true;
}
uDataGridView1.BorderStyle = BorderStyle.FixedSingle;
BindGrid();
}
void BindGrid()
{
list = CarcassSaleOutBL.GetWeightRecord(mDetail.ID);
uDataGridView1.DataSource = list;
uDataGridView1.Refresh();
weightLabel.Text = string.Format("{0:#0.######} KG", list.Sum(x => x.Weight));
}
private void addBtn_Click(object sender, EventArgs e)
{
if (new AddWeightRecord(mDetail,mBatchID).ShowDialog() == DialogResult.OK)
{
BindGrid();
Changed = true;
}
}
private void deleteBtn_Click(object sender, EventArgs e)
{
if(uDataGridView1.CurrentRow==null)
return;
var id = (long)uDataGridView1.CurrentRow.Cells[0].Value;
var tag = list.First(x => x.ID == id);
CarcassSaleOutBL.DeleteAndUpdate(tag);
BindGrid();
Changed = true;
}
private void closeBtn_Click(object sender, EventArgs e)
{
Close();
}
}
}