|
|
|
@ -62,242 +62,242 @@ namespace B3DealerClient.Windows.CarcassSaleOutWindow_ |
|
|
|
pageSize = (int)customerPanel.ActualHeight / 60; |
|
|
|
} |
|
|
|
|
|
|
|
private void NumberBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var numberPad = new NumberPad(this); |
|
|
|
if (numberPad.ShowDialog() == true) |
|
|
|
private void NumberBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
decimal value = 0; |
|
|
|
if (!string.IsNullOrEmpty(numberPad.Result) && !decimal.TryParse(numberPad.Result, out value)) |
|
|
|
throw new Exception("输入错误"); |
|
|
|
|
|
|
|
var name = (sender as TextBox).Name; |
|
|
|
switch (name) |
|
|
|
var numberPad = new NumberPad(this); |
|
|
|
if (numberPad.ShowDialog() == true) |
|
|
|
{ |
|
|
|
case "hook": |
|
|
|
context.HookWeight = value; |
|
|
|
config.HookWeight = value; |
|
|
|
break; |
|
|
|
//case "number":
|
|
|
|
// context.Number = value;
|
|
|
|
// config.Number = value;
|
|
|
|
// break;
|
|
|
|
decimal value = 0; |
|
|
|
if (!string.IsNullOrEmpty(numberPad.Result) && !decimal.TryParse(numberPad.Result, out value)) |
|
|
|
throw new Exception("输入错误"); |
|
|
|
|
|
|
|
var name = (sender as TextBox).Name; |
|
|
|
switch (name) |
|
|
|
{ |
|
|
|
case "hook": |
|
|
|
context.HookWeight = value; |
|
|
|
config.HookWeight = value; |
|
|
|
break; |
|
|
|
//case "number":
|
|
|
|
// context.Number = value;
|
|
|
|
// config.Number = value;
|
|
|
|
// break;
|
|
|
|
} |
|
|
|
XmlUtil.SerializerObjToFile(config); |
|
|
|
} |
|
|
|
XmlUtil.SerializerObjToFile(config); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var tb = sender as FrameworkElement; |
|
|
|
var dig = new BaseInfoDialog(tb.Name); |
|
|
|
if (dig.ShowDialog() == true) |
|
|
|
private void BaseInfoBox_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
switch (tb.Name) |
|
|
|
var tb = sender as FrameworkElement; |
|
|
|
var dig = new BaseInfoDialog(tb.Name); |
|
|
|
if (dig.ShowDialog() == true) |
|
|
|
{ |
|
|
|
case "DriverGoodsLine": |
|
|
|
context.DriverGoodsLine.Fill(dig.Result); |
|
|
|
pageIndex = 0; |
|
|
|
BindCustomerPanel(); |
|
|
|
break; |
|
|
|
case "Store": |
|
|
|
context.Store.Fill(dig.Result); |
|
|
|
config.Store = dig.Result; |
|
|
|
XmlUtil.SerializerObjToFile(config); |
|
|
|
break; |
|
|
|
switch (tb.Name) |
|
|
|
{ |
|
|
|
case "DriverGoodsLine": |
|
|
|
context.DriverGoodsLine.Fill(dig.Result); |
|
|
|
pageIndex = 0; |
|
|
|
BindCustomerPanel(); |
|
|
|
break; |
|
|
|
case "Store": |
|
|
|
context.Store.Fill(dig.Result); |
|
|
|
config.Store = dig.Result; |
|
|
|
XmlUtil.SerializerObjToFile(config); |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void BindCustomerPanel() |
|
|
|
{ |
|
|
|
context.CustomerList = CarcassSaleOutBL.GetCustomers(new |
|
|
|
{ |
|
|
|
Date = context.Date, |
|
|
|
Store_ID = context.Store.ID, |
|
|
|
DeliverGoodsLine_ID = context.DriverGoodsLine.ID, |
|
|
|
PageIndex = pageIndex, |
|
|
|
PageSize = pageSize |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
private void PageBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var tag = (sender as Button).Tag.ToString(); |
|
|
|
if (tag == "0") |
|
|
|
{ |
|
|
|
if (pageIndex == 0) |
|
|
|
return; |
|
|
|
pageIndex -= 1; |
|
|
|
BindCustomerPanel(); |
|
|
|
} |
|
|
|
else |
|
|
|
void BindCustomerPanel() |
|
|
|
{ |
|
|
|
if (context.CustomerList == null || context.CustomerList.Count < pageSize) |
|
|
|
return; |
|
|
|
pageIndex += 1; |
|
|
|
BindCustomerPanel(); |
|
|
|
context.CustomerList = CarcassSaleOutBL.GetCustomers(new |
|
|
|
{ |
|
|
|
Date = context.Date, |
|
|
|
Store_ID = context.Store.ID, |
|
|
|
DeliverGoodsLine_ID = context.DriverGoodsLine.ID, |
|
|
|
PageIndex = pageIndex, |
|
|
|
PageSize = pageSize |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void NumberBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var c = (sender as Button).Content.ToString(); |
|
|
|
switch (c) |
|
|
|
private void PageBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
case "0": |
|
|
|
context.StrNumber = "0"; |
|
|
|
break; |
|
|
|
case "./点": |
|
|
|
if (string.IsNullOrEmpty(context.StrNumber)) |
|
|
|
context.StrNumber = "0."; |
|
|
|
else if (context.StrNumber.Contains('.')) |
|
|
|
var tag = (sender as Button).Tag.ToString(); |
|
|
|
if (tag == "0") |
|
|
|
{ |
|
|
|
if (pageIndex == 0) |
|
|
|
return; |
|
|
|
else |
|
|
|
context.StrNumber += "."; |
|
|
|
break; |
|
|
|
default: |
|
|
|
if (context.StrNumber == "0") |
|
|
|
context.StrNumber = c; |
|
|
|
else |
|
|
|
context.StrNumber += c; |
|
|
|
break; |
|
|
|
pageIndex -= 1; |
|
|
|
BindCustomerPanel(); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
if (context.CustomerList == null || context.CustomerList.Count < pageSize) |
|
|
|
return; |
|
|
|
pageIndex += 1; |
|
|
|
BindCustomerPanel(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void CustomerBtn_PriviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
if (context.Dmo != null) |
|
|
|
context.Dmo = null; |
|
|
|
if (context.Detail != null) |
|
|
|
context.Detail = null; |
|
|
|
if (context.Details.Any()) |
|
|
|
context.Details.Clear(); |
|
|
|
private void NumberBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var c = (sender as Button).Content.ToString(); |
|
|
|
switch (c) |
|
|
|
{ |
|
|
|
case "0": |
|
|
|
context.StrNumber = "0"; |
|
|
|
break; |
|
|
|
case "./点": |
|
|
|
if (string.IsNullOrEmpty(context.StrNumber)) |
|
|
|
context.StrNumber = "0."; |
|
|
|
else if (context.StrNumber.Contains('.')) |
|
|
|
return; |
|
|
|
else |
|
|
|
context.StrNumber += "."; |
|
|
|
break; |
|
|
|
default: |
|
|
|
if (context.StrNumber == "0") |
|
|
|
context.StrNumber = c; |
|
|
|
else |
|
|
|
context.StrNumber += c; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var obj = (sender as ListBoxItem).DataContext as CustomerObj; |
|
|
|
context.DmoList = CarcassSaleOutBL.GetDmoList(new |
|
|
|
private void CustomerBtn_PriviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
Date = context.Date, |
|
|
|
Customer_ID = obj.ID, |
|
|
|
Store_ID = context.Store.ID, |
|
|
|
AssignFinished = obj.Finished |
|
|
|
}); |
|
|
|
if (context.Dmo != null) |
|
|
|
context.Dmo = null; |
|
|
|
if (context.Detail != null) |
|
|
|
context.Detail = null; |
|
|
|
if (context.Details.Any()) |
|
|
|
context.Details.Clear(); |
|
|
|
|
|
|
|
var obj = (sender as ListBoxItem).DataContext as CustomerObj; |
|
|
|
context.DmoList = CarcassSaleOutBL.GetDmoList(new |
|
|
|
{ |
|
|
|
Date = context.Date, |
|
|
|
Customer_ID = obj.ID, |
|
|
|
Store_ID = context.Store.ID, |
|
|
|
AssignFinished = obj.Finished |
|
|
|
}); |
|
|
|
|
|
|
|
foreach (var item in context.CustomerList) |
|
|
|
foreach (var item in context.CustomerList) |
|
|
|
{ |
|
|
|
if (item.Selected && !item.Equals(obj)) |
|
|
|
item.Selected = false; |
|
|
|
else if (!item.Selected && item.Equals(obj)) |
|
|
|
item.Selected = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void MainGridFocus(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
if (item.Selected && !item.Equals(obj)) |
|
|
|
item.Selected = false; |
|
|
|
else if (!item.Selected && item.Equals(obj)) |
|
|
|
item.Selected = true; |
|
|
|
var row = sender as DataGridRow; |
|
|
|
context.Dmo = row.Item as CarcassSaleOut; |
|
|
|
foreach (var item in context.DmoList) |
|
|
|
{ |
|
|
|
if (item.Selected && item.ID != context.Dmo.ID) |
|
|
|
item.Selected = false; |
|
|
|
else if (item.Selected && item.ID == context.Dmo.ID) |
|
|
|
context.Dmo.Selected = true; |
|
|
|
} |
|
|
|
MainSelected(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void MainGridFocus(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var row = sender as DataGridRow; |
|
|
|
context.Dmo = row.Item as CarcassSaleOut; |
|
|
|
foreach (var item in context.DmoList) |
|
|
|
void MainSelected() |
|
|
|
{ |
|
|
|
if (item.Selected && item.ID != context.Dmo.ID) |
|
|
|
item.Selected = false; |
|
|
|
else if (item.Selected && item.ID == context.Dmo.ID) |
|
|
|
context.Dmo.Selected = true; |
|
|
|
context.Details.Clear(); |
|
|
|
var details = CarcassSaleOutBL.GetDetailRecords(context.Dmo.DetailID); |
|
|
|
foreach (var item in details) |
|
|
|
context.Details.Add(item); |
|
|
|
context.Detail = context.Details.FirstOrDefault(); |
|
|
|
DetailSelected(); |
|
|
|
} |
|
|
|
MainSelected(); |
|
|
|
} |
|
|
|
|
|
|
|
void MainSelected() |
|
|
|
{ |
|
|
|
context.Details.Clear(); |
|
|
|
var details = CarcassSaleOutBL.GetDetailRecords(context.Dmo.DetailID); |
|
|
|
foreach (var item in details) |
|
|
|
context.Details.Add(item); |
|
|
|
context.Detail = context.Details.FirstOrDefault(); |
|
|
|
DetailSelected(); |
|
|
|
} |
|
|
|
private void DetailGridFocus(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var row = sender as DataGridRow; |
|
|
|
context.Detail = row.Item as CarcassSaleOut_Record; |
|
|
|
DetailSelected(); |
|
|
|
} |
|
|
|
|
|
|
|
private void DetailGridFocus(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var row = sender as DataGridRow; |
|
|
|
context.Detail = row.Item as CarcassSaleOut_Record; |
|
|
|
DetailSelected(); |
|
|
|
} |
|
|
|
void DetailSelected() |
|
|
|
{ |
|
|
|
if (context.Detail == null) |
|
|
|
return; |
|
|
|
|
|
|
|
void DetailSelected() |
|
|
|
{ |
|
|
|
if (context.Detail == null) |
|
|
|
return; |
|
|
|
foreach (var item in context.Details) |
|
|
|
{ |
|
|
|
if (item.Selected && item.ID != context.Detail.ID) |
|
|
|
item.Selected = false; |
|
|
|
else if (!item.Selected && item.ID == context.Detail.ID) |
|
|
|
item.Selected = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
foreach (var item in context.Details) |
|
|
|
private void DeleteBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
if (item.Selected && item.ID != context.Detail.ID) |
|
|
|
item.Selected = false; |
|
|
|
else if (!item.Selected && item.ID == context.Detail.ID) |
|
|
|
item.Selected = true; |
|
|
|
var confirm = MessageBox.Show("确定要删除选中记录吗?", "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (confirm == MessageBoxResult.OK) |
|
|
|
{ |
|
|
|
CarcassSaleOutBL.Delete(context.Detail.ID); |
|
|
|
context.Details.Remove(context.Detail); |
|
|
|
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) - context.Detail.NetWeight; |
|
|
|
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) - context.Detail.SecondNumber; |
|
|
|
context.Detail = context.Details.FirstOrDefault(); |
|
|
|
DetailSelected(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void DeleteBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var confirm = MessageBox.Show("确定要删除选中记录吗?", "删除确认", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (confirm == MessageBoxResult.OK) |
|
|
|
private void SaveBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
CarcassSaleOutBL.Delete(context.Detail.ID); |
|
|
|
context.Details.Remove(context.Detail); |
|
|
|
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) - context.Detail.NetWeight; |
|
|
|
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) - context.Detail.SecondNumber; |
|
|
|
context.Detail = context.Details.FirstOrDefault(); |
|
|
|
var record = new CarcassSaleOut_Record(); |
|
|
|
record.MainID = context.Dmo.ID; |
|
|
|
record.DetailID = context.Dmo.DetailID; |
|
|
|
record.Goods_Name = context.Dmo.Goods_Name; |
|
|
|
record.Weight = context.Weight; |
|
|
|
record.SecondNumber = context.Number; |
|
|
|
record.Discont = (context.HookWeight ?? 0) * Math.Ceiling(record.SecondNumber); |
|
|
|
record.NetWeight = record.Weight - record.Discont; |
|
|
|
record.Date = DateTime.Now; |
|
|
|
record.Selected = true; |
|
|
|
CarcassSaleOutBL.InsertRecord(record); |
|
|
|
context.Details.Add(record); |
|
|
|
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) + record.NetWeight; |
|
|
|
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) + record.SecondNumber; |
|
|
|
context.Detail = record; |
|
|
|
DetailSelected(); |
|
|
|
weightControl.Weight = 0; |
|
|
|
context.Weight = 0; |
|
|
|
context.StrNumber = string.Empty; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void SaveBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var record = new CarcassSaleOut_Record(); |
|
|
|
record.MainID = context.Dmo.ID; |
|
|
|
record.DetailID = context.Dmo.DetailID; |
|
|
|
record.Goods_Name = context.Dmo.Goods_Name; |
|
|
|
record.Weight = context.Weight; |
|
|
|
record.SecondNumber = context.Number; |
|
|
|
record.Discont = (context.HookWeight ?? 0) * Math.Ceiling(record.SecondNumber); |
|
|
|
record.NetWeight = record.Weight - record.Discont; |
|
|
|
record.Date = DateTime.Now; |
|
|
|
record.Selected = true; |
|
|
|
CarcassSaleOutBL.InsertRecord(record); |
|
|
|
context.Details.Add(record); |
|
|
|
context.Dmo.AlreadyNumber = (context.Dmo.AlreadyNumber ?? 0) + record.NetWeight; |
|
|
|
context.Dmo.AlreadySecondNumber = (context.Dmo.AlreadySecondNumber ?? 0) + record.SecondNumber; |
|
|
|
context.Detail = record; |
|
|
|
DetailSelected(); |
|
|
|
weightControl.Weight = 0; |
|
|
|
context.Weight = 0; |
|
|
|
context.StrNumber = string.Empty; |
|
|
|
} |
|
|
|
|
|
|
|
private void ViewBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
new RecordViewDialog(context.Dmo.ID).ShowDialog(); |
|
|
|
} |
|
|
|
|
|
|
|
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
private void ViewBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
new RecordViewDialog(context.Dmo.ID).ShowDialog(); |
|
|
|
} |
|
|
|
|
|
|
|
var targets = context.DmoList.Where(x => x.ID == context.Dmo.ID); |
|
|
|
var needConfirm = targets.Any(x => (x.AlreadyNumber ?? 0) == 0 || (x.SecondNumber ?? 0) == 0); |
|
|
|
if (needConfirm) |
|
|
|
private void FinishBtn_PreviewMouseDown(object sender, MouseButtonEventArgs e) |
|
|
|
{ |
|
|
|
var confirm = MessageBox.Show("存在未配货的明细,确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (confirm != MessageBoxResult.OK) |
|
|
|
|
|
|
|
var targets = context.DmoList.Where(x => x.ID == context.Dmo.ID); |
|
|
|
var needConfirm = targets.Any(x => (x.AlreadyNumber ?? 0) == 0 || (x.SecondNumber ?? 0) == 0); |
|
|
|
if (needConfirm) |
|
|
|
{ |
|
|
|
var confirm = MessageBox.Show("存在未配货的明细,确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (confirm != MessageBoxResult.OK) |
|
|
|
return; |
|
|
|
} |
|
|
|
var r = MessageBox.Show("确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (r != MessageBoxResult.OK) |
|
|
|
return; |
|
|
|
CarcassSaleOutBL.FinishAssign(context.Dmo.ID); |
|
|
|
foreach (var item in targets) |
|
|
|
item.AssignFinished = true; |
|
|
|
context.Dmo = context.Dmo; |
|
|
|
MessageBox.Show("配货完成"); |
|
|
|
} |
|
|
|
var r = MessageBox.Show("确认配货完成?", "配货完成确认", MessageBoxButton.OKCancel, MessageBoxImage.Question); |
|
|
|
if (r != MessageBoxResult.OK) |
|
|
|
return; |
|
|
|
CarcassSaleOutBL.FinishAssign(context.Dmo.ID); |
|
|
|
foreach (var item in targets) |
|
|
|
item.AssignFinished = true; |
|
|
|
context.Finish = true; |
|
|
|
MessageBox.Show("配货完成"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |