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.Infrastructure.Query; using CY.BLL.Sys; namespace CY.WebForm.Pages.work { //吴辉 //新增/修改公文管理 public partial class Adm_zhanghaomimaAdd : BasePage { Adm_zhanghaomimaBLL bll_Adm_zhanghaomimaBLL = null; Sys_DictionaryBLL bll_Sys_DictionaryBLL = null; OA_StaffBLL bll_OA_StaffBLL = null; OA_DepartmentBll bll_OA_DepartmentBll = null; public string staffs = ""; //初始化 public Adm_zhanghaomimaAdd() { bll_Adm_zhanghaomimaBLL = new Adm_zhanghaomimaBLL(); bll_Sys_DictionaryBLL = new Sys_DictionaryBLL(); bll_OA_StaffBLL = new OA_StaffBLL(); bll_OA_DepartmentBll = new OA_DepartmentBll(); } //页面加载 protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Pagination pa = new Pagination(); pa.PageSize = 500; pa.PageIndex = 1; this.seltype.DataSource = bll_Sys_DictionaryBLL.GetDataByType("Sys_账号密码"); this.seltype.DataValueField = "MeanValue"; this.seltype.DataTextField = "Name"; this.seltype.DataBind(); InitData(); } } //数据加载 public void InitData() { this.seltype.Value = ""; this.txtchanpinxiangmu.Value = ""; this.txtzhanghao.Value = ""; this.txtmima.Value = ""; this.txtmibao.Text = ""; if (string.IsNullOrEmpty(Request["keyid"])) { string departid = ""; var oA_Staffs = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false).OrderBy(x => x.DepartmentId).ToList(); for (int i = 0; i < oA_Staffs.Count; i++) { if (i != 0 && oA_Staffs[i].DepartmentId != oA_Staffs[i - 1].DepartmentId) { var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId); if (department != null) { departid = department.Keyid.Value.ToString(); staffs += "
" + department.Name + ":"; } } if (i == 0) { var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId); if (department != null) { departid = department.Keyid.Value.ToString(); staffs += "
" + department.Name + ":"; } } staffs += " " + "" + "" + oA_Staffs[i].Name + ""; } } if (!string.IsNullOrEmpty(Request["keyid"])) { var adm_zhanghaomima = bll_Adm_zhanghaomimaBLL.GetModelByKeyid(Request["keyid"].ToInt32().Value); if (adm_zhanghaomima != null) { this.seltype.Value = adm_zhanghaomima.type_id.Value.ToString(); this.txtchanpinxiangmu.Value = adm_zhanghaomima.chanpinxiangmu; this.txtzhanghao.Value = adm_zhanghaomima.zhanghao; this.txtmima.Value = adm_zhanghaomima.mima; this.txtmibao.Text = adm_zhanghaomima.mibao; var Jusequanxian = adm_zhanghaomima.Jusequanxian; var Jusequanxians = Jusequanxian.Trim(',').Split(','); var juesequanxian = new List(); foreach (var juese in Jusequanxians) { juesequanxian.Add(juese.ToInt32()); } string departid = ""; bool shifouxianshi = false; var oA_Staffs = bll_OA_StaffBLL.SelectListByFirmId(CurrentUser.MemberId, false, false).OrderBy(x => x.DepartmentId).ToList(); for (int i = 0; i < oA_Staffs.Count; i++) { if (i != 0 && oA_Staffs[i].DepartmentId != oA_Staffs[i - 1].DepartmentId) { var ocount = oA_Staffs.Count(x => x.DepartmentId == oA_Staffs[i].DepartmentId && juesequanxian.Contains(x.Keyid)); if (ocount > 0) { shifouxianshi = true; } else { shifouxianshi = false; } var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId); if (department != null) { departid = department.Keyid.Value.ToString(); if (shifouxianshi) { staffs += "
" + department.Name + ":"; } else { staffs += "
" + department.Name + ":"; } } } if (i == 0) { var ocount = oA_Staffs.Count(x => x.DepartmentId == oA_Staffs[i].DepartmentId && juesequanxian.Contains(x.Keyid)); if (ocount > 0) { shifouxianshi = true; } else { shifouxianshi = false; } var department = bll_OA_DepartmentBll.GetModelByKeyid(oA_Staffs[i].DepartmentId); if (department != null) { departid = department.Keyid.Value.ToString(); if (shifouxianshi) { staffs += " " + department.Name + ":"; } else { staffs += " " + department.Name + ":"; } } } if (shifouxianshi) { if (Jusequanxians.Count(x => x == oA_Staffs[i].Keyid.Value.ToString()) > 0) { staffs += " " + "" + "" + oA_Staffs[i].Name + ""; } else { staffs += " " + "" + "" + oA_Staffs[i].Name + ""; } } else { staffs += " " + "" + "" + oA_Staffs[i].Name + ""; } } } } } //表单提交 protected void btn_submit_form(object sender, EventArgs e) { try { DateTime nowTime = DateTime.Now; Adm_zhanghaomima adm_zhanghaomima = new Adm_zhanghaomima(); if (!string.IsNullOrEmpty(Request["keyid"])) { adm_zhanghaomima = bll_Adm_zhanghaomimaBLL.GetModelByKeyid(Request["keyid"].ToInt32().Value); adm_zhanghaomima.FirmId = CurrentUser.MemberId; adm_zhanghaomima.type_id = this.seltype.Value.ToInt32().Value; adm_zhanghaomima.chanpinxiangmu = this.txtchanpinxiangmu.Value.Trim(); adm_zhanghaomima.zhanghao = this.txtzhanghao.Value.Trim(); adm_zhanghaomima.mima = this.txtmima.Value.Trim(); adm_zhanghaomima.mibao = this.txtmibao.Text.Trim(); adm_zhanghaomima.rec_status = "A"; adm_zhanghaomima.modifier = CurrentUser.ShortName; adm_zhanghaomima.modifytime = DateTime.Now; adm_zhanghaomima.Jusequanxian = "," + this.deleteKeyIds.Value + ","; if (bll_Adm_zhanghaomimaBLL.UpdateModel(adm_zhanghaomima)) { JavaScript.MessageBox("修改成功", this, true, true); //InitData(); } else JavaScript.MessageBox("修改失败", this); } else { adm_zhanghaomima.FirmId = CurrentUser.MemberId; adm_zhanghaomima.type_id = this.seltype.Value.ToInt32().Value; adm_zhanghaomima.chanpinxiangmu = this.txtchanpinxiangmu.Value.Trim(); adm_zhanghaomima.zhanghao = this.txtzhanghao.Value.Trim(); adm_zhanghaomima.mima = this.txtmima.Value.Trim(); adm_zhanghaomima.mibao = this.txtmibao.Text.Trim(); adm_zhanghaomima.rec_status = "A"; adm_zhanghaomima.creater = CurrentUser.ShortName; adm_zhanghaomima.createtime = DateTime.Now; adm_zhanghaomima.modifier = adm_zhanghaomima.creater; adm_zhanghaomima.modifytime = adm_zhanghaomima.createtime; adm_zhanghaomima.Jusequanxian = "," + this.deleteKeyIds.Value + ","; if (bll_Adm_zhanghaomimaBLL.InsertModel(adm_zhanghaomima)) { JavaScript.MessageBox("新增成功", this, false, true); InitData(); } else JavaScript.MessageBox("新增失败", this); } } catch (Exception ex) { PAGEHandleException(ex); JavaScript.MessageBox("操作失败", this); } } } }