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 System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.Model;
using CY.Infrastructure.Query;
using CY.BLL.OA;
using CY.Infrastructure.Common;
using System.Data;
namespace CY.WebForm.Pages.procurement
{
    public partial class OA_PaperWeightEdit : BasePage
    {
        OA_PaperWeightBLL _OA_PaperWeightBLL = null;
        OA_PaperWeight paperWeight = null;
        OA_CommodityBLL _OA_CommodityBLL = null;
        OA_GoodsInfoBLL _OA_GoodsInfoBLL = null;
        OA_BrandBLL _OA_BrandBLL = null;
 
        public OA_PaperWeightEdit()
        {
            _OA_BrandBLL = new OA_BrandBLL();
            _OA_GoodsInfoBLL = new OA_GoodsInfoBLL();
            _OA_CommodityBLL = new OA_CommodityBLL();
            paperWeight = new OA_PaperWeight();
            _OA_PaperWeightBLL = new OA_PaperWeightBLL();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!string.IsNullOrEmpty(Request["PaperWeightName"].ToString2()))
                {
                    int id = Request["id"].ToInt32() ?? 0;
                    int GoodsId = Request["Goodsid"].ToInt32() ?? 0;
                    bool result = _OA_PaperWeightBLL.isExistPaperWeightName(Request["PaperWeightName"].ToString2(), CurrentUser.MemberId, id, GoodsId);
                    Response.Write(result ? "1" : "0");
                }
            }
            catch (Exception ex)
            {
                PAGEHandleException(ex);
                string ms = ex.Message;
                Response.Clear();
                Response.Write("-1");
            }
            if (!string.IsNullOrEmpty(Request["PaperWeightName"].ToString2()))
            {
                Response.End();
            }
 
 
            if (!IsPostBack)
            {
                string PaperCommodiyId = _OA_CommodityBLL.getCommodityId(CurrentUser.MemberId).Keyid.ToString2();
                ChangeSelBrand(PaperCommodiyId);
                if (Request["EditKeyid"].ToInt32() > 0)
 
                    InitialData();
            }
        }
 
        protected void InitialSelData()
        {
            DataTable ds = _OA_CommodityBLL.SelectModelPage(CurrentUser.MemberId, "true", "true");
            var dic = new Dictionary<string, string>();
        }
 
        protected void InitialData()
        {
            paperWeight = _OA_PaperWeightBLL.getSingleBrand(Request["EditKeyid"].ToString2());
            if (paperWeight != null)
            {
                this.txtBrandName.Value = paperWeight.Name;
                //this.dwCommity.SelectedValue = paperWeight.CommodityId.ToString2();
                ChangeSelBrand(paperWeight.CommodityId.ToString2());
                this.selGoodName.Value = paperWeight.GoodsId.ToString2();
                this.txtOrderNum.Value = paperWeight.OrderNum.ToString2();
            }
            else
            {
                this.txtBrandName.Value = "";
                this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, "OA_PaperWeight");
            }
        }
 
        protected void btn_Submit_Click(object sender, EventArgs e)
        {
            if (Request["EditKeyid"].ToInt32() > 0)
            {
                paperWeight = _OA_PaperWeightBLL.getSingleBrand(Request["EditKeyid"].ToString2());
            }
 
            paperWeight.FirmId = CurrentUser.MemberId;
            paperWeight.LastUpdateTime = DateTime.Now;
            paperWeight.Name = txtBrandName.Value;
            paperWeight.Operator = CurrentUser.ShortName;
            paperWeight.OrderNum = this.txtOrderNum.Value.ToInt32();
            paperWeight.GoodsId = this.selGoodName.Value.ToInt32();
            paperWeight.CommodityId = _OA_CommodityBLL.getCommodityId(CurrentUser.MemberId).Keyid;
            if (Request["EditKeyid"].ToInt32() > 0)
            {
                if (_OA_PaperWeightBLL.UpdateModel(paperWeight))
                    JavaScript.MessageBoxCloseAndRefreshFirst("更新成功", this);
                else
                    JavaScript.MessageBox("更新失败", this);
            }
            else
            {
                if (_OA_PaperWeightBLL.InsertModel(paperWeight))
                {
                    //InitialData();
                    //JavaScript.MessageBox("添加成功", this, false, true);
                    JavaScript.MessageBoxCloseAndRefreshFirst("添加成功", this);
                }
                else
                    JavaScript.MessageBox("添加失败", this);
            }
 
 
        }
 
        protected void dwCommity_SelectedIndexChanged(object sender, EventArgs e)
        {
            string PaperCommodiyId = _OA_CommodityBLL.getCommodityId(CurrentUser.MemberId).ToString2();
            this.selGoodName.DataValueField = "Keyid";
            this.selGoodName.DataTextField = "GoodsName";
            this.selGoodName.DataBind();
        }
 
        protected void ChangeSelBrand(string CommodityId)
        {
            this.txtOrderNum.Value = _OA_BrandBLL.GetMaxOrderNum(CurrentUser.MemberId, "OA_PaperWeight");
            this.selGoodName.DataSource = _OA_GoodsInfoBLL.SlectModleByCommity(CommodityId, CurrentUser.MemberId);
            this.selGoodName.DataValueField = "Keyid";
            this.selGoodName.DataTextField = "GoodsName";
            this.selGoodName.DataBind();
        }
    }
}