public UserSecurity() { corp = new Model.Corporation(); dept = new Model.Department(); assets = new List<Data.Model.Asset>(); authValues = new Dictionary<Data.StyleEnum, Data.DetailCollection>(); authGroups = new List<Model.AuthGroup>(); roles = new List<Model.Role>(); menus = new List<Model.Menu>(); authOptions = new List<Model.AuthOption>(); authOptionDetails = new List<Model.AuthOptionDetail>(); refs = new List<Model.AuthOptionDetailEmpRef>(); }
public ResultModel Load(UserModel user, int empId) { ResultModel result = new ResultModel(); try { string cmdText = "select c.* from dbo.CorpDept cd inner join dbo.Corporation c on cd.CorpId = c.CorpId inner join dbo.DeptEmp de on de.DeptId = cd.DeptId where de.EmpId=@empId"; SqlParameter[] paras = new SqlParameter[1]; paras[0] = new SqlParameter("@empId", empId); DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, cmdText, paras, CommandType.Text); List<Corporation> corporations = new List<Corporation>(); foreach (DataRow dr in dt.Rows) { Corporation corporation = new Corporation(); corporation.CorpId = Convert.ToInt32(dr["CorpId"]); if (dr["ParentId"] != DBNull.Value) { corporation.ParentId = Convert.ToInt32(dr["ParentId"]); } if (dr["CorpCode"] != DBNull.Value) { corporation.CorpCode = Convert.ToString(dr["CorpCode"]); } if (dr["CorpName"] != DBNull.Value) { corporation.CorpName = Convert.ToString(dr["CorpName"]); } if (dr["CorpEName"] != DBNull.Value) { corporation.CorpEName = Convert.ToString(dr["CorpEName"]); } if (dr["TaxPayerId"] != DBNull.Value) { corporation.TaxPayerId = dr["TaxPayerId"].ToString(); } if (dr["CorpFullName"] != DBNull.Value) { corporation.CorpFullName = Convert.ToString(dr["CorpFullName"]); } if (dr["CorpFullEName"] != DBNull.Value) { corporation.CorpFullEName = Convert.ToString(dr["CorpFullEName"]); } if (dr["CorpAddress"] != DBNull.Value) { corporation.CorpAddress = Convert.ToString(dr["CorpAddress"]); } if (dr["CorpEAddress"] != DBNull.Value) { corporation.CorpEAddress = Convert.ToString(dr["CorpEAddress"]); } if (dr["CorpTel"] != DBNull.Value) { corporation.CorpTel = Convert.ToString(dr["CorpTel"]); } if (dr["CorpFax"] != DBNull.Value) { corporation.CorpFax = Convert.ToString(dr["CorpFax"]); } if (dr["CorpZip"] != DBNull.Value) { corporation.CorpZip = Convert.ToString(dr["CorpZip"]); } if (dr["CorpType"] != DBNull.Value) { corporation.CorpType = Convert.ToInt32(dr["CorpType"]); } if (dr["CorpStatus"] != DBNull.Value) { corporation.CorpStatus = (Common.StatusEnum)Enum.Parse(typeof(Common.StatusEnum), dr["CorpStatus"].ToString()); } if (dr["CreatorId"] != DBNull.Value) { corporation.CreatorId = Convert.ToInt32(dr["CreatorId"]); } if (dr["CreateTime"] != DBNull.Value) { corporation.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["LastModifyId"] != DBNull.Value) { corporation.LastModifyId = Convert.ToInt32(dr["LastModifyId"]); } if (dr["LastModifyTime"] != DBNull.Value) { corporation.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]); } corporations.Add(corporation); } result.AffectCount = dt.Rows.Count; result.Message = "获取列表成功"; result.ResultStatus = 0; result.ReturnValue = corporations; } catch (Exception ex) { result.Message = ex.Message; } return result; }
public ResultModel LoadAuthSelfCorp(UserModel user) { ResultModel result = new ResultModel(); try { NFMT.Authority.CorpAuth auth = new NFMT.Authority.CorpAuth(); auth.AuthColumnNames.Add("corp.CorpId"); result = auth.CreateAuthorityStr(user); string cmdText = string.Format("select corp.* from dbo.Corporation corp where corp.IsSelf=1 and corp.CorpStatus ={0} {1}", (int)StatusEnum.已生效, result.ReturnValue.ToString()); DataTable dt = SqlHelper.ExecuteDataTable(ConnectString, cmdText, null, CommandType.Text); List<Corporation> corporations = new List<Corporation>(); foreach (DataRow dr in dt.Rows) { Corporation corporation = new Corporation(); corporation.CorpId = Convert.ToInt32(dr["CorpId"]); if (dr["ParentId"] != DBNull.Value) { corporation.ParentId = Convert.ToInt32(dr["ParentId"]); } if (dr["CorpCode"] != DBNull.Value) { corporation.CorpCode = Convert.ToString(dr["CorpCode"]); } if (dr["CorpName"] != DBNull.Value) { corporation.CorpName = Convert.ToString(dr["CorpName"]); } if (dr["CorpEName"] != DBNull.Value) { corporation.CorpEName = Convert.ToString(dr["CorpEName"]); } if (dr["TaxPayerId"] != DBNull.Value) { corporation.TaxPayerId = dr["TaxPayerId"].ToString(); } if (dr["CorpFullName"] != DBNull.Value) { corporation.CorpFullName = Convert.ToString(dr["CorpFullName"]); } if (dr["CorpFullEName"] != DBNull.Value) { corporation.CorpFullEName = Convert.ToString(dr["CorpFullEName"]); } if (dr["CorpAddress"] != DBNull.Value) { corporation.CorpAddress = Convert.ToString(dr["CorpAddress"]); } if (dr["CorpEAddress"] != DBNull.Value) { corporation.CorpEAddress = Convert.ToString(dr["CorpEAddress"]); } if (dr["CorpTel"] != DBNull.Value) { corporation.CorpTel = Convert.ToString(dr["CorpTel"]); } if (dr["CorpFax"] != DBNull.Value) { corporation.CorpFax = Convert.ToString(dr["CorpFax"]); } if (dr["CorpZip"] != DBNull.Value) { corporation.CorpZip = Convert.ToString(dr["CorpZip"]); } if (dr["CorpType"] != DBNull.Value) { corporation.CorpType = Convert.ToInt32(dr["CorpType"]); } if (dr["CorpStatus"] != DBNull.Value) { corporation.CorpStatus = (Common.StatusEnum)Enum.Parse(typeof(Common.StatusEnum), dr["CorpStatus"].ToString()); } if (dr["CreatorId"] != DBNull.Value) { corporation.CreatorId = Convert.ToInt32(dr["CreatorId"]); } if (dr["CreateTime"] != DBNull.Value) { corporation.CreateTime = Convert.ToDateTime(dr["CreateTime"]); } if (dr["LastModifyId"] != DBNull.Value) { corporation.LastModifyId = Convert.ToInt32(dr["LastModifyId"]); } if (dr["LastModifyTime"] != DBNull.Value) { corporation.LastModifyTime = Convert.ToDateTime(dr["LastModifyTime"]); } corporations.Add(corporation); } result.AffectCount = dt.Rows.Count; result.Message = "获取列表成功"; result.ResultStatus = 0; result.ReturnValue = corporations; } catch (Exception ex) { result.Message = ex.Message; } return result; }
public override IModel CreateModel(SqlDataReader dr) { Corporation corporation = new Corporation(); int indexCorpId = dr.GetOrdinal("CorpId"); corporation.CorpId = Convert.ToInt32(dr[indexCorpId]); int indexParentId = dr.GetOrdinal("ParentId"); if (dr["ParentId"] != DBNull.Value) { corporation.ParentId = Convert.ToInt32(dr[indexParentId]); } int indexCorpCode = dr.GetOrdinal("CorpCode"); if (dr["CorpCode"] != DBNull.Value) { corporation.CorpCode = Convert.ToString(dr[indexCorpCode]); } int indexCorpName = dr.GetOrdinal("CorpName"); corporation.CorpName = Convert.ToString(dr[indexCorpName]); int indexCorpEName = dr.GetOrdinal("CorpEName"); if (dr["CorpEName"] != DBNull.Value) { corporation.CorpEName = Convert.ToString(dr[indexCorpEName]); } int indexTaxPayerId = dr.GetOrdinal("TaxPayerId"); if (dr["TaxPayerId"] != DBNull.Value) { corporation.TaxPayerId = Convert.ToString(dr[indexTaxPayerId]); } int indexCorpFullName = dr.GetOrdinal("CorpFullName"); if (dr["CorpFullName"] != DBNull.Value) { corporation.CorpFullName = Convert.ToString(dr[indexCorpFullName]); } int indexCorpFullEName = dr.GetOrdinal("CorpFullEName"); if (dr["CorpFullEName"] != DBNull.Value) { corporation.CorpFullEName = Convert.ToString(dr[indexCorpFullEName]); } int indexCorpAddress = dr.GetOrdinal("CorpAddress"); if (dr["CorpAddress"] != DBNull.Value) { corporation.CorpAddress = Convert.ToString(dr[indexCorpAddress]); } int indexCorpEAddress = dr.GetOrdinal("CorpEAddress"); if (dr["CorpEAddress"] != DBNull.Value) { corporation.CorpEAddress = Convert.ToString(dr[indexCorpEAddress]); } int indexCorpTel = dr.GetOrdinal("CorpTel"); if (dr["CorpTel"] != DBNull.Value) { corporation.CorpTel = Convert.ToString(dr[indexCorpTel]); } int indexCorpFax = dr.GetOrdinal("CorpFax"); if (dr["CorpFax"] != DBNull.Value) { corporation.CorpFax = Convert.ToString(dr[indexCorpFax]); } int indexCorpZip = dr.GetOrdinal("CorpZip"); if (dr["CorpZip"] != DBNull.Value) { corporation.CorpZip = Convert.ToString(dr[indexCorpZip]); } int indexCorpType = dr.GetOrdinal("CorpType"); if (dr["CorpType"] != DBNull.Value) { corporation.CorpType = Convert.ToInt32(dr[indexCorpType]); } int indexIsSelf = dr.GetOrdinal("IsSelf"); if (dr["IsSelf"] != DBNull.Value) { corporation.IsSelf = Convert.ToBoolean(dr[indexIsSelf]); } int indexCorpStatus = dr.GetOrdinal("CorpStatus"); corporation.CorpStatus = (Common.StatusEnum)Convert.ToInt32(dr[indexCorpStatus]); int indexCreatorId = dr.GetOrdinal("CreatorId"); corporation.CreatorId = Convert.ToInt32(dr[indexCreatorId]); int indexCreateTime = dr.GetOrdinal("CreateTime"); corporation.CreateTime = Convert.ToDateTime(dr[indexCreateTime]); int indexLastModifyId = dr.GetOrdinal("LastModifyId"); if (dr["LastModifyId"] != DBNull.Value) { corporation.LastModifyId = Convert.ToInt32(dr[indexLastModifyId]); } int indexLastModifyTime = dr.GetOrdinal("LastModifyTime"); if (dr["LastModifyTime"] != DBNull.Value) { corporation.LastModifyTime = Convert.ToDateTime(dr[indexLastModifyTime]); } return corporation; }