/// <summary> /// 获得数据列表 /// </summary> public List <zs.Model.Sys_Role> DataTableToList(DataTable dt) { List <zs.Model.Sys_Role> modelList = new List <zs.Model.Sys_Role>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { zs.Model.Sys_Role model; for (int n = 0; n < rowsCount; n++) { model = new zs.Model.Sys_Role(); if (dt.Rows[n]["ID"] != null && dt.Rows[n]["ID"].ToString() != "") { model.ID = int.Parse(dt.Rows[n]["ID"].ToString()); } if (dt.Rows[n]["RoleName"] != null && dt.Rows[n]["RoleName"].ToString() != "") { model.RoleName = dt.Rows[n]["RoleName"].ToString(); } if (dt.Rows[n]["Description"] != null && dt.Rows[n]["Description"].ToString() != "") { model.Description = dt.Rows[n]["Description"].ToString(); } if (dt.Rows[n]["validateDate"] != null && dt.Rows[n]["validateDate"].ToString() != "") { model.validateDate = DateTime.Parse(dt.Rows[n]["validateDate"].ToString()); } modelList.Add(model); } } return(modelList); }
protected void btnSave_Click(object sender, EventArgs e) { string RoleName = this.txtRoleName.Text; string Description = this.txtDescription.Text; zs.Model.Sys_Role model = new zs.Model.Sys_Role(); model.RoleName = RoleName; model.Description = Description; bll.Add(model); BindData(); }
protected void gridView_RowUpdating(object sender, GridViewUpdateEventArgs e) { string id = gridView.DataKeys[e.RowIndex].Values[0].ToString(); //string Sxh=GridView1.Rows[e.RowIndex].Cells[0].Text.Trim(); string name = ((TextBox)gridView.Rows[e.RowIndex].Cells[1].Controls[0]).Text.Trim(); string desc = ((TextBox)gridView.Rows[e.RowIndex].Cells[2].Controls[0]).Text.Trim(); zs.Model.Sys_Role model = bll.GetModel(int.Parse(id)); model.Description = desc; model.RoleName = name; bll.Update(model); gridView.EditIndex = -1; BindData(); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(zs.Model.Sys_Role model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(zs.Model.Sys_Role model) { return(dal.Add(model)); }