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 方法 /// /// 初始化绑定页面 /// 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(); } } /// /// 保存事件 /// /// /// protected void btnSave_Click(object sender, EventArgs e) { bool isSuccess = true; IList list = new List(); 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); } } } }