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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CY.BLL.Inquiry;
using CY.Model;
using CY.Infrastructure.Common;
namespace CY.WebForm.Pages.sysInquiry
{
    public partial class PrintTypeLimit : BasePage
    {
        #region 变量
        PaperInfoBLL _paperInfoBLL = new PaperInfoBLL();
        RangeofBusinessBLL _rangeofBusinessBLL = new RangeofBusinessBLL();
        #endregion
 
        #region 属性
        #endregion
 
        #region 方法
        private void BindPaperList()
        {
            IEnumerable<SysInquiry_PaperInfo> list = _paperInfoBLL.GetAllPaperList();
            this.RepPaperList.DataSource = list;
            this.RepPaperList.DataBind();
        }
        #endregion
 
        #region 事件
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Page_Load(object sender, EventArgs e)
        {
           
            if (!IsPostBack)
            {
                BindPaperList();
            }
            string result = string.Empty;
            if (Request["Init"] != null)
            {
                int printTypeId = int.Parse(Request["PrintTypeId"].ToString());
                IList<SysInquiry_RangeofBusiness> list = _rangeofBusinessBLL.GetModelList(printTypeId);
                string str = string.Empty;
                string init = string.Empty;
                if (list.Count > 0)
                {
                    foreach (SysInquiry_RangeofBusiness model in list)
                    {
                        str += "{ PagerId:" + model.PagerId + ",GramWeights:'" + model.GramWeightRange + "'},";
                    }
                    init = "1";
                }
                else
                {
                    init = "2";
                    IEnumerable<SysInquiry_PaperInfo> list1 = _paperInfoBLL.GetAllPaperList();
                    foreach (SysInquiry_PaperInfo model1 in list1)
                    {
                        str += "{ PagerId:" + model1.PapeId + ",GramWeights:'" + model1.GramWeights + "'},";
                    }
                }
                if (!string.IsNullOrEmpty(str))
                {
                    str = str.Substring(0, str.Length - 1);
                    
                }
                result = "{initObj:" + init + ",list:[" + str + "]}";
                Response.Write(result);
                Response.End();
            }
            if (Request["Save"] != null)
            {
                IList<SysInquiry_RangeofBusiness> list = new List<SysInquiry_RangeofBusiness>();
                SysInquiry_RangeofBusiness model = null;
                int printTypeId = int.Parse(Request["PrintTypeId"].ToString());
                string modelList = Request["ModelList"].ToString();
                string[] modelArry = modelList.Split(',');
                foreach (string modelStr in modelArry)
                {
                    string[] arry=modelStr.Split(':');
                    model = new SysInquiry_RangeofBusiness();
                    model.PrintingTypeId = printTypeId;
                    model.PagerId = arry[0].ToInt32();
                    model.GramWeightRange = arry[1];
                    model.PageSizeRange = string.Empty;
                    model.AfterParameterRange = string.Empty;
                    model.Operater = CurrentUser.ShortName;
                    model.OperateTime = DateTime.Now;
                    model.lastUpdateTime = DateTime.Now;
                    list.Add(model);
                }
                bool isSuccess = _rangeofBusinessBLL.SaveModelList(list,printTypeId);
                if (isSuccess)
                {
                    result = "保存成功";
                }
                else
                {
                    result = "保存失败";
                }
                Response.Write(result);
                Response.End();
            }
        }
        #endregion       
    }
}