/// <summary> /// 获得数据列表 /// </summary> public List<AutekInfo.Model.Emp_Roles> DataTableToList(DataTable dt) { List<AutekInfo.Model.Emp_Roles> modelList = new List<AutekInfo.Model.Emp_Roles>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { AutekInfo.Model.Emp_Roles model; for (int n = 0; n < rowsCount; n++) { model = new AutekInfo.Model.Emp_Roles(); if(dt.Rows[n]["role_id"].ToString()!="") { model.role_id=int.Parse(dt.Rows[n]["role_id"].ToString()); } model.role_code= dt.Rows[n]["role_code"].ToString(); model.role_name= dt.Rows[n]["role_name"].ToString(); model.role_describe= dt.Rows[n]["role_describe"].ToString(); modelList.Add(model); } } return modelList; }
public string AddRoles() { string role_code=Request["role_code"]; string role_name=Request["role_name"]; string role_describe=Request["role_describe"]; var b_role = new AutekInfo.BLL.Emp_Roles(); var list = b_role.GetModelList(String.Format("role_code='{0}' or role_name='{1}'",role_code,role_name)); if(list.Count>0){ return "该角色已存在!"; } var m = new AutekInfo.Model.Emp_Roles(); m.role_code = role_code; m.role_name = role_name; m.role_describe = role_describe; return b_role.Add(m).ToString(); }