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 PropertyRecordEdit : BasePage { Sys_DictionaryBLL bll_Sys_DictionaryBLL = null; OA_PropertyRecordBLL bll_OA_PropertyRecordBLL = null; OA_PropertyManageBLL bll_OA_PropertyManageBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; public PropertyRecordEdit() { bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); bll_OA_PropertyRecordBLL = new OA_PropertyRecordBLL(); bll_OA_PropertyManageBLL = new OA_PropertyManageBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); } //页面加载 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.SelectedValue = ""; this.selPropertyId.Items.Insert(0, new ListItem("请选择", "")); } } //表单提交 protected void btn_submit_form(object sender, EventArgs e) { try { if (this.txtAddQuality.Value.ToInt32() > this.spanNowNum.InnerText.ToInt32()) { JavaScript.MessageBox("申请数量不能大于剩余数量",this); return; } DateTime nowTime = DateTime.Now; OA_PropertyRecord m_OA_PropertyRecord = bll_OA_PropertyRecordBLL.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_PropertyRecord == null) { m_OA_PropertyRecord = new OA_PropertyRecord(); m_OA_PropertyRecord.MemberId = CurrentUser.MemberId; m_OA_PropertyRecord.Status = 1; m_OA_PropertyRecord.Remark = ""; m_OA_PropertyRecord.ApproveId = CurrentUser.MemberId; m_OA_PropertyRecord.ApproveQuality = 0; m_OA_PropertyRecord.ApproveRemark = ""; m_OA_PropertyRecord.ApproveTime = nowTime; m_OA_PropertyRecord.BackId = CurrentUser.MemberId; m_OA_PropertyRecord.BackQuality = 0; m_OA_PropertyRecord.BackRemark = ""; m_OA_PropertyRecord.BackTime = nowTime; OA_Staff m_OA_Staff = bll_OA_StaffBLL.GetModelByMemberId(CurrentUser.TrueMemberId); if (m_OA_Staff != null) m_OA_PropertyRecord.DepartmentId = m_OA_Staff.DepartmentId; else m_OA_PropertyRecord.DepartmentId = 0; m_OA_PropertyRecord.AddName = CurrentUser.TrueName; m_OA_PropertyRecord.AddId = CurrentUser.TrueMemberId; } m_OA_PropertyRecord.CateId = this.selCateId.SelectedValue.ToInt32(); m_OA_PropertyRecord.AddQuality = this.txtAddQuality.Value.ToInt32(); m_OA_PropertyRecord.AddRemark = this.txtAddRemark.Value; m_OA_PropertyRecord.AddTime = nowTime; m_OA_PropertyRecord.PropertyId = this.selPropertyId.SelectedValue.ToInt32(); m_OA_PropertyRecord.Operator = CurrentUser.ShortName; m_OA_PropertyRecord.LastUpdateTime = nowTime; if (Request["keyid"].ToInt32() > 0) { if (bll_OA_PropertyRecordBLL.UpdateModel(m_OA_PropertyRecord)) JavaScript.MessageBox("更新成功", this, true, true); else JavaScript.MessageBox("更新失败", this); } else { if (bll_OA_PropertyRecordBLL.InsertModel(m_OA_PropertyRecord)) JavaScript.MessageBox("新增成功", this, true, true); else JavaScript.MessageBox("操作失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } } //分类修改 protected void selCateId_SelectedIndexChanged(object sender, EventArgs e) { GetListByCate(this.selCateId.SelectedValue.ToInt32()); } //物品获取 public void GetListByCate(int? CateId) { if (CateId > 0) { this.selPropertyId.DataSource = bll_OA_PropertyManageBLL.GetDataByCate(CurrentUser.MemberId, CateId, true); this.selPropertyId.DataTextField = "Name"; this.selPropertyId.DataValueField = "Keyid"; this.selPropertyId.DataBind(); this.selPropertyId.Items.Insert(0, new ListItem("请选择", "")); this.selPropertyId.SelectedValue = ""; } else { this.selPropertyId.Items.Clear(); this.selPropertyId.Items.Insert(0, new ListItem("请选择", "")); } } //物品修改 protected void selPropertyId_SelectedIndexChanged(object sender, EventArgs e) { if (this.selPropertyId.SelectedValue.ToInt32() > 0) { OA_PropertyManage m_OA_PropertyManage = bll_OA_PropertyManageBLL.GetModelByKeyid(this.selPropertyId.SelectedValue.ToInt32()); if (m_OA_PropertyManage != null) { this.spanNowNum.InnerText =(m_OA_PropertyManage.AllNum - m_OA_PropertyManage.ReceiveNum).ToString(); this.spanPrice.InnerText =m_OA_PropertyManage.Price.Value.ToString("0.00"); this.txtAddRemark.Attributes.Add("max", (m_OA_PropertyManage.AllNum - m_OA_PropertyManage.ReceiveNum).ToString()); }else { this.spanNowNum.InnerText = "0"; this.spanPrice.InnerText = "0"; this.txtAddRemark.Attributes.Add("max", "0"); } } } } }