/// <summary> /// 修改部门信息 /// </summary> /// <param name="item">部门实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MComDepartment item) { StringBuilder sql = new StringBuilder("UPDATE tbl_ComDepartment SET DepartName = @DepartName,DepartHead=@DepartHead,Contact=@Contact,"); sql.Append("Fax=@Fax,PrintHeader=@PrintHeader,PrintFooter=@PrintFooter,PrintTemplates=@PrintTemplates,Seal=@Seal,Remarks=@Remarks,OperatorId=@OperatorId "); sql.Append("WHERE DepartId = @DepartId AND CompanyId = @CompanyId"); DbCommand comm = this._db.GetSqlStringCommand(sql.ToString()); this._db.AddInParameter(comm, "@DepartName", DbType.String, item.DepartName); this._db.AddInParameter(comm, "@DepartHead", DbType.String, item.DepartHead); this._db.AddInParameter(comm, "@Contact", DbType.String, item.Contact); this._db.AddInParameter(comm, "@Fax", DbType.String, item.Fax); this._db.AddInParameter(comm, "@PrintHeader", DbType.String, item.PrintHeader); this._db.AddInParameter(comm, "@PrintFooter", DbType.String, item.PrintFooter); this._db.AddInParameter(comm, "@PrintTemplates", DbType.String, item.PrintTemplates); this._db.AddInParameter(comm, "@Seal", DbType.String, item.Seal); this._db.AddInParameter(comm, "@Remarks", DbType.String, item.Remarks); this._db.AddInParameter(comm, "@OperatorId", DbType.AnsiStringFixedLength, item.OperatorId); this._db.AddInParameter(comm, "@DepartId", DbType.Int32, item.DepartId); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); int result = DbHelper.ExecuteSql(comm, this._db); return(result > 0 ? true : false); }
/// <summary> /// 添加部门信息 /// </summary> /// <param name="item">部门实体</param> /// <returns>true:成功 false:失败</returns> public bool Add(MComDepartment item) { StringBuilder sql = new StringBuilder("INSERT INTO tbl_ComDepartment(CompanyId,DepartName,DepartHead,PrevDepartId,Contact,"); sql.Append("Fax,PrintHeader,PrintFooter,PrintTemplates,Seal,Remarks,OperatorId,CertificateCode) VALUES(@CompanyId,@DepartName,"); sql.Append("@DepartHead,@PrevDepartId,@Contact,@Fax,@PrintHeader,@PrintFooter,@PrintTemplates,@Seal,@Remarks,@OperatorId,@CertificateCode)"); DbCommand comm = this._db.GetSqlStringCommand(sql.ToString()); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); this._db.AddInParameter(comm, "@DepartName", DbType.String, item.DepartName); this._db.AddInParameter(comm, "@DepartHead", DbType.String, item.DepartHead); this._db.AddInParameter(comm, "@PrevDepartId", DbType.Int32, item.PrevDepartId); this._db.AddInParameter(comm, "@Contact", DbType.String, item.Contact); this._db.AddInParameter(comm, "@Fax", DbType.String, item.Fax); this._db.AddInParameter(comm, "@PrintHeader", DbType.String, item.PrintHeader); this._db.AddInParameter(comm, "@PrintFooter", DbType.String, item.PrintFooter); this._db.AddInParameter(comm, "@PrintTemplates", DbType.String, item.PrintTemplates); this._db.AddInParameter(comm, "@Seal", DbType.String, item.Seal); this._db.AddInParameter(comm, "@Remarks", DbType.String, item.Remarks); this._db.AddInParameter(comm, "@OperatorId", DbType.AnsiStringFixedLength, item.OperatorId); this._db.AddInParameter(comm, "@CertificateCode", DbType.AnsiString, item.CertificateCode); int result = DbHelper.ExecuteSql(comm, this._db); return(result > 0 ? true : false); }
/// <summary> /// 获取所有部门信息 /// </summary> /// <param name="companyId">公司编号</param> /// <returns></returns> public IList <MComDepartment> GetList(string companyId) { string sql = "SELECT DepartId,DepartName,PrevDepartId FROM tbl_ComDepartment WHERE CompanyId = @CompanyId"; DbCommand comm = this._db.GetSqlStringCommand(sql); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, companyId); IList <MComDepartment> list = new List <MComDepartment>(); MComDepartment item = null; using (IDataReader reader = DbHelper.ExecuteReader(comm, this._db)) { while (reader.Read()) { list.Add(item = new MComDepartment { DepartId = (int)reader["DepartId"], DepartName = reader.IsDBNull(reader.GetOrdinal("DepartName")) ? string.Empty : reader["DepartName"].ToString(), PrevDepartId = (int)reader["PrevDepartId"] }); } } return(list); }
/// <summary> /// 获取部门信息 /// </summary> /// <param name="departId">部门编号</param> /// <param name="companyId">公司编号</param> /// <returns>部门实体</returns> public MComDepartment GetModel(int departId, string companyId) { MComDepartment item = null; if (!string.IsNullOrEmpty(companyId)) { item = dal.GetModel(departId, companyId); } return(item); }
/// <summary> /// 获取部门 /// </summary> /// <param name="DepartmentID">部门ID</param> protected string GetDepartmentById(int DepartmentID, string companyid) { //返回信息 string result = ""; //实例化部门业务层 BComDepartment BLL = new BComDepartment(); MComDepartment model = BLL.GetModel(DepartmentID, companyid); if (model != null) { result = model.DepartName; } return(result); }
/// <summary> /// 修改部门信息 /// </summary> /// <param name="item">部门实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MComDepartment item) { bool result = false; if (item != null) { result = dal.Update(item); if (result) { string cacheKey = string.Format(EyouSoft.Cache.Tag.TagName.ComDept, item.CompanyId); if (EyouSoft.Cache.Facade.EyouSoftCache.GetCache(cacheKey) != null) { EyouSoft.Cache.Facade.EyouSoftCache.Remove(cacheKey); } EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("修改部门,编号为:{0}", item.DepartId)); } } return(result); }
/// <summary> /// 获取部门下的所有子部门信息 /// </summary> /// <param name="departId">部门编号</param> /// <param name="companyId">公司编号</param> /// <returns>部门集合</returns> public IList <MComDepartment> GetList(string departId, string companyId) { StringBuilder sql = new StringBuilder(); sql.Append("with depart( DepartId,DepartName,PrevDepartId)"); sql.Append(" as"); sql.Append(" ("); sql.Append(" select DepartId,DepartName,PrevDepartId"); sql.AppendFormat(" from tbl_ComDepartment where DepartId = {0} and CompanyId = '{1}'", departId, companyId); sql.Append(" union all"); sql.Append(" select a.DepartId,a.DepartName,a.PrevDepartId "); sql.Append(" from tbl_ComDepartment a "); sql.Append(" inner join depart b on a.PrevDepartId = b.DepartId"); sql.Append(" )"); sql.AppendFormat(" select * from depart where DepartId <> {0}", departId); DbCommand comm = this._db.GetSqlStringCommand(sql.ToString()); IList <MComDepartment> list = new List <MComDepartment>(); MComDepartment item = null; using (IDataReader reader = DbHelper.ExecuteReader(comm, this._db)) { while (reader.Read()) { list.Add(item = new MComDepartment { DepartId = (int)reader["DepartId"], DepartName = reader.IsDBNull(reader.GetOrdinal("DepartName")) ? string.Empty : reader["DepartName"].ToString(), PrevDepartId = (int)reader["PrevDepartId"] }); } } return(list); }
/// <summary> /// 页面初始化 /// </summary> /// <param name="id">操作ID</param> protected void PageInit(string id, string doType) { #region 用户控件初始化 this.HrSelect1.ParentIframeID = Utils.GetQueryStringValue("iframeId"); this.HrSelect1.SetTitle = "部门主管"; this.uc_Head.CompanyID = this.SiteUserInfo.CompanyId; this.uc_Foot.CompanyID = this.SiteUserInfo.CompanyId; this.uc_Temp.CompanyID = this.SiteUserInfo.CompanyId; this.uc_Seal.CompanyID = this.SiteUserInfo.CompanyId; #endregion BComDepartment BLL = new BComDepartment(); //根据编辑传过来的编号获取部门信息实体 MComDepartment Model = BLL.GetModel(Utils.GetInt(id), this.SiteUserInfo.CompanyId); if (doType == "update") { if (null != Model) { //部门名称 this.txtDepartName.Text = Model.DepartName; //部门编号 this.hidDepartId.Value = Model.DepartId.ToString(); //联系电话 this.txtContact.Text = Model.Contact; //传真 this.txtFaxa.Text = Model.Fax; //备注 this.txtRemark.Text = Model.Remarks; string strDel = "<span class='upload_filename'><a href='{0}' target='_blank'>查看</a><a href=\"javascript:void(0)\" onclick=\"PageJsData.DelFile(this)\" title='删除附件'><img style='vertical-align:middle' src='/images/cha.gif'></a><input type=\"hidden\" name=\"hide_{1}\" value=\"{0}\"/></span>"; if (!string.IsNullOrEmpty(Model.PrintHeader)) { //页眉 this.lbTxtHead.Text = string.Format(strDel, Model.PrintHeader, "head"); } if (!string.IsNullOrEmpty(Model.PrintFooter)) { //页脚 this.lbTxtFoot.Text = string.Format(strDel, Model.PrintFooter, "foot"); } if (!string.IsNullOrEmpty(Model.PrintTemplates)) { //模板 this.lbTxtTemp.Text = string.Format(strDel, Model.PrintTemplates, "temp"); } if (!string.IsNullOrEmpty(Model.Seal)) { //公章 this.lbTxtSeal.Text = string.Format(strDel, Model.Seal, "seal"); } //部门主管编号 this.HrSelect1.HrSelectID = Model.DepartHead; //this.HrSelect1.HrSelectName = Model.DepartHead; MComDepartment ModelPart = BLL.GetModel(Model.PrevDepartId, Model.CompanyId); if (ModelPart != null) { //上级部门名称和编号 this.txtUpSection.Text = ModelPart.DepartName; this.hidupsectionId.Value = ModelPart.DepartId.ToString(); } else { this.txtUpSection.Text = "股东会"; } //通过部门主管编号获取人事档案信息实体 EyouSoft.BLL.GovStructure.BArchives BLLManager = new EyouSoft.BLL.GovStructure.BArchives(); EyouSoft.Model.GovStructure.MGovFile ModelManager; ModelManager = BLLManager.GetArchivesModel(Model.DepartHead); if (ModelManager != null) { this.HrSelect1.HrSelectName = ModelManager.Name; this.HrSelect1.HrSelectID = ModelManager.ID; } } else { this.txtUpSection.Text = "股东会"; } } else { if (Model != null) { this.txtUpSection.Text = Model.DepartName; this.hidupsectionId.Value = Model.DepartId.ToString(); } else { this.txtUpSection.Text = "股东会"; this.hidupsectionId.Value = "0"; } } }
/// <summary> /// 保存按钮点击事件执行方法 /// </summary> protected void PageSave(string doType) { #region 表单取值 //部门名称 string deptname = Utils.GetFormValue(txtDepartName.UniqueID); //部门编号 string deptid = Utils.GetFormValue(hidDepartId.UniqueID); //部门主管编号 string depthead = Utils.GetFormValue(this.HrSelect1.HrSelectIDClient); //上级部门编号 string upsection = Utils.GetFormValue(this.hidupsectionId.UniqueID); //联系电话 string contact = Utils.GetFormValue(txtContact.UniqueID); //传真 string fax = Utils.GetFormValue(txtFaxa.UniqueID); string remark = Utils.GetFormValue(txtRemark.UniqueID); string head = Utils.GetFormValue(this.uc_Head.ClientHideID); string[] headpath = Utils.GetFormValue(this.uc_Head.ClientHideID).Split('|'); string[] footpath = Utils.GetFormValue(this.uc_Foot.ClientHideID).Split('|'); string[] temppath = Utils.GetFormValue(this.uc_Temp.ClientHideID).Split('|'); string[] sealpath = Utils.GetFormValue(this.uc_Seal.ClientHideID).Split('|'); string oldhead = Utils.GetFormValue("hide_head"); string oldfoot = Utils.GetFormValue("hide_foot"); string oldtemp = Utils.GetFormValue("hide_temp"); string oldseal = Utils.GetFormValue("hide_seal"); #endregion #region 数据验证 string msg = ""; bool result = false; if (string.IsNullOrEmpty(deptname)) { msg += "-请输入部门名称!"; } if (!string.IsNullOrEmpty(msg)) { Response.Clear(); Response.Write("{\"result\":\"" + result + "\",\"msg\":\"" + msg + "\"}"); Response.End(); } #endregion #region 实体赋值 MComDepartment model = new MComDepartment(); model.CompanyId = this.SiteUserInfo.CompanyId; model.Contact = contact; model.DepartHead = depthead; //model.DepartId = model.DepartName = deptname; model.DepartId = Utils.GetInt(deptid, 0); model.Fax = fax; model.IssueTime = DateTime.Now; model.OperatorId = this.SiteUserInfo.UserId; model.PrevDepartId = Utils.GetInt(upsection); if (footpath != null && footpath.Length > 1) { model.PrintFooter = footpath[1]; } else { model.PrintFooter = oldfoot; } if (headpath != null && headpath.Length > 1) { model.PrintHeader = headpath[1]; } else { model.PrintHeader = oldhead; } if (temppath != null && temppath.Length > 1) { model.PrintTemplates = temppath[1]; } else { model.PrintTemplates = oldtemp; } if (sealpath != null && sealpath.Length > 1) { model.Seal = sealpath[1]; } else { model.Seal = oldseal; } model.Remarks = remark; #endregion #region 提交保存 Response.Clear(); BComDepartment BLL = new BComDepartment(); if (doType == "add") { result = BLL.Add(model); msg = result ? "添加成功!" : "添加失败!"; Response.Write("{\"result\":\"" + (result ? "1" : "0") + "\",\"msg\":\"" + msg + "\",\"id\":\"" + model.PrevDepartId + "\"}"); } else { result = BLL.Update(model); msg = result ? "修改成功!" : "修改失败!"; Response.Write("{\"result\":\"" + (result ? "1" : "0") + "\",\"msg\":\"" + msg + "\",\"id\":\"" + model.DepartId + "\",\"nowName\":\"" + model.DepartName + "\"}"); } Response.End(); #endregion }