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.work { //吴辉 //行政物品 public partial class GongzuozhizeEdit : BasePage { OA_GongzuozhizeBLL bll_OA_GongzuozhizeBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; OA_DepartmentBll bll_OA_DepartmentBll = null; public GongzuozhizeEdit() { bll_OA_GongzuozhizeBLL = new OA_GongzuozhizeBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); bll_OA_DepartmentBll = new OA_DepartmentBll(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { try { switch (Request["Target"]) { case "change": Response.Write(reLoadAccountName(Request["TypeName"].ToString2())); break; default: if (!IsPostBack) { this.selZerenren.DataSource = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, null, null); this.selZerenren.DataTextField = "Name"; this.selZerenren.DataValueField = "Keyid"; this.selZerenren.DataBind(); //this.selZerenren.Items.Insert(0, new ListItem("全部", "")); //this.selZerenren.Value = ""; Pagination pa = new Pagination(); pa.PageSize = 500; pa.PageIndex = 1; this.selBumen.DataSource = bll_OA_DepartmentBll.SelectModelPage(pa, CurrentUser.MemberId, "", "启用"); this.selBumen.DataTextField = "Name"; this.selBumen.DataValueField = "Keyid"; this.selBumen.DataBind(); this.selBumen.Items.Insert(0, new ListItem("全部", "")); this.selBumen.Value = ""; InitData(); } return; } } catch (Exception ex) { PAGEHandleException(ex); Response.Clear(); //Response.Write("-1"); Response.Write(ex.Message); } Response.End(); } //数据加载 public void InitData() { OA_Gongzuozhize m_OA_Gongzuozhize = bll_OA_GongzuozhizeBLL.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_Gongzuozhize != null) { this.txtCarNumbera.Value = m_OA_Gongzuozhize.Gongzuozhize; this.selZerenren.Value = m_OA_Gongzuozhize.Zerenren.HasValue? m_OA_Gongzuozhize.Zerenren.ToString():""; } } //表单提交 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_Gongzuozhize m_OA_Gongzuozhize = bll_OA_GongzuozhizeBLL.GetModelByKeyid(Request["keyid"].ToInt32()); if (m_OA_Gongzuozhize == null) { m_OA_Gongzuozhize = new OA_Gongzuozhize(); m_OA_Gongzuozhize.MemberId = CurrentUser.MemberId; } m_OA_Gongzuozhize.Gongzuozhize = this.txtCarNumbera.Value; m_OA_Gongzuozhize.Zerenren = this.selZerenren.Value.ToInt32(); var a_Staff = bll_OA_StaffBLL.GetModelByKeyid(m_OA_Gongzuozhize.Zerenren); if (a_Staff != null) { m_OA_Gongzuozhize.ZerenrenName = a_Staff.Name; } else { m_OA_Gongzuozhize.ZerenrenName = ""; } m_OA_Gongzuozhize.Updator = CurrentUser.ShortName; m_OA_Gongzuozhize.LastUpdateTime = nowTime; if (Request["keyid"].ToInt32() > 0) { if (bll_OA_GongzuozhizeBLL.UpdateModel(m_OA_Gongzuozhize)) { JavaScript.MessageBox("更新成功", this, true, true); } else JavaScript.MessageBox("更新失败", this); } else { m_OA_Gongzuozhize.Creator = CurrentUser.ShortName; m_OA_Gongzuozhize.CreateTime = nowTime; if (bll_OA_GongzuozhizeBLL.InsertModel(m_OA_Gongzuozhize)) { this.txtCarNumbera.Value=""; JavaScript.MessageBox("新增成功", this, false, true); } else JavaScript.MessageBox("操作失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } } protected string reLoadAccountName(string selAcoountType) { if (!string.IsNullOrEmpty(selAcoountType)) { return JsonHelper.GetJsonStringByObject(bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId,false,false).Where(x => x.DepartmentId == selAcoountType.ToInt32())); } else { return JsonHelper.GetJsonStringByObject(bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false)); } } } }