/// <summary> /// 修改用户信息 /// </summary> /// <param name="item">用户信息实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MComUser item) { DbCommand comm = this._db.GetStoredProcCommand("proc_ComUser_Update"); this._db.AddInParameter(comm, "@UserId", DbType.AnsiStringFixedLength, item.UserId); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); this._db.AddInParameter(comm, "@Password", DbType.AnsiString, item.Password); this._db.AddInParameter(comm, "@md5", DbType.AnsiString, item.MD5Password); this._db.AddInParameter(comm, "@ContactName", DbType.String, item.ContactName); this._db.AddInParameter(comm, "@ContactSex", DbType.AnsiStringFixedLength, item.ContactSex); this._db.AddInParameter(comm, "@ContactTel", DbType.String, item.ContactTel); this._db.AddInParameter(comm, "@ContactFax", DbType.String, item.ContactFax); this._db.AddInParameter(comm, "@ContactMobile", DbType.String, item.ContactMobile); this._db.AddInParameter(comm, "@ContactEmail", DbType.String, item.ContactEmail); this._db.AddInParameter(comm, "@QQ", DbType.String, item.QQ); this._db.AddInParameter(comm, "@msn", DbType.String, item.MSN); this._db.AddInParameter(comm, "@JobName", DbType.String, item.JobName); this._db.AddInParameter(comm, "@RoleId", DbType.Int32, item.RoleId); this._db.AddInParameter(comm, "@DeptId", DbType.Int32, item.DeptId); this._db.AddInParameter(comm, "@DeptName", DbType.String, item.DeptName); this._db.AddInParameter(comm, "@PeopProfile", DbType.String, item.PeopProfile); this._db.AddInParameter(comm, "@Remark", DbType.String, item.Remark); this._db.AddInParameter(comm, "@CertificateCode", DbType.AnsiString, item.CertificateCode); this._db.AddInParameter(comm, "@DeptIdJG", DbType.Int32, item.DeptIdJG); this._db.AddInParameter(comm, "@Arrears", DbType.Currency, item.Arrears); this._db.AddInParameter(comm, "@OperatorId", DbType.AnsiStringFixedLength, item.OperatorId); this._db.AddInParameter(comm, "@Operator", DbType.String, item.Operator); this._db.AddInParameter(comm, "@OperDeptId", DbType.String, item.OperDeptId); int result = DbHelper.ExecuteSql(comm, this._db); return(result > 0 ? true : false); }
/// <summary> /// 获取用户实体 /// </summary> /// <param name="userId">用户编号</param> /// <param name="companyId">公司编号</param> /// <returns>用户实体</returns> public MComUser GetModel(string userId, string companyId) { MComUser item = null; if (!string.IsNullOrEmpty(userId) && !string.IsNullOrEmpty(companyId)) { item = dal.GetModel(userId, companyId); } return(item); }
/// <summary> /// 添加用户 /// </summary> /// <param name="item">用户信息实体</param> /// <returns>true:成功 false:失败</returns> public bool Add(MComUser item) { bool result = false; if (item != null) { item.UserId = Guid.NewGuid().ToString(); item.MD5Password = new EyouSoft.Toolkit.DataProtection.HashCrypto().MD5Encrypt(item.Password); result = dal.Add(item); if (result) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("添加用户,编号为:{0}", item.UserId)); } } return(result); }
/// <summary> /// 修改用户信息 /// </summary> /// <param name="item">用户信息实体</param> /// <returns>true:成功 false:失败</returns> public bool Update(MComUser item) { bool result = false; if (item != null) { item.MD5Password = new EyouSoft.Toolkit.DataProtection.HashCrypto().MD5Encrypt(item.Password); result = dal.Update(item); if (result) { EyouSoft.BLL.SysStructure.BSysLogHandle.Insert(string.Format("修改用户,编号为:{0}", item.UserId)); string cacheKey = string.Format(EyouSoft.Cache.Tag.TagName.ComUser, item.CompanyId, item.UserId); EyouSoft.Cache.Facade.EyouSoftCache.Remove(cacheKey); } } return(result); }
/// <summary> /// 添加用户 /// </summary> /// <param name="item">用户信息实体</param> /// <returns>true:成功 false:失败</returns> public bool Add(MComUser item) { DbCommand comm = this._db.GetStoredProcCommand("proc_ComUser_Add"); this._db.AddInParameter(comm, "@UserId", DbType.AnsiStringFixedLength, item.UserId); this._db.AddInParameter(comm, "@CompanyId", DbType.AnsiStringFixedLength, item.CompanyId); this._db.AddInParameter(comm, "@TourCompanyId", DbType.AnsiStringFixedLength, item.TourCompanyId); this._db.AddInParameter(comm, "@UserName", DbType.AnsiString, item.UserName); this._db.AddInParameter(comm, "@Password", DbType.AnsiString, item.Password); this._db.AddInParameter(comm, "@md5", DbType.AnsiString, item.MD5Password); this._db.AddInParameter(comm, "@userType", DbType.Byte, (int)item.UserType); this._db.AddInParameter(comm, "@ContactName", DbType.String, item.ContactName); this._db.AddInParameter(comm, "@GovFileId", DbType.String, item.GovFileId); this._db.AddInParameter(comm, "@ContactSex", DbType.AnsiStringFixedLength, item.ContactSex); this._db.AddInParameter(comm, "@ContactTel", DbType.String, item.ContactTel); this._db.AddInParameter(comm, "@ContactFax", DbType.String, item.ContactFax); this._db.AddInParameter(comm, "@ContactMobile", DbType.String, item.ContactMobile); this._db.AddInParameter(comm, "@ContactEmail", DbType.String, item.ContactEmail); this._db.AddInParameter(comm, "@QQ", DbType.String, item.QQ); this._db.AddInParameter(comm, "@msn", DbType.String, item.MSN); this._db.AddInParameter(comm, "@JobName", DbType.String, item.JobName); this._db.AddInParameter(comm, "@LastLoginIP", DbType.String, item.LastLoginIP); this._db.AddInParameter(comm, "@LastLoginTime", DbType.DateTime, item.LastLoginTime); this._db.AddInParameter(comm, "@RoleId", DbType.Int32, item.RoleId); this._db.AddInParameter(comm, "@DeptId", DbType.Int32, item.DeptId); this._db.AddInParameter(comm, "@DeptName", DbType.String, item.DeptName); this._db.AddInParameter(comm, "@PeopProfile", DbType.String, item.PeopProfile); this._db.AddInParameter(comm, "@Remark", DbType.String, item.Remark); this._db.AddInParameter(comm, "@CertificateCode", DbType.AnsiString, item.CertificateCode); this._db.AddInParameter(comm, "@DeptIdJG", DbType.Int32, item.DeptIdJG); this._db.AddInParameter(comm, "@OperatorId", DbType.AnsiStringFixedLength, item.OperatorId); this._db.AddInParameter(comm, "@Operator", DbType.String, item.Operator); this._db.AddInParameter(comm, "@OperDeptId", DbType.String, item.OperDeptId); this._db.AddInParameter(comm, "@Arrears", DbType.Decimal, item.Arrears); int result = DbHelper.ExecuteSql(comm, this._db); return(result > 0 ? true : false); }
/// <summary> /// 分页获取用户信息 /// </summary> /// <param name="pageCurrent">当前页</param> /// <param name="pageSize">每页显示记录数</param> /// <param name="pageCount">总记录数</param> /// <param name="companyId">公司编号</param> /// <param name="search">搜索实体</param> /// <returns>用户信息集合</returns> public IList <MComUser> GetList(int pageCurrent, int pageSize, ref int pageCount, string companyId, MComUserSearch search) { string tableName = "tbl_ComUser"; string primaryKey = "UserId"; string orderBy = "IssueTime DESC"; string fileds = "UserId,CompanyId,RoleId,DeptId,IsAdmin,(select DepartName from tbl_ComDepartment where DepartId=tbl_ComUser.DeptId) DeptName,UserName,UserType,ContactName,ContactTel,ContactMobile,ContactFax,QQ,UserStatus,OnlineStatus"; fileds += ",Arrears,(SELECT A.RoleName FROM tbl_ComRole AS A WHERE A.Id=tbl_ComUser.RoleId) AS RoleName"; IList <MComUser> list = new List <MComUser>(); MComUser item = null; StringBuilder query = new StringBuilder(); query.AppendFormat(" CompanyId = '{0}' and IsDelete='0' and UserType in({1},{2}) ", companyId, (int)UserType.内部员工, (int)UserType.导游); if (search != null) { if (!string.IsNullOrEmpty(search.UserName)) { query.AppendFormat(" AND UserName like '%{0}%'", Utils.ToSqlLike(search.UserName)); } if (!string.IsNullOrEmpty(search.ContactName)) { query.AppendFormat(" AND ContactName like '%{0}%'", Utils.ToSqlLike(search.ContactName)); } if (search.DeptId != 0) { query.AppendFormat(" AND DeptId = {0}", search.DeptId); } else { if (!string.IsNullOrEmpty(search.DeptName)) { query.AppendFormat(" AND exists(select 1 from tbl_ComDepartment where DepartId=tbl_ComUser.DeptId and DepartName like '%{0}%')", Utils.ToSqlLike(search.DeptName)); } } if (search.UserStatus.HasValue) { query.AppendFormat(" AND UserStatus = {0}", (int)search.UserStatus.Value); } if (search.RoleId.HasValue) { query.AppendFormat(" AND RoleId = {0}", search.RoleId.Value); } } using (IDataReader reader = DbHelper.ExecuteReader(this._db, pageSize, pageCurrent, ref pageCount, tableName, primaryKey, fileds, query.ToString(), orderBy)) { while (reader.Read()) { list.Add(item = new MComUser() { UserId = reader["UserId"].ToString(), CompanyId = reader["CompanyId"].ToString(), UserName = reader["UserName"].ToString(), RoleId = (int)reader["RoleId"], UserType = (UserType)Enum.Parse(typeof(UserType), reader["UserType"].ToString()), ContactName = reader["ContactName"].ToString(), ContactTel = reader.IsDBNull(reader.GetOrdinal("ContactTel")) ? string.Empty : reader["ContactTel"].ToString(), ContactFax = reader.IsDBNull(reader.GetOrdinal("ContactFax")) ? string.Empty : reader["ContactFax"].ToString(), ContactMobile = reader.IsDBNull(reader.GetOrdinal("ContactMobile")) ? string.Empty : reader["ContactMobile"].ToString(), QQ = reader.IsDBNull(reader.GetOrdinal("QQ")) ? string.Empty : reader["QQ"].ToString(), DeptName = reader.IsDBNull(reader.GetOrdinal("DeptName")) ? string.Empty : reader["DeptName"].ToString(), UserStatus = (EyouSoft.Model.EnumType.ComStructure.UserStatus)reader.GetByte(reader.GetOrdinal("UserStatus")), DeptId = reader.IsDBNull(reader.GetOrdinal("DeptId")) ? 0 : reader.GetInt32(reader.GetOrdinal("DeptId")), IsAdmin = reader["IsAdmin"].ToString() == "1" ? true : false, OnlineStatus = (UserOnlineStatus)reader.GetByte(reader.GetOrdinal("OnlineStatus")), Arrears = reader.GetDecimal(reader.GetOrdinal("Arrears")), RoleName = reader["RoleName"].ToString() }); } } return(list); }
/// <summary> /// 保存按钮点击事件执行方法 /// </summary> private string PageSave(string doType, string id) { string msg = string.Empty; //t为false为编辑,true时为新增 bool t = String.Equals(doType, "update", StringComparison.InvariantCultureIgnoreCase) && !string.IsNullOrEmpty(id) ? false : true; //国家 #region 表单取值 string country = Utils.GetFormValue(this.ddlCountry.UniqueID); //省份 string provice = Utils.GetFormValue(this.ddlProvice.UniqueID); //城市 string city = Utils.GetFormValue(this.ddlCity.UniqueID); //县区 string area = Utils.GetFormValue(this.ddlArea.UniqueID); //地址 string address = Utils.GetFormValue(this.txtaddress.UniqueID); //单位名称 string UnitName = Utils.GetFormValue(this.txtUnitName.UniqueID); //线路特色 string Character = Utils.GetFormValue(this.txtCharacter.UniqueID); //合同开始时间 string ContractStartDate = Utils.GetFormValue(this.txtContractDate_Start.UniqueID); //合同有到期时间 string ContractDate = Utils.GetFormValue(this.txtContractDate.UniqueID); //合同号 string ContractNum = Utils.GetFormValue(this.txtContractNum.UniqueID); //法人代表 string LegalName = Utils.GetFormValue(this.txtLegalName.UniqueID); //许可证号 string PermitNum = Utils.GetFormValue(this.txtPermitNum.UniqueID); //返佣政策 string Policy = Utils.GetFormValue(this.txtpolicy.UniqueID); //联系电话 string Tel = Utils.GetFormValue(this.txtTel.UniqueID); //合同附件(新) string[] visaUpload = Utils.GetFormValues(this.UploadControl1.ClientHideID); string[] oldVisaUpload = Utils.GetFormValues("hideFileInfo"); #endregion EyouSoft.Model.CrmStructure.MCrmLinkman m = new EyouSoft.Model.CrmStructure.MCrmLinkman(); MComUser mUser = new MComUser(); IList <EyouSoft.Model.CrmStructure.MCrmLinkman> list = UtilsCommons.GetDataList(); if (list != null && list.Count > 0) { mUser.ContactMobile = list[0].MobilePhone; mUser.ContactName = list[0].Name; mUser.ContactTel = list[0].Telephone; mUser.QQ = list[0].QQ; m.Post = list[0].Post; } if (string.IsNullOrEmpty(UnitName)) { msg = "{\"result\":\"0\",\"msg\":\"单位名称不能为空!\"}"; return(msg); } EyouSoft.Model.SourceStructure.MSourceTravel mTravel = new EyouSoft.Model.SourceStructure.MSourceTravel(); if (!string.IsNullOrEmpty(id)) { mTravel = new EyouSoft.BLL.SourceStructure.BSource().GetTravelServiceModel(id); } EyouSoft.Model.SourceStructure.MSource mModel = new EyouSoft.Model.SourceStructure.MSource(); mModel.Address = this.txtaddress.Text; mModel.CityId = Utils.GetInt(Utils.GetFormValue(this.ddlCity.UniqueID)); mModel.CountryId = Utils.GetInt(Utils.GetFormValue(this.ddlCountry.UniqueID)); mModel.CountyId = Utils.GetInt(Utils.GetFormValue(this.ddlArea.UniqueID)); mModel.ProvinceId = Utils.GetInt(Utils.GetFormValue(this.ddlProvice.UniqueID)); mModel.Name = Utils.GetFormValue(this.txtUnitName.UniqueID).Trim(); mModel.CompanyId = this.SiteUserInfo.CompanyId; mModel.OperatorId = this.SiteUserInfo.UserId; mModel.ContractCode = ContractNum; mModel.DeptId = this.SiteUserInfo.DeptId; mModel.ContractPeriodStart = String.IsNullOrEmpty(ContractStartDate) ? null : (DateTime?)DateTime.Parse(ContractStartDate); mModel.ContractPeriodEnd = String.IsNullOrEmpty(ContractDate) ? null : (DateTime?)DateTime.Parse(ContractDate); //签单 if (RadSign_no.Checked) { mModel.IsPermission = false; } else { mModel.IsPermission = true; } //推荐 if (RadRecommend_no.Checked) { mModel.IsRecommend = false; } else { mModel.IsRecommend = true; } //返佣 mModel.IsCommission = true; if (radno.Checked) { mModel.IsCommission = false; } //合同 if (Radio_hd_no.Checked) { mModel.IsSignContract = false; } else { mModel.IsSignContract = true; mModel.ContractCode = Utils.GetFormValue(this.txtContractNum.UniqueID); } mModel.LastModifierId = this.SiteUserInfo.Name; mModel.LastModifyTime = DateTime.Now; mModel.LicenseKey = PermitNum; mModel.UnitPolicy = Policy; mModel.Desc = Character; mModel.IssueTime = DateTime.Now; if (!String.IsNullOrEmpty(id)) { mModel.SourceId = id; } #region 合同附件 EyouSoft.Model.ComStructure.MComAttach visaModel = new EyouSoft.Model.ComStructure.MComAttach(); if (oldVisaUpload.Length > 0) { for (int i = 0; i < oldVisaUpload.Length; i++) { visaModel.FilePath = oldVisaUpload[i].Split('|')[1]; visaModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商合同附件; visaModel.Name = oldVisaUpload[i].Split('|')[0]; visaModel.Size = 0; } } if (visaUpload.Length > 0) { for (int i = 0; i < visaUpload.Length; i++) { if (visaUpload[i].Trim() != "") { if (visaUpload[i].Split('|').Length > 1) { visaModel.Downloads = 0; visaModel.FilePath = visaUpload[i].Split('|')[1]; visaModel.ItemType = EyouSoft.Model.EnumType.ComStructure.AttachItemType.供应商合同附件; visaModel.Name = visaUpload[i].Split('|')[0]; visaModel.Size = 0; } } } } mModel.ContractAttach = visaModel; #endregion mUser.CompanyId = this.SiteUserInfo.CompanyId; //mUser.IsEnable = true; mUser.IssueTime = DateTime.Now; mUser.UserType = EyouSoft.Model.EnumType.ComStructure.UserType.供应商; MSourceTravelInfo Traveinfo = new MSourceTravelInfo(); Traveinfo.LegalRepresentative = LegalName; Traveinfo.Routes = Character; Traveinfo.Telephone = Tel; mTravel.SourceTravelModel = Traveinfo; //mTravel.UserModel = mUser; mTravel.SourceModel = mModel; mTravel.LinkManList = list; //mTravel.SourceTravelModel EyouSoft.BLL.SourceStructure.BSource bllsource = new EyouSoft.BLL.SourceStructure.BSource(); EyouSoft.BLL.ComStructure.BComUser blluser = new EyouSoft.BLL.ComStructure.BComUser(); int result = 0; if (t) {//新增 result = bllsource.AddTravelServiceModel(mTravel); if (result == -1) { msg = "{\"result\":\"0\",\"msg\":\"单位名称已存在!\"}"; return(msg); } } else { //编辑 result = bllsource.UpdateTravelServiceModel(mTravel); if (result == -1) { msg = "{\"result\":\"0\",\"msg\":\"单位名称已存在!\"}"; return(msg); } } string type = t ? "新增" : "修改"; if (result > 0) { msg = "{\"result\":\"1\",\"msg\":\"" + type + "成功!\"}"; return(msg); } else { msg = "{\"result\":\"0\",\"msg\":\"" + type + "失败!\"}"; return(msg); } }