schangxiang@126.com
2025-09-04 e9269528ae01bc4572b68148b9c801b51f23b669
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
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;
using WMS.UI.WORK;
 
namespace WMS.UI.SynthesizeQuery
{
    public partial class FrmPVClist : Form
    {
        long stockId = 0;
        /// <summary>
        /// 
        /// </summary>
        /// <param name="positionNames"></param>
        /// <param name="place">1=库存查询,2=入库单,3=推送MES详情</param>
        public FrmPVClist(string positionNames, int place,long mainId)
        {
            InitializeComponent();
            this.dataGridView1.AutoGenerateColumns = false;
            this.Text = positionNames;
            getData(positionNames, place, mainId);
 
        }
        private void getData(string positionNames, int place, long mainId)
        {
            try
            {
 
                if (place == 1)
                {
                    var res = FLogin.wcsWcf.findStockList(positionNames);
                    if (res.status == 200)
                    {
                        dataGridView1.DataSource = res.date;
 
                    }
                    else
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res.msg);
                        ms.Show();
                    }
                }
                else if(place == 3)
                {
                    var res = FLogin.wcsWcf.findOutInStockRecord_Details_V2_Mes(mainId);
                    if (res.status == 200)
                    {
                        dataGridView1.DataSource = res.date;
 
                    }
                    else
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res.msg);
                        ms.Show();
                    }
                }
                else
                {
                    var res = FLogin.wcsWcf.findInStockList(positionNames);
                    if (res.status == 200)
                    {
                        dataGridView1.DataSource = res.date;
 
                    }
                    else
                    {
                        WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(2, res.msg);
                        ms.Show();
                    }
                }
 
 
            }
            catch (Exception)
            {
 
            }
 
        }
 
        private void FrmPVClist_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (preview.newform.Contains(this.Text))
            {
                preview.newform.Remove(this.Text);
            }
        }
 
 
        private void button_confirm_Click(object sender, EventArgs e)
        {
 
            try
            {
                if (this.Text.Substring(0, 1) == "G" && this.Text.Length > 4)//保存入库明细
                {
 
                    WMS.yunneiWCS.inStockOrderList[] modifyStockList = (WMS.yunneiWCS.inStockOrderList[])dataGridView1.DataSource;
                    var res = FLogin.wcsWcf.modfiyInStockList(modifyStockList);
                    int statu = res.status == 200 ? 1 : 2;
                    WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(statu, res.msg);
                    ms.Show();
                    if (res.status == 200)
                    {
                        this.Close();
                    }
 
                }
                else//保存库存明细
                {
                    WMS.yunneiWCS.productStockList[] modifyStockList = (WMS.yunneiWCS.productStockList[])dataGridView1.DataSource;
                    var res = FLogin.wcsWcf.modfiyStockList(modifyStockList, 0);
                    int statu = res.status == 200 ? 1 : 2;
                    WMS.EnumDefine.messages ms = new WMS.EnumDefine.messages(statu, res.msg);
                    ms.Show();
                    if (res.status == 200)
                    {
                        this.Close();
                    }
                }
 
 
 
            }
            catch (Exception)
            {
 
            }
        }
 
        private void button_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
 
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (dataGridView1.Columns[e.ColumnIndex].Name == "delete")
                {
                    if (this.Text.Substring(0, 1) == "G" && this.Text.Length > 4)//入库单修改
                    {
                        WMS.yunneiWCS.inStockOrderList[] modifyStockList = (WMS.yunneiWCS.inStockOrderList[])dataGridView1.DataSource;
                        var modfiy = modifyStockList.ToList();
                        modfiy.RemoveAt(dataGridView1.CurrentRow.Index);
                        dataGridView1.DataSource = null;
                        dataGridView1.DataSource = modfiy.ToArray();
                    }
                    else//库存修改
                    {
                        WMS.yunneiWCS.productStockList[] modifyStockList = (WMS.yunneiWCS.productStockList[])dataGridView1.DataSource;
                        var modfiy = modifyStockList.ToList();
                        modfiy.RemoveAt(dataGridView1.CurrentRow.Index);
                        dataGridView1.DataSource = null;
                        dataGridView1.DataSource = modfiy.ToArray();
                    }
 
 
                }
 
            }
            catch (Exception ex)
            {
 
            }
        }
        /// <summary>增加序号
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void dataGridView1_RowPostPaint(object sender, DataGridViewRowPostPaintEventArgs e)
        {
 
            SolidBrush b = new SolidBrush(this.dataGridView1.RowHeadersDefaultCellStyle.ForeColor);
            e.Graphics.DrawString((e.RowIndex + 1).ToString(System.Globalization.CultureInfo.CurrentUICulture), this.dataGridView1.DefaultCellStyle.Font, b, e.RowBounds.Location.X + 20, e.RowBounds.Location.Y + 4);
 
        }
    }
}