using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using CY.BLL; using CY.Model; using CY.Infrastructure.Query; using CY.Infrastructure.Common; using CY.BLL.Sys; using CY.BLL.OA; namespace CY.WebForm.Pages.financial { public partial class SubjectSetEdit : BasePage { Sys_DictionaryBLL _Sys_DictionaryBLL = null; //字典类业务逻辑操作对象 OA_SubjectSetBLL _OA_SubjectSetBLL = null; // 科目类业务逻辑操作对象 OA_SubjectSet subjectSet = null; // 科目类对象 public SubjectSetEdit() { _Sys_DictionaryBLL = new Sys_DictionaryBLL(); _OA_SubjectSetBLL = new OA_SubjectSetBLL(); subjectSet = new OA_SubjectSet(); } protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { InitialData(); if (Request["Keyid"].ToInt32() > 0) // 加载要修改的的数据 { InitialModifyData(); } } } /// /// 初始化科目类别 /// public void InitialData() { this.selGoodsStatus.DataSource = _Sys_DictionaryBLL.GetDataByType("科目类别"); this.selGoodsStatus.DataBind(); } /// /// 初始化要修改的数据 /// public void InitialModifyData() { subjectSet = _OA_SubjectSetBLL.getSingleSubject(Request["Keyid"].ToInt32()); if (subjectSet == null || subjectSet.FirmId != CurrentUser.MemberId) { JavaScript.MessageBox("数据错误", this, true, true); return; } this.selGoodsStatus.Value = subjectSet.SubjectType.ToString2(); this.txtRemark.Value = subjectSet.Remark.ToString2(); this.txtSubjectName.Value = subjectSet.SubjectName.ToString2(); this.selStatus.Value = subjectSet.Status.ToString2(); } /// /// 添加或修改科目 /// /// /// protected void btn_Submit_Config(object sender, EventArgs e) { if (Request["Keyid"].ToInt32() > 0) //如果keyid 大于0 则再加载一次对象,方便利用对象里面的不变属性 { subjectSet = _OA_SubjectSetBLL.getSingleSubject(Request["Keyid"].ToInt32()); if (subjectSet == null || subjectSet.FirmId != CurrentUser.MemberId) { JavaScript.MessageBox("数据错误", this, true, true); return; } } if (_OA_SubjectSetBLL.CheckTypeAndName(Request["Keyid"].ToInt32(), this.selGoodsStatus.Value.ToString2(), this.txtSubjectName.Value.ToString2(), CurrentUser.MemberId)) { JavaScript.MessageBox("所选科目类别下面已存在此科目,请勿重复", this, " window.location = location;"); return; } subjectSet.LastUpdateTime = System.DateTime.Now; subjectSet.Remark = this.txtRemark.Value.ToString2(); subjectSet.SubjectType = this.selGoodsStatus.Value.ToString2(); subjectSet.SubjectName = this.txtSubjectName.Value.ToString2(); subjectSet.Operator = CurrentUser.ShortName; subjectSet.Status = Convert.ToBoolean(this.selStatus.Value); if (Request["Keyid"].ToInt32() > 0) { if (_OA_SubjectSetBLL.UpdateModel(subjectSet)) JavaScript.MessageBox("更新成功", this, true, true); else JavaScript.MessageBox("更新失败", this); } else { subjectSet.FirmId = CurrentUser.MemberId; if (_OA_SubjectSetBLL.InserModel(subjectSet)) JavaScript.MessageBox("添加成功", this, true, true); else JavaScript.MessageBox("添加失败", this); } } } }