Esempio n. 1
0
        public static void ModifyT_RoleMenuRelation(T_RoleMenuRelation t_RoleMenuRelation)
        {
            string sql =
                "UPDATE T_RoleMenuRelations " +
                "SET " +
                "role_id = @role_id, " +
                "menu_id = @menu_id " +
                "WHERE Id = @Id";


            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@Id", t_RoleMenuRelation.Id),
                    new SqlParameter("@role_id", DBHelper.GetValueByWhetherNull(t_RoleMenuRelation.Role_id)),
                    new SqlParameter("@menu_id", DBHelper.GetValueByWhetherNull(t_RoleMenuRelation.Menu_id))
                };

                DBHelper.ExecuteCommand(sql, para);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Esempio n. 2
0
        public static T_RoleMenuRelation AddT_RoleMenuRelation(T_RoleMenuRelation t_RoleMenuRelation)
        {
            string sql =
                "INSERT T_RoleMenuRelations (role_id, menu_id)" +
                "VALUES (@role_id, @menu_id)";

            sql += " ; SELECT @@IDENTITY";

            try
            {
                SqlParameter[] para = new SqlParameter[]
                {
                    new SqlParameter("@role_id", DBHelper.GetValueByWhetherNull(t_RoleMenuRelation.Role_id)),
                    new SqlParameter("@menu_id", DBHelper.GetValueByWhetherNull(t_RoleMenuRelation.Menu_id))
                };

                int newId = DBHelper.GetScalar(sql, para);
                return(GetT_RoleMenuRelationById(newId));
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Esempio n. 3
0
        public static T_RoleMenuRelation GetT_RoleMenuRelationById(int id)
        {
            string sql = "SELECT * FROM T_RoleMenuRelations WHERE Id = @Id";

            try
            {
                SqlDataReader reader = DBHelper.GetReader(sql, new SqlParameter("@Id", id));
                if (reader.Read())
                {
                    T_RoleMenuRelation t_RoleMenuRelation = new T_RoleMenuRelation();

                    try{
                        t_RoleMenuRelation.Id = (int)reader["Id"];
                    }catch
                    {}
                    try{
                        t_RoleMenuRelation.Role_id = (int)reader["role_id"];
                    }catch
                    {}
                    try{
                        t_RoleMenuRelation.Menu_id = (int)reader["menu_id"];
                    }catch
                    {}

                    reader.Close();

                    return(t_RoleMenuRelation);
                }
                else
                {
                    reader.Close();
                    return(null);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Esempio n. 4
0
        private static List <T_RoleMenuRelation> GetT_RoleMenuRelationsBySql(string sql, params SqlParameter[] values)
        {
            List <T_RoleMenuRelation> list = new List <T_RoleMenuRelation>();

            try
            {
                DataTable table = DBHelper.GetDataSet(sql, values);

                foreach (DataRow row in table.Rows)
                {
                    T_RoleMenuRelation t_RoleMenuRelation = new T_RoleMenuRelation();

                    try{
                        t_RoleMenuRelation.Id = (int)row["Id"];
                    }catch
                    {}
                    try{
                        t_RoleMenuRelation.Role_id = (int)row["role_id"];
                    }catch
                    {}
                    try{
                        t_RoleMenuRelation.Menu_id = (int)row["menu_id"];
                    }catch
                    {}

                    list.Add(t_RoleMenuRelation);
                }

                return(list);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                throw e;
            }
        }
Esempio n. 5
0
 public static void DeleteT_RoleMenuRelation(T_RoleMenuRelation t_RoleMenuRelation)
 {
     DeleteT_RoleMenuRelationById(t_RoleMenuRelation.Id);
 }
Esempio n. 6
0
 public static void ModifyT_RoleMenuRelation(T_RoleMenuRelation t_RoleMenuRelation)
 {
     T_RoleMenuRelationService.ModifyT_RoleMenuRelation(t_RoleMenuRelation);
 }
Esempio n. 7
0
 public static void DeleteT_RoleMenuRelation(T_RoleMenuRelation t_RoleMenuRelation)
 {
     T_RoleMenuRelationService.DeleteT_RoleMenuRelation(t_RoleMenuRelation);
 }
Esempio n. 8
0
 public static T_RoleMenuRelation AddT_RoleMenuRelation(T_RoleMenuRelation t_RoleMenuRelation)
 {
     return(T_RoleMenuRelationService.AddT_RoleMenuRelation(t_RoleMenuRelation));
 }