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
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.Infrastructure.Common;
using System.Web.UI.HtmlControls;
using CY.Model;
 
namespace CY.WebForm.Pages.sysInquiry
{
    public partial class PrintingWorksList : BasePage
    {
        #region 变量
        PrintingWorksBLL _printingWorksBLL = new PrintingWorksBLL();
        ReduceWorkCountSetBLL _reduceWorkCountSetBLL = new ReduceWorkCountSetBLL();
        #endregion
 
        #region 属性
        #endregion
 
        #region 方法
 
        /// <summary>
        /// 初始化绑定页面
        /// </summary>
        private void BindPage()
        {
            if (InquiryConditionObj.FirmId == Guid.Parse(UtilConst.AdminFirmId))
            {
                this.palCount.Visible = false;
            }
            else
            {
                this.palCount.Visible = true;
            }
            Inquiry_ReduceWorkCountSet model = _reduceWorkCountSetBLL.GetModel(InquiryConditionObj.FirmId, InquiryConditionObj.CustomerId);
            if (model == null)
            {
                this.txtCount.Text = string.Empty;
            }
            else
            {
                this.txtCount.Text = model.Count.ToString();
            }
 
            this.RepPrintingWorksList.DataSource = _printingWorksBLL.GetModelList(InquiryConditionObj.InquiryId);
            this.RepPrintingWorksList.DataBind();
        }
 
 
        #endregion
 
        #region 事件
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindPage();
            }
        }
 
 
        /// <summary>
        /// 保存事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSave_Click(object sender, EventArgs e)
        {
 
            bool isSuccess = true;
            IList<Inquiry_PrintingWorks> list = new List<Inquiry_PrintingWorks>();
 
            Inquiry_PrintingWorks model = null;
            decimal versionCost = 0;
            int machineId = 0;
            int index = 0;
            foreach (RepeaterItem item in this.RepPrintingWorksList.Items)
            {
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    model = new Inquiry_PrintingWorks();
                    Label lblMachineId = item.FindControl("lblMachineId") as Label;
                    Label lblMinPrintCount = item.FindControl("lblMinPrintCount") as Label;
                    Label lblMaxPrintCount = item.FindControl("lblMaxPrintCount") as Label;
                    Label lblWorkPriceUnit = item.FindControl("lblWorkPriceUnit") as Label;
                    Label lblVersionCostUnit = item.FindControl("lblVersionCostUnit") as Label;
                    TextBox txtWorkPrice = item.FindControl("txtWorkPrice") as TextBox;
                    TextBox txtAddPrintCount = item.FindControl("txtAddPrintCount") as TextBox;
                    TextBox txtAddPrice = item.FindControl("txtAddPrice") as TextBox;
                    TextBox txtVersionCost = item.FindControl("txtVersionCost") as TextBox;
                    TextBox txtStartPrice = item.FindControl("txtStartPrice") as TextBox;
                    if (index == 0)
                    {
                        machineId = lblMachineId.Text.ToInt32().Value;
                        versionCost = txtVersionCost.Text.ToDecimal2().Value;
                    }
                    if (machineId == lblMachineId.Text.ToInt32().Value)
                    {
                        model.MachineId = machineId;
                        model.VersionCost = versionCost;
                    }
                    else
                    {
                        machineId = lblMachineId.Text.ToInt32().Value;
                        versionCost = txtVersionCost.Text.ToDecimal2().Value;
                        model.MachineId = machineId;
                        model.VersionCost = versionCost;
                    }
                    model.FirmId = InquiryConditionObj.ActualFirmId;
                    model.WorkPrice = txtWorkPrice.Text.ToDecimal2().Value;
                    model.AddPrintCount = txtAddPrintCount.Text.ToInt32();
                    model.AddPrice = txtAddPrice.Text.ToDecimal2();
                    model.MinPrintCount = lblMinPrintCount.Text.ToInt32().Value;
                    model.MaxPrintCount = lblMaxPrintCount.Text.ToInt32().Value;
                    //model.VersionCost = txtVersionCost.Text.ToDecimal2().Value;
                    model.StartPrice = txtStartPrice.Text.ToDecimal2().Value;
                    model.WorkPriceUnit = lblWorkPriceUnit.Text;
                    model.VersionCostUnit = lblWorkPriceUnit.Text;
                    model.Remark = string.Empty;
                    model.Operater = CurrentUser.ShortName;
                    model.OperateTime = DateTime.Now;
                    model.LastUpdateTime = DateTime.Now;
                    list.Add(model);
                    index++;
                }
            }
            isSuccess = _printingWorksBLL.SaveModelList(list, InquiryConditionObj);
 
            if (isSuccess)
            {
                JavaScript.MessageBox("保存成功", this);
            }
            else
            {
                JavaScript.MessageBox("保存失败", this);
            }
        }
        #endregion
 
        protected void Button1_Click(object sender, EventArgs e)
        {
            bool IsCanSave=false;
            bool isSuccess = false;
            string countStr = this.txtCount.Text.Trim();
            int count=0;
            if (!string.IsNullOrEmpty(countStr))
            {
                try
                {
                    count = int.Parse(countStr);
                    if (count >= 0 && count <= 999)
                    {
                        IsCanSave = true;
                    }
                }
                catch (Exception ex)
                {
                    PAGEHandleException(ex);
                }
            }
            if (!IsCanSave)
            {
                JavaScript.MessageBox("优惠次数必须是0-999的正整数", this);
                return;
            }
            Inquiry_ReduceWorkCountSet model = null;
            model = new Inquiry_ReduceWorkCountSet();
            model.FirmId = InquiryConditionObj.FirmId;
            model.CustomerId = InquiryConditionObj.CustomerId;
            model.Count = count;
            isSuccess = _reduceWorkCountSetBLL.SaveModel(model);
            if (isSuccess)
            {
                JavaScript.MessageBox("保存成功", this);
            }
            else
            {
                JavaScript.MessageBox("保存失败", this);
            }
        }
    }
}