using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient; using CY.Model; using CY.BLL; using CY.Infrastructure.Common; using CY.BLL.Sys; using CY.BLL.EC; using CY.Infrastructure.DESEncrypt; using CY.Infrastructure.Query; namespace CY.WebForm.Pages.Property { //吴辉 //行政物品 public partial class PropertyEdit : BasePage { Sys_DictionaryBLL bll_Sys_DictionaryBLL = null; OA_PropertyManageBLL bll_OA_PropertyManageBLL = null; public PropertyEdit() { bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); bll_OA_PropertyManageBLL = new OA_PropertyManageBLL(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.selCateId.DataSource = bll_OA_PropertyManageBLL.GetDataByType(CurrentUser.MemberId); this.selCateId.DataTextField = "Name"; this.selCateId.DataValueField = "Keyid"; this.selCateId.DataBind(); this.selCateId.Items.Insert(0, new ListItem("请选择", "")); this.selCateId.Value = ""; InitData(); } } //数据加载 public void InitData() { OA_PropertyManage m_OA_PropertyManage = bll_OA_PropertyManageBLL.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_PropertyManage != null) { this.selCateId.Value = m_OA_PropertyManage.CateId.ToString2(); this.txtCarNumber.Value = m_OA_PropertyManage.Name; this.txtPrice.Value = m_OA_PropertyManage.Price.Value.ToString("0.00"); this.txtAllNum.Value = m_OA_PropertyManage.AllNum.ToString2(); this.txtReceiveNum.Value = m_OA_PropertyManage.ReceiveNum.ToString2(); } } //表单提交 protected void btn_submit_form(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(this.txtAllNum.Value) || string.IsNullOrEmpty(this.txtReceiveNum.Value)) { JavaScript.MessageBox("物品总数量和已领取数量均不能为空", this); return; } if (this.txtAllNum.Value.ToInt32() < this.txtReceiveNum.Value.ToInt32()) { JavaScript.MessageBox("已领取数量不能大于总数量",this); return; } DateTime nowTime = DateTime.Now; OA_PropertyManage m_OA_PropertyManage = bll_OA_PropertyManageBLL.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_PropertyManage == null) { m_OA_PropertyManage = new OA_PropertyManage(); m_OA_PropertyManage.MemberId = CurrentUser.MemberId; m_OA_PropertyManage.Status = 1; m_OA_PropertyManage.Remark = ""; } m_OA_PropertyManage.CateId = this.selCateId.Value.ToInt32(); m_OA_PropertyManage.AllNum = this.txtAllNum.Value.ToInt32(); m_OA_PropertyManage.Name = this.txtCarNumber.Value; m_OA_PropertyManage.ReceiveNum = this.txtReceiveNum.Value.ToInt32(); m_OA_PropertyManage.Price = this.txtPrice.Value.ToDecimal2(); m_OA_PropertyManage.Operator = CurrentUser.ShortName; m_OA_PropertyManage.LastUpdateTime = nowTime; if (Request["keyid"].ToInt32() > 0) { if (bll_OA_PropertyManageBLL.UpdateModel(m_OA_PropertyManage)) JavaScript.MessageBox("更新成功", this, true, true); else JavaScript.MessageBox("更新失败", this); } else { if (bll_OA_PropertyManageBLL.InsertModel(m_OA_PropertyManage)) JavaScript.MessageBox("新增成功", this, false, true); else JavaScript.MessageBox("操作失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } } } }