schangxiang@126.com
2025-07-30 a16904bd86f89e97a5e507e08003506c5dd8642e
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
using Sunny.UI;
using sunui.forms;
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 WMS.UI.Basic
{
    public partial class addMaterial : Form
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="types">1=新建,2=编辑</param>
        /// <param name="ID">编辑时物料ID</param>
        /// <param name="materialCode">编辑时传物料编号</param>
        /// <param name="materialName">编辑时传物料名称</param>
        /// <param name="materialType">新建物料时 物料类型 0=缸盖,1=缸体</param>
        ///  <param name="version">新建物料时 机型</param>
        public addMaterial(int types, int ID, string materialCode, string materialName, int materialType, string  version)
        {
            InitializeComponent();
           
            if (types == 2)
            {
                label_Title.Text = "物料编辑";
                label_ID.Text = ID.ToString();
                textBox_Code.Text = materialCode;
                textBox_Name.Text = materialName;
                comboBox_type.SelectedIndex = materialType;
                textBox_version.Text = version.Trim();
            }
        }
 
        private void button_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        /// <summary>确认按钮
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button_confirm_Click(object sender, EventArgs e)
        {
            try
            {
                #region 参数检查
                if (string.IsNullOrEmpty(textBox_Name.Text.Trim()))
                {
                    WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "物料名称不能为空");
                    ms.Show();
                 // ShowWarningTip("物料名称不能为空- 警告");
                    return;
 
                }
                if (string.IsNullOrEmpty(textBox_Code.Text.Trim()))
                {
                    WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "物料编号不能为空");
                    ms.Show();
                   // ShowWarningTip("物料编号不能为空- 警告");
                    return;
 
                }
                if (string.IsNullOrEmpty((string)comboBox_type.SelectedItem))
                {
                    WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "请选择物料类型");
                    ms.Show();
                 // ShowWarningTip("请选择物料类型- 警告");
                    return;
                }
                #endregion
 
                if (label_Title.Text == "物料编辑")
                {
 
                    if (string.IsNullOrEmpty(label_ID.Text.Trim()))
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "物料id为空,请查看库存物料数据");
                        ms.Show();
                     //  ShowWarningTip( " 物料id为空,请查看库存物料数据- 警告");
                      
                        return;
                    }
                    string res = FLogin.wcsWcf.materialOP(2, Convert.ToInt32(label_ID.Text.Trim()), textBox_Code.Text.Trim(), textBox_Name.Text.Trim(), comboBox_type.SelectedIndex, textBox_version.Text.Trim());
                    if (res == "")
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(1, "修改成功");
                        ms.Show();
                       // ShowSuccessTip("修改成功 - 成功");
                        this.DialogResult = DialogResult.OK;
                        this.Close();
                       
                    }
                    else
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res);
                        ms.Show();
                       // ShowWarningTip(res+" - 警告");
                        this.Close();
                    }
 
                }
                else
                {
                    string res = FLogin.wcsWcf.materialOP(1, 0, textBox_Code.Text.Trim(), textBox_Name.Text.Trim(), comboBox_type.SelectedIndex, textBox_version.Text.Trim());
                    if (res == "")
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(1, "创建成功 - 成功");
                        ms.Show();
                      // ShowSuccessTip("创建成功 - 成功");
                     
                        this.DialogResult = DialogResult.OK;
                    }
                    else
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res);
                        ms.Show();
                      //  ShowWarningTip(res+" - 警告");
                     
                        this.DialogResult = DialogResult.OK;
                    }
                }
            }
            catch (Exception)
            {
                WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, "异常了- 警告");
                ms.Show();
               // ShowWarningTip("异常了- 警告");
            }
 
        }
 
        // ShowWarningTip("轻便消息提示框 - 警告");
        // ShowSuccessTip("轻便消息提示框 - 成功");
    }
}