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
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 CY.Infrastructure.Common;
using System.Data;
namespace CY.WebForm.Pages.procurement
{
    public partial class CommoditySpeciAssociateManager : BasePage
    {
        OA_CommodityBLL _OA_CommodityBLL = null;
        OA_SpecificationBLL _OA_SpecificationBLL = null;
        OA_CommoditySpeciAssociateBLL _OA_CommoditySpeciAssociateBLL = null;
        DataTable ds = null;
        public CommoditySpeciAssociateManager()
        {
            _OA_CommodityBLL = new OA_CommodityBLL();
            _OA_SpecificationBLL = new OA_SpecificationBLL();
            _OA_CommoditySpeciAssociateBLL = new OA_CommoditySpeciAssociateBLL();
           
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindList();
            }
            
        }
 
        /// <summary>
        ///绑定下拉列表和checkboxlist里面的原始数据 
        /// </summary>
        protected void BindList() 
        {
           ds=_OA_CommoditySpeciAssociateBLL.SelectModelPage(Request["Keyid"].ToString2());
            CBSpecification.DataSource = _OA_SpecificationBLL.getAllSpecification(CurrentUser.MemberId);
            CBSpecification.DataTextField = "Name";
            CBSpecification.DataValueField = "Keyid";
            CBSpecification.DataBind();
            for (int i = 0; i < ds.Rows.Count; i++)
            {
                for (int j = 0; j < CBSpecification.Items.Count; j++)
                {
                    if (CBSpecification.Items[j].Value == ds.Rows[i]["SpecificationId"].ToString2())
                    {
                        CBSpecification.Items[j].Selected = true;
                    }
                }
            
            }
        }
 
        protected void btn_config_Click(object sender, EventArgs e)
        {
            ds = _OA_CommoditySpeciAssociateBLL.SelectModelPage(Request["Keyid"].ToString2());
            List<string> SpecificationListAfter = new List<string>();
            List<string> SpecificationListBefore = new List<string>();
 
            for (int i = 0; i < CBSpecification.Items.Count; i++) 
            {
                if (CBSpecification.Items[i].Selected)
                    SpecificationListAfter.Add(CBSpecification.Items[i].Value);
            }
            for (int i = 0; i < ds.Rows.Count; i++)
            {
                SpecificationListBefore.Add(ds.Rows[i]["SpecificationId"].ToString2());
            }    
          _OA_CommoditySpeciAssociateBLL.DeleteModel(SpecificationListBefore.ToArray(),Request["Keyid"].ToString2() );
                
                
            _OA_CommoditySpeciAssociateBLL.InsertModel(SpecificationListAfter.ToArray(),Request["Keyid"].ToString2());
 
            }
 
    }
}