You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
334 lines
14 KiB
C#
334 lines
14 KiB
C#
using CentralControl.DBDAO;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Data;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using XGL;
|
|
using XGL.Data;
|
|
using XGL.Models;
|
|
using XGL.UControl;
|
|
|
|
namespace CSWMS.UControl
|
|
{
|
|
/// <summary>
|
|
/// UserAdd.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class product_ordertj : Window
|
|
{
|
|
public static string id = "";
|
|
public static string order_code = "";
|
|
public static string line_code = "";
|
|
public static string prod_code = "";
|
|
public static string materiel_box_no = "";
|
|
public product_ordertj()
|
|
{
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
//查询
|
|
try
|
|
{
|
|
List<common_base_unitModel> model = new List<common_base_unitModel>();
|
|
//获取所有订单
|
|
DBService userDb = new DBService();
|
|
var Items = userDb.GetOrderTJList();
|
|
if (Items != null && Items.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in Items.Rows)
|
|
{
|
|
common_base_unitModel list_model = new common_base_unitModel();
|
|
list_model.id = row["id"].ToString();
|
|
list_model.order_code = row["order_code"].ToString();
|
|
list_model.line_code = row["line_code"].ToString();
|
|
list_model.prod_code = row["prod_desc"].ToString();
|
|
list_model.materiel_box_no = row["materiel_box_no"].ToString();
|
|
list_model.est = Convert.ToDateTime(row["est"].ToString()).ToString("yyyy-MM-dd");
|
|
list_model.Quantity = row["Quantity"].ToString();
|
|
list_model.UpQuantity = row["UpQuantity"].ToString();
|
|
list_model.outwarehousequantity = row["outwarehousequantity"].ToString();
|
|
list_model.production_sequence = row["production_sequence"].ToString();
|
|
|
|
//查询此订单的可转入物料数量
|
|
//根据订单的对应线体查询此订单在线边库的物料数量
|
|
DBService userXB = new DBService();
|
|
var number_xianbian = userXB.GetMaterielNoNumber_xb(row["line_code"].ToString(), row["materiel_box_no"].ToString());
|
|
int number_XB = 0;
|
|
if (number_xianbian != null && number_xianbian.Rows.Count > 0 && number_xianbian.Rows[0]["materiel_num_add"].ToString() != "")
|
|
{
|
|
number_XB = Convert.ToInt32(number_xianbian.Rows[0]["materiel_num_add"].ToString());
|
|
}
|
|
else
|
|
{
|
|
number_XB = 0;
|
|
}
|
|
//获取库区内此物料总数量
|
|
DBService userKK = new DBService();
|
|
var item = userKK.GetMaterielNoNumber(row["materiel_box_no"].ToString());
|
|
//获取此物料订单上件数量
|
|
DBService userKB = new DBService();
|
|
var item1 = userKB.GetMaterielNoNumber_dingdan();
|
|
//存在订单的上件数量
|
|
int numb = 0;
|
|
//存在订单的出库数量
|
|
int numb_xj = 0;
|
|
if (item1 != null && item1.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow i in item1.Rows)
|
|
{
|
|
if (row["materiel_box_no"].ToString().Equals(i["materiel_box_no"].ToString()))
|
|
{
|
|
numb += Convert.ToInt32(i["UpQuantity"].ToString());
|
|
numb_xj += Convert.ToInt32(i["OutWareHouseQuantity"].ToString());
|
|
}
|
|
}
|
|
}
|
|
if (item != null && item.Rows.Count > 0)
|
|
{
|
|
|
|
list_model.area_amount = item.Rows[0]["materiel_num"].ToString();
|
|
list_model.maby_amount = (Convert.ToInt32(item.Rows[0]["materiel_num"].ToString()) + number_XB - (numb - numb_xj)).ToString();
|
|
if (Convert.ToInt32(list_model.maby_amount) <= 0 || list_model.maby_amount == null || list_model.maby_amount == "")
|
|
{
|
|
list_model.maby_amount = "0";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
list_model.area_amount = "0";
|
|
list_model.maby_amount = "0";
|
|
//try
|
|
//{
|
|
// if (number_XB > 0)
|
|
// {
|
|
// list_model.maby_amount = number_XB.ToString();
|
|
// }
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
|
|
//}
|
|
|
|
}
|
|
model.Add(list_model);
|
|
}
|
|
gridBill.ItemsSource = model;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("未查到订单信息!", "提示", MessageBoxButton.OK);
|
|
return;
|
|
}
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
MessageBox.Show("获取订单错误");
|
|
}
|
|
}
|
|
|
|
private void gridBill_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
if (gridBill.SelectedIndex != -1)
|
|
{
|
|
var unit = this.gridBill.SelectedItem as common_base_unitModel;
|
|
if (unit != null)
|
|
{
|
|
id = unit.id;
|
|
order_code = unit.order_code;
|
|
line_code = unit.line_code;
|
|
prod_code = unit.prod_code;
|
|
materiel_box_no = unit.materiel_box_no;
|
|
this.DialogResult = true;
|
|
this.Close();
|
|
}
|
|
else
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.Close();
|
|
}
|
|
}
|
|
|
|
private void BtnAction_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
try
|
|
{
|
|
common_base_unitModel mySelectedElement = (common_base_unitModel)gridBill.SelectedItem;
|
|
string order_code = mySelectedElement.materiel_box_no;
|
|
string orderCode = mySelectedElement.order_code;
|
|
string upNum = mySelectedElement.UpQuantity;
|
|
string upQuanity = mySelectedElement.Quantity;
|
|
string line_code = mySelectedElement.line_code;
|
|
|
|
ordertj order = new ordertj();
|
|
ordertj.order_code = order_code;
|
|
ordertj.orderCode = orderCode;
|
|
ordertj.upNum = upNum;
|
|
ordertj.upQuanity = upQuanity;
|
|
ordertj.lineCode = line_code;
|
|
|
|
if (order.ShowDialog() == true)
|
|
{
|
|
//查询
|
|
try
|
|
{
|
|
Button_ChaXun(null,null);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("获取订单错误");
|
|
}
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
this.Focus();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 显示序号事件
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
private void dgData_LoadingRow(object sender, DataGridRowEventArgs e)
|
|
{ e.Row.Header = e.Row.GetIndex() + 1; }
|
|
|
|
private void Button_ChaXun(object sender, RoutedEventArgs e)
|
|
{
|
|
//查询
|
|
try
|
|
{
|
|
string lineCode = "";
|
|
if (this.line_name.Text.Trim() == "A线")
|
|
{
|
|
lineCode = "D3";
|
|
}
|
|
else if (this.line_name.Text.Trim() == "B线")
|
|
{
|
|
lineCode = "TV";
|
|
}
|
|
else if (this.line_name.Text.Trim() == "C线")
|
|
{
|
|
lineCode = "TQ";
|
|
}
|
|
else if(this.line_name.Text.Trim() == "F线")
|
|
{
|
|
lineCode = "W8";
|
|
}
|
|
List<common_base_unitModel> model = new List<common_base_unitModel>();
|
|
//获取所有订单
|
|
DBService userDb = new DBService();
|
|
var Items = userDb.GetOrderTJList_new(lineCode);
|
|
if (Items != null && Items.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow row in Items.Rows)
|
|
{
|
|
common_base_unitModel list_model = new common_base_unitModel();
|
|
list_model.id = row["id"].ToString();
|
|
list_model.order_code = row["order_code"].ToString();
|
|
list_model.line_code = row["line_code"].ToString();
|
|
list_model.prod_code = row["prod_desc"].ToString();
|
|
list_model.materiel_box_no = row["materiel_box_no"].ToString();
|
|
list_model.est = Convert.ToDateTime(row["est"].ToString()).ToString("yyyy-MM-dd");
|
|
list_model.Quantity = row["Quantity"].ToString();
|
|
list_model.UpQuantity = row["UpQuantity"].ToString();
|
|
list_model.outwarehousequantity = row["outwarehousequantity"].ToString();
|
|
list_model.production_sequence = row["production_sequence"].ToString();
|
|
|
|
//查询此订单的可转入物料数量
|
|
//根据订单的对应线体查询此订单在线边库的物料数量
|
|
DBService userXB = new DBService();
|
|
var number_xianbian = userXB.GetMaterielNoNumber_xb(row["line_code"].ToString(), row["materiel_box_no"].ToString());
|
|
int number_XB = 0;
|
|
if (number_xianbian != null && number_xianbian.Rows.Count > 0 && number_xianbian.Rows[0]["materiel_num_add"].ToString() != "")
|
|
{
|
|
number_XB = Convert.ToInt32(number_xianbian.Rows[0]["materiel_num_add"].ToString());
|
|
}
|
|
else
|
|
{
|
|
number_XB = 0;
|
|
}
|
|
//获取库区内此物料总数量
|
|
DBService userKK = new DBService();
|
|
var item = userKK.GetMaterielNoNumber(row["materiel_box_no"].ToString());
|
|
//获取此物料订单上件数量
|
|
DBService userKB = new DBService();
|
|
var item1 = userKB.GetMaterielNoNumber_dingdan();
|
|
//存在订单的上件数量
|
|
int numb = 0;
|
|
//存在订单的出库数量
|
|
int numb_xj = 0;
|
|
if (item1 != null && item1.Rows.Count > 0)
|
|
{
|
|
foreach (DataRow i in item1.Rows)
|
|
{
|
|
if (row["materiel_box_no"].ToString().Equals(i["materiel_box_no"].ToString()))
|
|
{
|
|
numb += Convert.ToInt32(i["UpQuantity"].ToString());
|
|
numb_xj += Convert.ToInt32(i["OutWareHouseQuantity"].ToString());
|
|
}
|
|
}
|
|
}
|
|
|
|
if (item != null && item.Rows.Count > 0)
|
|
{
|
|
list_model.area_amount = item.Rows[0]["materiel_num"].ToString();
|
|
list_model.maby_amount = (Convert.ToInt32(item.Rows[0]["materiel_num"].ToString()) + number_XB - (numb - numb_xj)).ToString();
|
|
if (Convert.ToInt32(list_model.maby_amount) <= 0 || list_model.maby_amount == null || list_model.maby_amount == "")
|
|
{
|
|
list_model.maby_amount = "0";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
list_model.area_amount = "0";
|
|
list_model.maby_amount = "0";
|
|
//try
|
|
//{
|
|
// if (number_XB > 0)
|
|
// {
|
|
// list_model.maby_amount = number_XB.ToString();
|
|
// }
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
|
|
//}
|
|
|
|
}
|
|
model.Add(list_model);
|
|
}
|
|
gridBill.ItemsSource = model;
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("未查到订单信息!", "提示", MessageBoxButton.OK);
|
|
return;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show("获取订单错误");
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|