屠宰场客户端
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.

74 lines
2.3 KiB

using BO.BO.Bill;
using BO.Utils.BillRpc;
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 OutHouseView
{
public partial class ViewDetail : Form
{
List<BeforeDeathDetail> details;
static bool changed = false;
public ViewDetail(long id)
{
InitializeComponent();
detailGridView1.AutoGenerateColumns = false;
details = OrderDetailRpc.GetBeforeDeathDetails(id).OrderByDescending(x => x.ID).ToList();
detailGridView1.DataSource = null;
detailGridView1.DataSource = details;
InitScrollBar1();
detailGridView1.Refresh();
numLbl.Text = TotalNumber.ToString();
lineCountLbl.Text = details.Count.ToString();
}
private void closeBtn_Click(object sender, EventArgs e)
{
if (changed)
DialogResult = DialogResult.OK;
this.Close();
}
public int TotalNumber { get { return details.Sum(x => x.Number); } }
private void detailGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
{
if (e.RowIndex == -1)
return;
if (e.ColumnIndex != detailGridView1.ColumnCount - 1)
return;
var id = (long)detailGridView1.CurrentRow.Cells["C_ID"].Value;
OrderDetailRpc.DeleteBeforeDeathDetail(id);
details.RemoveAll(x => x.ID == id);
numLbl.Text = TotalNumber.ToString();
lineCountLbl.Text = details.Count.ToString();
if (!changed)
changed = true;
detailGridView1.DataSource = null;
if (details.Any())
detailGridView1.DataSource = details;
detailGridView1.Refresh();
}
private void InitScrollBar1()
{
vScrollBar1.Maximum = (detailGridView1.RowCount - detailGridView1.DisplayedRowCount(false) + 30) * detailGridView1.RowTemplate.Height;
vScrollBar1.Minimum = 0;
vScrollBar1.SmallChange = detailGridView1.RowTemplate.Height;
vScrollBar1.LargeChange = detailGridView1.RowTemplate.Height * 30;
this.vScrollBar1.Scroll += (sender, e) =>
{
var roll = e.NewValue / detailGridView1.RowTemplate.Height;
detailGridView1.FirstDisplayedScrollingRowIndex = roll;
};
}
}
}