username@email.com
2025-05-12 ae6e40362a745caef9ead36f81f38313fb8c2c66
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.OA;
using System.Data;
using System.Data.SqlClient;
using CY.Infrastructure.Common;
using CY.Model;
 
namespace CY.WebForm.Pages.procurement
{
    public partial class OutOfStorageEdit : BasePage
    {
        OA_SpecificationBLL _OA_SpecificationBLL = null;
        OA_SuppliersBLL _OA_SuppliersBLL = null;
        OA_CommodityBLL _OA_CommodityBLL = null;
        OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
        OA_ProcurementBLL _OA_ProcurementBLL = null;
        OA_GoodsInfo GoodsInfo = null;
        OA_Procurement procurement = null;
        OA_WarehouseInfoBLL _OA_WarehouseInfoBLL = null;
        OA_CargoSpaceBLL _OA_CargoSpaceBLL = null;
        OA_Inventory Inventory = null;
        OA_OutOfStorage outOfStorage = null;
        OA_OutOfStorageBLL _OA_OutOfStorageBLL = new OA_OutOfStorageBLL();
 
        OA_BrandBLL _OA_BrandBLL = null;
        OA_PaperWeightBLL _OA_PaperWeightBLL = null;
 
        public OutOfStorageEdit()
        {
            _OA_PaperWeightBLL = new OA_PaperWeightBLL();
            _OA_SpecificationBLL = new OA_SpecificationBLL();
            _OA_BrandBLL = new OA_BrandBLL();
            _OA_OutOfStorageBLL = new OA_OutOfStorageBLL();
            outOfStorage = new OA_OutOfStorage();
            _OA_WarehouseInfoBLL = new OA_WarehouseInfoBLL();
            _OA_CargoSpaceBLL = new OA_CargoSpaceBLL();
            procurement = new OA_Procurement();
            _OA_CommodityBLL = new OA_CommodityBLL();
            _OA_ProcurementBLL = new OA_ProcurementBLL();
            _OA_SuppliersBLL = new OA_SuppliersBLL();
            _OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
            GoodsInfo = new OA_GoodsInfo();
            Inventory = new OA_Inventory();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
 
            if (!IsPostBack)
            {
                this.div_none.Visible = false;
                this.div_tanPrice.Visible = false;
                this.dwPaperWeight.Visible = false;
                this.txtTenPrice.Visible = false;
                this.div_td.Visible = false;
                InitialData();
            }
        }
 
        /// <summary>
        /// 初始化下拉列表
        /// </summary>
        protected void InitialData()
        {
            //供应商
            this.selSuppliers.DataSource = _OA_SuppliersBLL.getSupplierTable(CurrentUser.MemberId);
            this.selSuppliers.DataBind();
            this.selSuppliers.Items.Insert(0, new ListItem("请选择", ""));
 
            //产品类别
            this.dwCommity.Items.Insert(0, new ListItem("请选择", ""));
            DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId,"","true");
            GetDataByLevel(this.dwCommity, ds, 0, 0);
 
            //仓库
            this.dwWarehouse.DataSource = _OA_WarehouseInfoBLL.getAllWarehouseInfo(CurrentUser.MemberId);
            this.dwWarehouse.DataValueField = "Keyid";
            this.dwWarehouse.DataTextField = "WarehouseName";
            this.dwWarehouse.DataBind();
            this.dwWarehouse.Items.Insert(0, new ListItem("请选择", ""));
 
            this.dwBrand.Items.Insert(0, new ListItem("请选择", ""));
 
            this.dwGoodsList.Items.Insert(0, new ListItem("请选择", ""));
 
            this.dwSpecification.Items.Insert(0, new ListItem("请选择", ""));
 
            this.dwPaperWeight.Items.Insert(0, new ListItem("请选择", ""));
        }
 
        /// <summary>
        /// 产品类别
        /// </summary>
        /// <param name="dwCommity"></param>
        /// <param name="data"></param>
        /// <param name="parentId"></param>
        /// <param name="level"></param>
        public static void GetDataByLevel(System.Web.UI.WebControls.DropDownList dwCommity, DataTable data, int parentId, int level)
        {
            DataRow[] result = data.Select(string.Format("ParentId={0}", parentId));
            int i = -1;
            while (++i < result.Length)
            {
                dwCommity.Items.Add(new ListItem(GetSplitChar(level) + result[i]["CommodityName"].ToString2(), result[i]["Keyid"].ToString2()));
                GetDataByLevel(dwCommity, data, result[i]["Keyid"].ToInt32().Value, level + 1);
 
            }
        }
 
        public static string GetSplitChar(int level)
        {
            string splitchar = "";
            int i = -1;
            while (++i < level) { splitchar += "."; }
            return splitchar;
        }
 
        /// <summary>
        /// 类别选取
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void dwCommity_SelectedIndexChanged(object sender, EventArgs e)
        {
            DataTable ds = _OA_GoodsInfoBLL.SlectModleByCommity(dwCommity.SelectedValue, CurrentUser.MemberId);
            if (ds.Rows.Count > 0)
            {
                dwGoodsList.DataSource = ds;
                dwGoodsList.DataTextField = "GoodsName";
                dwGoodsList.DataValueField = "Keyid";
                dwGoodsList.DataBind();
                dwGoodsList.Items.Insert(0, new ListItem("请选择", ""));
            }
            else
            {
                dwGoodsList.Items.Clear();
                dwGoodsList.Items.Insert(0, new ListItem("请选择", ""));
            }
            indecChage();
 
        }
 
        protected void indecChage()
        {
 
            DataTable dt_brand = _OA_BrandBLL.getAllBrand(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
            if (dt_brand.Rows.Count > 0)
            {
                dwBrand.DataSource = dt_brand;
                dwBrand.DataTextField = "Name";
                dwBrand.DataValueField = "Keyid";
                dwBrand.DataBind();
            }
            else
            {
                dwBrand.Items.Clear();
                dwBrand.Items.Insert(0, new ListItem("请选择", ""));
            }
            DataTable dt_Specefiction = _OA_SpecificationBLL.getAllSpecification(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
 
            if (dt_Specefiction.Rows.Count > 0)
            {
                dwSpecification.DataSource = dt_Specefiction;
                dwSpecification.DataTextField = "Name";
                dwSpecification.DataValueField = "Keyid";
                dwSpecification.DataBind();
            }
            else
            {
                dwSpecification.Items.Clear();
                dwSpecification.Items.Insert(0, new ListItem("请选择", ""));
            }
            DataTable dt_PaperWeight = _OA_PaperWeightBLL.getPaperWeight(CurrentUser.MemberId, this.dwCommity.SelectedValue, this.dwGoodsList.SelectedValue);
 
            if (dt_PaperWeight.Rows.Count > 0)
            {
                dwPaperWeight.DataSource = dt_PaperWeight;
                dwPaperWeight.DataTextField = "Name";
                dwPaperWeight.DataValueField = "Keyid";
                dwPaperWeight.DataBind();
                this.dwPaperWeight.Visible = true;
                this.txtTenPrice.Visible = true;
                this.div_td.Visible = true;
                this.div_tanPrice.Visible = true;
                this.div_none.Visible = true;
            }
            else
            {
                this.div_none.Visible = false;
                this.div_tanPrice.Visible = false;
                this.dwPaperWeight.Visible = false;
                this.txtTenPrice.Visible = false;
                this.div_td.Visible = false;
            }
 
        }
 
        /// <summary>
        /// 根据产品名初始化数据
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void dwGoodsList_SelectedIndexChanged(object sender, EventArgs e)
        {
            indecChage();
        }
 
        /// <summary>
        /// 产品添加
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btn_config_Click(object sender, EventArgs e)
        {
            Inventory.CargoSpaceId = 0;
            Inventory.FirmId = CurrentUser.MemberId;
            Inventory.GoodsId = dwGoodsList.SelectedValue.ToInt32();
            Inventory.InventoryCount = txtQuantity.Value.ToInt32();
            Inventory.LastUpdateTime = DateTime.Now;
            Inventory.Operator = CurrentUser.ShortName;
            Inventory.Remark = "";
            Inventory.WarehouseId = dwWarehouse.SelectedValue.ToInt32();
            Inventory.SpecificationId = this.dwSpecification.SelectedValue.ToInt32();
            Inventory.PaperWeightId = this.dwPaperWeight.SelectedValue.ToInt32()??0;
            Inventory.BrandId = this.dwBrand.SelectedValue.ToInt32();
            Inventory.UnitPrice = this.txtPrice.Value.ToDecimal2();
            Inventory.TotalPrice = 0;
 
 
            outOfStorage.FirmId = CurrentUser.MemberId;
            outOfStorage.GoodsId = dwGoodsList.SelectedValue.ToInt32();
            outOfStorage.CargoSpaceId = 0;
            outOfStorage.LastUpdateTime = DateTime.Now;
            outOfStorage.Operator = CurrentUser.ShortName;
            outOfStorage.Remark = "";
            outOfStorage.WarehouseId = dwWarehouse.SelectedValue.ToInt32();
            outOfStorage.SuppliersId = selSuppliers.Value.ToInt32();
            outOfStorage.AllMoney = txtAllMoney.Value.ToDecimal2();
            outOfStorage.InfoType = Request["type"].ToString2();
            outOfStorage.Price = txtPrice.Value.ToDecimal2();
            outOfStorage.Quantity = txtQuantity.Value.ToInt32();
            outOfStorage.TanPrice = this.txtTenPrice.Value.ToDecimal2();
            outOfStorage.SpecificationId = this.dwSpecification.SelectedValue.ToInt32();
            outOfStorage.PaperWeightId = this.dwPaperWeight.SelectedValue.ToInt32() ?? 0;
            outOfStorage.BrandId = this.dwBrand.SelectedValue.ToInt32();
 
 
            if (_OA_OutOfStorageBLL.InsertModel(Inventory, outOfStorage))
            {
                this.txtAllMoney.Value = "";
                this.txtPrice.Value = "";
                this.txtQuantity.Value = "";
                this.txtTenPrice.Value = "";
                JavaScript.MessageBox("操作成功", this,false,true);
            }
            else
            {
                JavaScript.MessageBox("添加失败", this);
            }
        }
      
    }
}