/// <summary> /// 获得数据列表 /// </summary> public List <zs.Model.Sys_UserRole> DataTableToList(DataTable dt) { List <zs.Model.Sys_UserRole> modelList = new List <zs.Model.Sys_UserRole>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { zs.Model.Sys_UserRole model; for (int n = 0; n < rowsCount; n++) { model = new zs.Model.Sys_UserRole(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["UserID"] != null && dt.Rows[n]["UserID"].ToString() != "") { model.UserID = int.Parse(dt.Rows[n]["UserID"].ToString()); } if (dt.Rows[n]["RoleID"] != null && dt.Rows[n]["RoleID"].ToString() != "") { model.RoleID = int.Parse(dt.Rows[n]["RoleID"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void ddl_role_SelectedIndexChanged(object sender, EventArgs e) { zs.Model.Sys_UserRole model = new zs.Model.Sys_UserRole(); string userId = ViewState["userid"].ToString(); if (bllur.GetModelList("UserID=" + userId).Count > 0) { model = bllur.GetModelList("UserID=" + userId)[0]; model.UserID = int.Parse(userId); model.RoleID = int.Parse(this.ddl_role.SelectedItem.Value); bllur.Update(model); } else { model.UserID = int.Parse(userId); model.RoleID = int.Parse(this.ddl_role.SelectedItem.Value); bllur.Add(model); } }
private void createData() { zs.BLL.Sys_Role bllr = new zs.BLL.Sys_Role(); zs.BLL.Sys_UserRole bllur = new zs.BLL.Sys_UserRole(); zs.Model.Sys_UserRole model = new zs.Model.Sys_UserRole(); foreach (RepeaterItem ri in Repeater1.Items) { (ri.FindControl("ddl_role") as DropDownList).DataSource = bllr.GetModelList(""); (ri.FindControl("ddl_role") as DropDownList).DataTextField = "RoleName"; (ri.FindControl("ddl_role") as DropDownList).DataValueField = "ID"; (ri.FindControl("ddl_role") as DropDownList).DataBind(); //(ri.FindControl("ddl_role") as DropDownList).SelectedValue = string userId = (ri.FindControl("HiddenField1") as HiddenField).Value; if (bllur.GetModelList("UserID=" + userId).Count > 0) { model = bllur.GetModelList("UserID=" + userId)[0]; (ri.FindControl("ddl_role") as DropDownList).SelectedValue = model.RoleID.Value.ToString(); } } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(zs.Model.Sys_UserRole model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(zs.Model.Sys_UserRole model) { return(dal.Add(model)); }