using BO.BO.Bill;
|
|
using BO.Utils;
|
|
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;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace OrderConfirm
|
|
{
|
|
public partial class OrderConfirmForm : Form, IAfterLogin
|
|
{
|
|
#region IAfterLogin
|
|
public string RoleName
|
|
{
|
|
get { return "窒晕员"; }
|
|
}
|
|
|
|
public Form Generate()
|
|
{
|
|
return this;
|
|
}
|
|
|
|
#endregion
|
|
|
|
private delegate void InvokeHandler();
|
|
List<ConfirmOrder> list;
|
|
Thread syncThread;
|
|
public OrderConfirmForm()
|
|
{
|
|
InitializeComponent();
|
|
uDatePicker1.Date = DateTime.Today;
|
|
uDataGridView1.AutoGenerateColumns = false;
|
|
uDataGridView1.DataSource = null;
|
|
this.FormClosing += delegate
|
|
{
|
|
if (syncThread != null && syncThread.IsAlive)
|
|
syncThread.Abort();
|
|
};
|
|
}
|
|
|
|
private void syncBtn_Click(object sender, EventArgs e)
|
|
{
|
|
if (syncThread == null || !syncThread.IsAlive)
|
|
{
|
|
syncThread = new Thread(SyncTask);
|
|
syncThread.Start();
|
|
syncBtn.BackColor = Color.FromArgb(15, 215, 107);
|
|
syncBtn.ForeColor = Color.White;
|
|
}
|
|
else
|
|
{
|
|
syncThread.Abort();
|
|
syncBtn.BackColor = Color.FromKnownColor(KnownColor.Control);
|
|
syncBtn.ForeColor = Color.FromKnownColor(KnownColor.ControlText);
|
|
}
|
|
}
|
|
|
|
private void SyncTask()
|
|
{
|
|
while (true)
|
|
{
|
|
this.Invoke(new InvokeHandler(delegate()
|
|
{
|
|
list = OrderConfirmRpc.GetConfirmOrder(uDatePicker1.Date.Value);
|
|
BindOrderGrid();
|
|
}));
|
|
Thread.Sleep(5000);
|
|
}
|
|
}
|
|
|
|
ConfirmOrder last;
|
|
private void BindOrderGrid()
|
|
{
|
|
uDataGridView1.DataSource = list.OrderByDescending(x => x.Order).OrderBy(x => x.Confirmed).ToList();
|
|
if (last == null && uDataGridView1.CurrentRow != null)
|
|
{
|
|
last = uDataGridView1.CurrentRow.DataBoundItem as ConfirmOrder;
|
|
if (last.Confirmed)
|
|
{
|
|
last = null;
|
|
uDataGridView1.CurrentRow.DefaultCellStyle.BackColor = Color.YellowGreen;
|
|
}
|
|
}
|
|
foreach (DataGridViewRow row in uDataGridView1.Rows)
|
|
{
|
|
if ((bool)row.Cells["C_Confirmed"].Value)
|
|
row.DefaultCellStyle.BackColor = Color.YellowGreen;
|
|
if (last != null && last.ID == (long)row.Cells["C_ID"].Value)
|
|
{
|
|
last = row.DataBoundItem as ConfirmOrder;
|
|
if (last.Confirmed)
|
|
row.DefaultCellStyle.BackColor = Color.Yellow;
|
|
else
|
|
row.DefaultCellStyle.BackColor = uDataGridView1.RowsDefaultCellStyle.SelectionBackColor;
|
|
}
|
|
}
|
|
if (last != null && !last.Confirmed)
|
|
orderLabel.Text = last.Order.ToString();
|
|
else
|
|
orderLabel.Text = "0";
|
|
InitScrollBar1();
|
|
uDataGridView1.ClearSelection();
|
|
try
|
|
{
|
|
if (roll != -1)
|
|
uDataGridView1.FirstDisplayedScrollingRowIndex = roll;
|
|
}
|
|
catch
|
|
{
|
|
roll = -1;
|
|
}
|
|
uDataGridView1.Refresh();
|
|
}
|
|
|
|
private void existBtn_Click(object sender, EventArgs e)
|
|
{
|
|
this.Close();
|
|
}
|
|
|
|
int roll = -1;
|
|
private void InitScrollBar1()
|
|
{
|
|
vScrollBar1.Maximum = (uDataGridView1.RowCount - uDataGridView1.DisplayedRowCount(false) + 30) * uDataGridView1.RowTemplate.Height;
|
|
vScrollBar1.Minimum = 0;
|
|
vScrollBar1.SmallChange = uDataGridView1.RowTemplate.Height;
|
|
vScrollBar1.LargeChange = uDataGridView1.RowTemplate.Height * 30;
|
|
this.vScrollBar1.Scroll += (sender, e) =>
|
|
{
|
|
roll = e.NewValue / uDataGridView1.RowTemplate.Height;
|
|
uDataGridView1.FirstDisplayedScrollingRowIndex = roll;
|
|
};
|
|
}
|
|
|
|
private void uDataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex == -1)
|
|
return;
|
|
var entity = uDataGridView1.CurrentRow.DataBoundItem as ConfirmOrder;
|
|
if (e.ColumnIndex != uDataGridView1.Columns.Count - 1)//非确定列
|
|
{
|
|
if (last != null)
|
|
{
|
|
foreach (DataGridViewRow row in uDataGridView1.Rows)
|
|
{
|
|
if (last.ID == (long)row.Cells["C_ID"].Value)
|
|
{
|
|
row.DefaultCellStyle.BackColor = last.Confirmed ? Color.YellowGreen : uDataGridView1.RowsDefaultCellStyle.BackColor;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
last = entity;
|
|
uDataGridView1.CurrentRow.DefaultCellStyle.SelectionBackColor = last.Confirmed ? Color.Yellow : uDataGridView1.RowsDefaultCellStyle.SelectionBackColor;
|
|
this.orderLabel.Text = last.Order.ToString();
|
|
}
|
|
else//确定列
|
|
{
|
|
uDataGridView1.CurrentRow.DefaultCellStyle.SelectionBackColor = last.Confirmed ? Color.YellowGreen : uDataGridView1.RowsDefaultCellStyle.BackColor;
|
|
last = null;
|
|
}
|
|
uDataGridView1.Refresh();
|
|
}
|
|
|
|
private void uDataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
|
{
|
|
if (e.RowIndex == -1)
|
|
return;
|
|
if (e.ColumnIndex == uDataGridView1.ColumnCount - 1)//确定
|
|
{
|
|
var entity = uDataGridView1.CurrentRow.DataBoundItem as ConfirmOrder;
|
|
if (entity.Confirmed)
|
|
return;
|
|
entity.Confirmed = true;
|
|
OrderConfirmRpc.SetOrderConfirmed(entity.ID);
|
|
BindOrderGrid();
|
|
}
|
|
}
|
|
}
|
|
}
|