username@email.com
2025-05-15 6fe02a16e55f17e45a3997171e1b2284d45af25b
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using System.Data;
using CY.Infrastructure.Common;
using CY.BLL.OA;
using CY.BLL.Sys;
namespace CY.WebForm.Pages.procurement
{
    public partial class GoodsInfoEdit : BasePage
    {
        OA_CommoditySpeciAssociate A = new OA_CommoditySpeciAssociate();
        OA_BrandBLL _OA_BrandBLL = null;
        OA_CommodityBLL _OA_CommodityBLL = null;
        OA_GoodsInfo goodInfo = null;
        OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
        OA_CommoditySpeciAssociateBLL _OA_CommoditySpeciAssociateBLL = null;
        OA_SpecificationBLL _OA_SpecificationBLL = null;
        Sys_DictionaryBLL _Sys_DictionaryBLL = null;
 
        public GoodsInfoEdit()
        {
            _Sys_DictionaryBLL = new Sys_DictionaryBLL();
            _OA_BrandBLL = new OA_BrandBLL();
            _OA_CommodityBLL = new OA_CommodityBLL();
            _OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
            goodInfo = new OA_GoodsInfo();
            _OA_SpecificationBLL = new OA_SpecificationBLL();
            _OA_CommoditySpeciAssociateBLL = new OA_CommoditySpeciAssociateBLL();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request["GoodsName"].ToString2()))
                {
                    int id = Request["id"].ToInt32() ?? 0;
                    bool result = _OA_GoodsInfoBLL.isExistGoodsName(Request["GoodsName"].ToString2(), CurrentUser.MemberId, id);
                    Response.Write(result ? "1" : "0");
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                string ms = ex.Message;
                Response.Clear();
                Response.Write("-1");
            }
            if (!string.IsNullOrEmpty(Request["GoodsName"].ToString2()))
            {
                Response.End();
            }
            if (!IsPostBack)
            {
                BindList();
                if (Request["Keyid"].ToInt32() > 0)
                {
                    BindModifyData();
                }
            }
        }
 
        /// <summary>
        /// 货品状态 货品类别的数据添加
        /// </summary>
        protected void BindList()
        {
            this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, " OA_GoodsInfo ");
            this.selGoodsStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("货品状态");
            this.selGoodsStatus.DataBind();
            //this.selGoodsStatus.Items.Insert(0, new ListItem("请选择", ""));
            //this.RBbrandList.DataSource = _OA_BrandBLL.getAllBrand(CurrentUser.MemberId);
            //this.RBbrandList.DataTextField = "Name";
            //this.RBbrandList.DataValueField = "Keyid";
            //this.RBbrandList.DataBind();
            DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId,"","true");
 
            var dic = new Dictionary<string, string>();
            GetDataByLevel(dwCommity, ds, 0, 0);
        }
 
        #region 上级父类数据初始化
        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;
        }
 
        #endregion
 
        /// <summary>
        /// 取得不同类别下面的规格、是否纸张
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        //protected void dwCommity_SelectedIndexChanged(object sender, EventArgs e)
        //{
        //    this.RBspecificationList.DataSource = _OA_CommoditySpeciAssociateBLL.SelectALLModel(dwCommity.SelectedValue);
        //    this.RBspecificationList.DataTextField = "OA_SpecificationName";
        //    this.RBspecificationList.DataValueField = "SpecificationId";
        //    this.RBspecificationList.DataBind();
 
        //    OA_Commodity Commodity = _OA_CommodityBLL.SelectSingleModel(dwCommity.SelectedValue);
        //    if (Commodity.IsPaper == true)
        //    {
        //        this.trWeight.Visible = true;
        //    }
        //}
 
        /// <summary>
        /// 装载要更新的数据
        /// </summary>
        protected void BindModifyData()
        {
            if (Request["Keyid"].ToInt32() > 0)
            {
                goodInfo = _OA_GoodsInfoBLL.SelectSingleModel(Request["Keyid"].ToString2());
                
                this.txtGoodsName.Value = goodInfo.GoodsName;
                this.dwCommity.SelectedValue = goodInfo.GoodsTypeId;
                this.txtOrderNum.Value = goodInfo.OrderNum.ToString2();
                //this.RBspecificationList.DataSource = _OA_CommoditySpeciAssociateBLL.SelectALLModel(goodInfo.GoodsTypeId);
                //this.RBspecificationList.DataTextField = "OA_SpecificationName";
                //this.RBspecificationList.DataValueField = "SpecificationId";
                //this.RBspecificationList.DataBind();
                //this.RBbrandList.SelectedValue = goodInfo.BrandId.ToString2();
                //this.RBspecificationList.SelectedValue = goodInfo.SpecificationId.ToString2();
                //this.txtWeight.Value = goodInfo.Weight.ToString2();
                //if (!string.IsNullOrEmpty(goodInfo.Weight.ToString2()))
                //{
                //    this.trWeight.Visible = true;
                //}
                //this.txtWarningInventory.Value = goodInfo.WarningInventory.ToString2();
                //this.txtGoodsHeight.Value = goodInfo.GoodsHeight.ToString2();
                //this.txtGoodsLength.Value = goodInfo.GoodsLength.ToString2();
                //this.txtGoodsWidth.Value = goodInfo.GoodsWidth.ToString2();
                //this.txtPrice.Value = goodInfo.Price.ToString2();
                //this.txtUnit.Value = goodInfo.Unit.ToString2();
 
                this.selGoodsStatus.Value = goodInfo.StatusId.ToString2();
            }
            else
            {
                this.txtGoodsName.Value = "";
                this.txtOrderNum.Value = goodInfo.OrderNum.ToString2();
            }
        }
 
        protected void btn_config_Click(object sender, EventArgs e)
        {
            goodInfo.Price = 0;
            goodInfo.WarningInventory = 0;
            goodInfo.GoodsHeight =0;
            goodInfo.GoodsLength =0;
            goodInfo.GoodsWidth = 0;
            goodInfo.GoodsName = this.txtGoodsName.Value;
            goodInfo.GoodsTypeId = this.dwCommity.SelectedValue;
            goodInfo.LastUpdateTime = DateTime.Now;
            goodInfo.Operator = CurrentUser.ShortName;
            goodInfo.Remark = " ";
            goodInfo.SpecificationId = 0;
            goodInfo.BrandId = 0;
            goodInfo.Weight = 0;
            goodInfo.OrderNum = this.txtOrderNum.Value.ToInt32();
            goodInfo.StatusId = this.selGoodsStatus.Value.ToInt32();
            goodInfo.Unit = " ";
          
            goodInfo.FirmId = CurrentUser.MemberId;
            if (Request["Keyid"].ToInt32() > 0)
            {
                goodInfo.Keyid = Request["Keyid"].ToInt32();
                if (_OA_GoodsInfoBLL.UpdateModel(goodInfo))
                    JavaScript.MessageBox("更新成功", this, true, true);
                else
                    JavaScript.MessageBox("更新失败", this);
            }
            else
            {
                if (_OA_GoodsInfoBLL.insertModel(goodInfo))
                {
                    BindModifyData();
                    JavaScript.MessageBox("添加成功", this, false, true);
                }
                else
                    JavaScript.MessageBox("添加失败", this);
            }
        }
    }
}