Frm_PalletAdd.xaml.cs
3.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
using HHWCS.Bll;
using HHWCS.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
namespace HHWCSHost.View.Pallet
{
/// <summary>
/// Frm_PalletAdd.xaml 的交互逻辑
/// </summary>
public partial class Frm_PalletAdd : Window
{
public Frm_PalletAdd()
{
InitializeComponent();
}
private void btn_Add_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(txt_PalletCode.Text))
{
MessageBox.Show("请输入条码");
}
else
{
var temp = AppCommon.Bll.GetAllContainer(txt_PalletCode.Text, false, false);
if (temp.Success)
{
MessageBox.Show($"托盘{txt_PalletCode.Text}已存在");
}
else
{
var temp2 = AppCommon.Bll.CreateContainer(txt_PalletCode.Text, AppCommon.WarehouseCode, AppCommon.WarehouseId, 1);
if (temp2.Success)
{
MessageBox.Show("创建成功");
}
else
{
MessageBox.Show("创建失败");
}
}
}
}
private void btn_BatchAdd_Click(object sender, RoutedEventArgs e)
{
if (string.IsNullOrEmpty(txt_Begin.Text) || string.IsNullOrEmpty(txt_End.Text) || string.IsNullOrEmpty(txt_Length.Text))
{
MessageBox.Show("开始、结束或长度为空");
}
int begin;
int end;
int length;
if(int.TryParse(txt_Begin.Text,out begin)&&int.TryParse(txt_End.Text,out end)&&int.TryParse(txt_Length.Text,out length))
{
if (begin > end || length < 1)
{
MessageBox.Show("开始要小于结束,长度要大于1");
}
else
{
string p = txt_P.Text;
for (int i = begin; i < end+1; i++)
{
string pallet = p + i.ToString().PadLeft(length, '0');
var temp = AppCommon.Bll.GetAllContainer(pallet, false, false);
if (temp.Success)
{
MessageBox.Show($"托盘{pallet}已存在,操作中止");
break;
}
var temp2 = AppCommon.Bll.CreateContainer(pallet, AppCommon.WarehouseCode, AppCommon.WarehouseId, 1);
if (!temp2.Success)
{
MessageBox.Show("创建失败,操作中止:消息:"+temp2.Msg);
break;
}
}
MessageBox.Show("创建成功!");
}
}
else
{
MessageBox.Show("请检查输入");
}
}
}
}