/// <summary> /// 更新一条数据 /// </summary> public bool Update(YJUI.Model.ui_role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update ui_role set "); strSql.Append("rolename=@rolename,"); strSql.Append("beizhu=@beizhu"); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@rolename", SqlDbType.NVarChar, 50), new SqlParameter("@beizhu", SqlDbType.NVarChar, 100), new SqlParameter("@id", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = model.rolename; parameters[1].Value = model.beizhu; parameters[2].Value = model.id; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(YJUI.Model.ui_role model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ui_role("); strSql.Append("id,rolename,beizhu,crdate)"); strSql.Append(" values ("); strSql.Append("@id,@rolename,@beizhu,@crdate)"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@rolename", SqlDbType.NVarChar, 50), new SqlParameter("@beizhu", SqlDbType.NVarChar, 100), new SqlParameter("@crdate", SqlDbType.DateTime) }; parameters[0].Value = Guid.NewGuid(); parameters[1].Value = model.rolename; parameters[2].Value = model.beizhu; parameters[3].Value = model.crdate; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(YJUI.Model.ui_role m_role, List <Model.ui_role_menu> T_role_menu) { string guid = new Guid().ToString(); StringBuilder strSql = new StringBuilder(); strSql.Append("insert into ui_role("); strSql.Append("id,rolename,beizhu,crdate)"); strSql.Append(" values ("); strSql.Append("@id,@rolename,@beizhu,@crdate)"); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@rolename", SqlDbType.NVarChar, 50), new SqlParameter("@beizhu", SqlDbType.NVarChar, 100), new SqlParameter("@crdate", SqlDbType.DateTime) }; parameters[0].Value = m_role.id; parameters[1].Value = m_role.rolename; parameters[2].Value = m_role.beizhu; parameters[3].Value = m_role.crdate; Hashtable SQLStringList = new Hashtable(); SQLStringList.Add(strSql, parameters); foreach (Model.ui_role_menu m_role_menu in T_role_menu) { StringBuilder strSql1 = new StringBuilder(); strSql1.Append("insert into ui_role_menu("); strSql1.Append("ui_role_id,ui_menu_id,crdate)"); strSql1.Append(" values ("); strSql1.Append("@ui_role_id,@ui_menu_id,@crdate)"); strSql1.Append(";select @@IDENTITY"); SqlParameter[] parameters1 = { new SqlParameter("@ui_role_id", SqlDbType.UniqueIdentifier, 16), new SqlParameter("@ui_menu_id", SqlDbType.Int, 4), new SqlParameter("@crdate", SqlDbType.DateTime) }; parameters1[0].Value = m_role_menu.ui_role_id; parameters1[1].Value = m_role_menu.ui_menu_id; parameters1[2].Value = m_role_menu.crdate; SQLStringList.Add(strSql1, parameters1); } try { DbHelperSQL.ExecuteSqlTran(SQLStringList); return(true); } catch (Exception e) { return(false); } }
/// <summary> /// 得到一个对象实体 /// </summary> public YJUI.Model.ui_role DataRowToModel(DataRow row) { YJUI.Model.ui_role model = new YJUI.Model.ui_role(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = new Guid(row["id"].ToString()); } if (row["rolename"] != null) { model.rolename = row["rolename"].ToString(); } if (row["beizhu"] != null) { model.beizhu = row["beizhu"].ToString(); } if (row["crdate"] != null && row["crdate"].ToString() != "") { model.crdate = DateTime.Parse(row["crdate"].ToString()); } } return(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public YJUI.Model.ui_role GetModel(Guid id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 id,rolename,beizhu,crdate from ui_role "); strSql.Append(" where id=@id "); SqlParameter[] parameters = { new SqlParameter("@id", SqlDbType.UniqueIdentifier, 16) }; parameters[0].Value = id; YJUI.Model.ui_role model = new YJUI.Model.ui_role(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { return(DataRowToModel(ds.Tables[0].Rows[0])); } else { return(null); } }